/* ═══════════════════════════════════════════
   DESIGN SYSTEM
═══════════════════════════════════════════ */
:root {
    /* Colors - Slate Palette */
    --bg: #020617;
    --surface: #0f172a;
    --surface-raised: #1e293b;
    --brand: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    /* Text */
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --text-muted: #4b5e78;

    /* Borders & Accents */
    --border: #1e293b;
    --border-light: rgba(255, 255, 255, 0.08);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Layout */
    --max-site-width: 1300px;
    --panel-height: calc(110vh - 130px);
    --panel-max-height: 840px;
    --panel-min-height: 480px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 22px;
    --radius-xl: 20px;
}

/* Light Theme Overrides */
body[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-raised: #f1f5f9;
    --text-main: #0f172a;
    --text-dim: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: rgba(0, 0, 0, 0.05);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html,
body {
    width: 100%;
    height: 100%;
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    overflow-x: hidden;
    scroll-behavior: smooth;
    transition: background-color 0.3s, color 0.3s;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input,
textarea {
    font-family: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* ============================================================
   HEADER & NAVIGATION
   ============================================================ */

.sticky-wrapper {
    position: sticky;
    top: 0;
    z-index: 2000;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.header-content {
    max-width: var(--max-site-width);
    margin: 0 auto;
    padding: 0 32px;
    height: 70px;
    display: grid;
    grid-template-columns: 180px 1fr 180px;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: var(--text-main);
}

.logo img {
    height: 39px;
    width: 39px;
}

.logo span {
    font-weight: 800;
    font-size: 1.45rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

.search-container i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-bar {
    width: 100%;
    padding: 9px 16px 9px 38px;
    background-color: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ============================================================
   PLAYER LAYOUT
   ============================================================ */

.player-container {
    width: 100%;
    max-width: var(--max-site-width);
    margin: 0 auto;
    padding: 20px 32px 28px;
    flex-grow: 1;
}

.player-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: stretch;
}

@media (min-width: 1024px) {
    .player-layout {
        grid-template-columns: 2.4fr 1fr;
    }
}

.video-main-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.video-panel {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    height: 100%;
}

@media (min-width: 1024px) {
    .video-panel {
        min-height: var(--panel-min-height);
        max-height: var(--panel-max-height);
    }
}

.video-player-container {
    background-color: #000;
    flex: 1;
    min-height: 0;
    position: relative;
}

@media (max-width: 1023px) {
    .video-player-container {
        flex: none;
        aspect-ratio: 16 / 9;
    }
}

.video-player-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-title-section {
    padding: 14px 18px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.video-title {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.date-span {
    color: orange;
    font-size: 0.7em;
    font-weight: 700;
}

.action-bar {
    display: flex;
    height: 46px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.action-part {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-dim);
    border-right: 1px solid var(--border);
    font-size: 0.9rem;
    transition: background 0.18s, color 0.18s;
}

.action-part:last-child {
    border-right: none;
}

.action-part:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

/* ============================================================
   LIVE CHAT SECTION
   ============================================================ */

.live-chat-section {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    height: var(--panel-height);
    max-height: var(--panel-max-height);
    min-height: var(--panel-min-height);
}

@media (max-width: 1023px) {
    .live-chat-section {
        height: 560px;
        max-height: none;
    }
}

/* JOIN CHAT WRAP */
#join-wrap {
    position: absolute;
    inset: 0;
    z-index: 100;
    background-color: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.join-card {
    text-align: center;
    width: 100%;
    max-width: 320px;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.join-icon {
    font-size: 2.5rem;
    color: var(--brand);
    margin-bottom: 1.25rem;
}

.join-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.join-desc {
    color: var(--text-dim);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--brand);
}

.primary-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--brand);
    color: white;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* CHAT INTERFACE */
#chat-wrap {
    display: none;
    flex-direction: column;
    height: 100%;
}

#chat-wrap.on {
    display: flex;
}

.chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-room-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 99px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.online-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* MESSAGES AREA */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
}

.message-row {
    padding: 6px 18px;
    display: flex;
    gap: 12px;
    position: relative;
    transition: background 0.1s;
}

.message-row:hover {
    background: rgba(255, 255, 255, 0.015);
}

.message-row.grouped {
    padding-top: 2px;
    padding-bottom: 2px;
}

.message-row.grouped .avatar,
.message-row.grouped .username,
.message-row.grouped .timestamp {
    display: none;
}

.message-row.grouped .message-content {
    margin-left: 44px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.username {
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.timestamp {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.message-text {
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
    color: var(--text-main);
}

.message-text.deleted {
    font-style: italic;
    color: var(--text-muted);
}

/* INPUT AREA */
.chat-input-wrapper {
    padding: 12px 18px 18px;
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    flex-shrink: 0;
}

.input-container {
    background-color: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.input-toolbar {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-light);
    gap: 4px;
}

.tool-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.input-area {
    display: flex;
    align-items: flex-end;
    padding: 8px 12px 10px;
    gap: 12px;
}

textarea#inp {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 0.875rem;
    padding: 4px 0;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.send-btn {
    width: 32px;
    height: 32px;
    background-color: var(--brand);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.send-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

/* PICKERS */
.picker {
    position: absolute;
    bottom: 100%;
    left: 18px;
    right: 18px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    height: 280px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 12px;
    animation: pickerIn 0.2s ease-out;
}

@keyframes pickerIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.picker.on {
    display: flex;
}

.picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.picker-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.82rem;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.picker-search:focus {
    border-color: var(--brand);
}

.picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}

.ep-cats {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
    scrollbar-width: none;
}

.ep-cats::-webkit-scrollbar {
    display: none;
}

.ep-cat-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.75rem;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ep-cat-btn.active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}

.ep-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 4px;
}

.ep-e {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.ep-e:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.18) rotate(4deg);
}

.gif-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.gif-grid img {
    width: 100%;
    height: 76px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.gif-grid img:hover {
    opacity: 0.85;
    transform: scale(1.03);
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */

.admin-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.35);
}

.admin-panel.on {
    transform: translateX(0);
}

.admin-panel-header {
    padding: 1.1rem 1.25rem;
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-panel-header span {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.admin-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.admin-section-title {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 0.7rem;
}

.admin-input,
.admin-select {
    width: 100%;
    padding: 0.45rem 0.7rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.78rem;
    font-family: 'Poppins', sans-serif;
    margin-bottom: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.admin-input:focus,
.admin-select:focus {
    border-color: var(--brand);
}

.admin-btn {
    padding: 0.45rem 0.8rem;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.73rem;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    width: 100%;
    transition: background 0.18s;
}

.admin-btn:hover {
    background: var(--primary-hover);
}

.admin-btn.danger {
    background: var(--danger);
}

.admin-btn.danger:hover {
    background: #dc2626;
}

.admin-user-list {
    display: flex;
    flex-direction: column;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.admin-user-name {
    font-weight: 600;
    font-size: 0.75rem;
}

.admin-user-role {
    font-size: 0.63rem;
    color: var(--text-dim);
}

.admin-user-btns {
    display: flex;
    gap: 4px;
}

.admin-btn-sm {
    padding: 3px 7px;
    font-size: 0.68rem;
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.admin-btn-sm:hover {
    color: var(--text-main);
    border-color: var(--text-dim);
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 5000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    animation: modalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow-lg);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.93) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============================================================
   ROLE BADGES
   ============================================================ */

.role-badge {
    font-size: 0.58rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 4px;
    vertical-align: middle;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.role-badge.mod {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

/* ============================================================
   FOOTER
   ============================================================ */

footer {
    border-top: 1px solid var(--border);
    padding: 28px 20px;
    text-align: center;
    background: var(--surface);
    margin-top: auto;
}

.footer-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.65;
}

/* ============================================================
   FLOATING BUTTONS & TOASTS
   ============================================================ */

.theme-float {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 48px;
    height: 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3000;
    color: var(--text-dim);
    box-shadow: var(--shadow-md);
    transition: color 0.2s, transform 0.3s, box-shadow 0.2s;
    font-size: 0.95rem;
}

.theme-float:hover {
    color: var(--text-main);
    transform: rotate(28deg) scale(1.08);
    box-shadow: var(--shadow-lg);
}

.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 22px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-family: 'Poppins', sans-serif;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.toast.on {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 850px) {
    .header-content {
        display: flex;
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 10px;
    }

    .player-container {
        padding: 12px 14px 20px;
    }

    .video-title {
        font-size: 1rem;
    }

    .live-chat-section {
        min-height: 520px;
    }

    .action-bar {
        height: 42px;
    }

    .action-part {
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .player-container {
        padding: 8px 10px 16px;
    }

    .modal-box {
        padding: 1.5rem;
    }
}