/* =============================================
   HeroClix Platform — Global Styles
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0d1117;
    --bg-2:       #1f2937;
    --bg-3:       #111827;
    --border:     #374151;
    --text:       #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim:   #6b7280;
    --red:        #dc2626;
    --red-dark:   #b91c1c;
    --gold:       #f59e0b;
    --green:      #22c55e;
    --sidebar-w:  220px;
}

body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; }

/* =============================================
   Judge Layout
   ============================================= */

body.judge-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: #161d2b;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.brand-link {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--red), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}
.nav-item:hover:not(.disabled) { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: rgba(220,38,38,0.15); color: #fca5a5; }
.nav-item.active .nav-icon { filter: none; }
.nav-item.disabled { opacity: 0.35; cursor: not-allowed; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.footer-user { color: var(--text-dim); font-size: 0.8rem; }
.footer-logout {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.15s;
}
.footer-logout:hover { color: var(--red); }

/* =============================================
   Judge Main
   ============================================= */

.judge-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

.judge-header {
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.header-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text);
}
.header-subtitle { color: var(--text-dim); font-size: 0.8rem; }
.header-actions { display: flex; gap: 10px; }

/* Rules banner */
.rules-banner {
    background: rgba(34,197,94,0.08);
    border-bottom: 1px solid rgba(34,197,94,0.2);
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: #86efac;
    flex-shrink: 0;
}
.banner-close {
    background: none;
    border: none;
    color: #86efac;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.7;
}
.banner-close:hover { opacity: 1; }

/* Chat */
.chat-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.messages-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.msg-row {
    display: flex;
    gap: 10px;
    max-width: 78%;
    animation: fadeIn 0.2s ease-out;
}
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.assistant { align-self: flex-start; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.msg-avatar.user-av { background: var(--red); }
.msg-avatar.judge-av { background: linear-gradient(135deg, var(--red-dark), var(--gold)); }

.msg-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-row.user .msg-bubble {
    background: var(--red);
    color: white;
    border-bottom-right-radius: 4px;
}
.msg-row.assistant .msg-bubble {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--gold);
}

.msg-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 4px;
    padding: 0 4px;
}
.msg-row.user .msg-meta { text-align: right; }

/* Typing */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    align-self: flex-start;
}
.typing-text { color: var(--text-dim); font-size: 0.8rem; font-style: italic; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--gold);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.input-area {
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    outline: none;
    max-height: 140px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--red); }
.chat-input::placeholder { color: var(--text-dim); }

/* Buttons */
.btn-send {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.btn-send:hover { opacity: 0.85; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* =============================================
   Modal
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }
.modal-desc { color: var(--text-muted); font-size: 0.875rem; line-height: 1.6; }
.rules-textarea {
    flex: 1;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 14px;
    font-size: 0.85rem;
    font-family: 'Inter', monospace;
    resize: none;
    outline: none;
    min-height: 220px;
    line-height: 1.6;
}
.rules-textarea:focus { border-color: var(--gold); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; }

/* Utility */
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }

/* =============================================
   Language Switcher
   ============================================= */

/* Inline switcher (topbar / header) */
.lang-switcher-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.lang-switcher-inline a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 3px 6px;
    border-radius: 4px;
    transition: color 0.2s;
}
.lang-switcher-inline a:hover { color: var(--text); }
.lang-switcher-inline a.active { color: var(--accent, #dc2626); }
.lang-sep { color: var(--border); }

/* Fixed switcher (login page) */
.lang-switcher-fixed {
    position: fixed;
    top: 16px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    z-index: 100;
}
.lang-switcher-fixed a {
    color: #6b7280;
    text-decoration: none;
    padding: 3px 7px;
    border-radius: 4px;
    transition: color 0.2s;
}
.lang-switcher-fixed a:hover { color: #f3f4f6; }
.lang-switcher-fixed a.active { color: #dc2626; }

/* =============================================
   Language Selection Modal (first visit)
   ============================================= */

.lang-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}
.lang-modal-card {
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.lang-modal-logo {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #dc2626, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}
.lang-modal-title {
    color: #9ca3af;
    font-size: 0.95rem;
    margin-bottom: 28px;
    letter-spacing: 0.5px;
}
.lang-modal-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
}
.lang-modal-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 12px;
    padding: 20px 28px;
    text-decoration: none;
    color: #f3f4f6;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    min-width: 120px;
}
.lang-modal-btn:hover {
    border-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(220,38,38,0.2);
}
.lang-flag { font-size: 2rem; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }
