/* EpicDebates.com - Main Stylesheet */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --agree: #10b981;
    --disagree: #ef4444;
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 16px 0;
    border-radius: var(--radius-xl);
    margin: 20px;
    box-shadow: var(--shadow-lg);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 28px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav a {
    color: var(--white);
    padding: 10px 16px;
    border-radius: var(--radius);
    transition: background 0.2s;
    font-weight: 500;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.nav .btn {
    background: var(--white);
    color: var(--primary);
}

.nav .btn:hover {
    background: var(--gray-100);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 8px;
    display: none;
    z-index: 1000;
    margin-top: 0;
    padding-top: 12px;
}

/* Add invisible bridge to prevent gap */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.dropdown-menu a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.dropdown-menu a i {
    width: 20px;
    color: var(--gray-500);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 8px 0;
}

/* Mobile menu */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn-agree {
    background: var(--agree);
    color: var(--white);
}

.btn-agree:hover {
    background: #059669;
    color: var(--white);
}

.btn-disagree {
    background: var(--disagree);
    color: var(--white);
}

.btn-disagree:hover {
    background: #dc2626;
    color: var(--white);
}

.btn-agree.active,
.btn-disagree.active {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-700);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 6px;
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 6px;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Topic Cards */
.topic-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.topic-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.topic-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
}

.topic-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.topic-title a {
    color: inherit;
}

.topic-title a:hover {
    color: var(--primary);
}

.topic-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: var(--gray-500);
}

.topic-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topic-votes {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.vote-bar {
    flex: 1;
}

.vote-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
}

.vote-bar-track {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.vote-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.vote-bar-fill.agree {
    background: var(--agree);
}

.vote-bar-fill.disagree {
    background: var(--disagree);
}

/* Response Cards */
.response-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.response-card.agree-response {
    border-left: 4px solid var(--agree);
}

.response-card.disagree-response {
    border-left: 4px solid var(--disagree);
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.response-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.response-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.response-username {
    font-weight: 600;
    color: var(--gray-800);
}

.response-time {
    font-size: 13px;
    color: var(--gray-500);
}

.response-stance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.response-stance.agree {
    background: #d1fae5;
    color: #065f46;
}

.response-stance.disagree {
    background: #fee2e2;
    color: #991b1b;
}

.response-content {
    color: var(--gray-700);
    line-height: 1.7;
    margin-bottom: 16px;
}

.response-actions {
    display: flex;
    gap: 16px;
    font-size: 14px;
}

.response-action {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--gray-500);
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0;
}

.response-action:hover {
    color: var(--primary);
}

.response-action.active.thumb-up {
    color: var(--success);
}

.response-action.active.thumb-down {
    color: var(--danger);
}

/* Reply section */
.replies {
    margin-top: 16px;
    margin-left: 32px;
    padding-left: 16px;
    border-left: 2px solid var(--gray-200);
}

.reply-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

/* Stats Widget */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 20px;
    color: var(--white);
    text-align: center;
}

.stat-card.secondary {
    background: linear-gradient(135deg, var(--gray-600) 0%, var(--gray-700) 100%);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 4px;
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.category-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.category-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: var(--white);
}

.category-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.category-count {
    font-size: 14px;
    color: var(--gray-500);
}

/* Leaderboard */
.leaderboard-table {
    width: 100%;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    gap: 16px;
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    background: var(--gray-200);
    color: var(--gray-600);
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: var(--white);
}

.leaderboard-rank.silver {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: var(--white);
}

.leaderboard-rank.bronze {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: var(--white);
}

.leaderboard-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.leaderboard-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.leaderboard-username {
    font-weight: 600;
    color: var(--gray-800);
}

.leaderboard-count {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
}

/* Auth Pages */
.auth-container {
    max-width: 440px;
    margin: 60px auto;
    padding: 0 20px;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--gray-500);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-500);
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 12px;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
}

.avatar-option:hover {
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.2s;
}

.pagination a {
    background: var(--white);
    color: var(--gray-700);
    box-shadow: var(--shadow-sm);
}

.pagination a:hover {
    background: var(--primary);
    color: var(--white);
}

.pagination .active {
    background: var(--primary);
    color: var(--white);
}

/* Footer */
.footer {
    background: var(--gray-800);
    color: var(--gray-300);
    padding: 40px 0;
    margin-top: 60px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--gray-400);
}

.footer-links a:hover {
    color: var(--white);
}

/* Admin Styles */
.admin-sidebar {
    width: 260px;
    background: var(--gray-800);
    min-height: 100vh;
    padding: 20px;
    position: fixed;
    left: 0;
    top: 0;
}

.admin-content {
    margin-left: 260px;
    padding: 24px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 4px;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--gray-700);
    color: var(--white);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.admin-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

.admin-table tr:hover {
    background: var(--gray-50);
}

/* AI Badge */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #8b5cf6;
    color: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    font-weight: 600;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--gray-700);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Turnstile container */
.cf-turnstile {
    margin-bottom: 20px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Responsive */
@media (max-width: 768px) {
    .header {
        margin: 10px;
        border-radius: var(--radius-lg);
    }
    
    .header-container {
        padding: 0 16px;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 16px;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
    
    .nav.active {
        display: flex;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .topic-header {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .auth-card {
        padding: 24px;
    }
    
    .admin-sidebar {
        transform: translateX(-100%);
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
    }
    
    .admin-content {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .topic-votes {
        flex-direction: column;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
    }
}