@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
    color-scheme: dark;
    font-family: Vazirmatn, Tahoma, sans-serif;
    background: #090d15;
    color: #eef2f8;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% -20%, rgba(52, 94, 165, .22), transparent 55%),
        #090d15;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.viewer-shell,
.admin-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.viewer-header,
.admin-header,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.admin-menu {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    margin-bottom: 18px;
    border: 1px solid #222b3a;
    border-radius: 12px;
    padding: 8px;
    background: rgba(12, 18, 29, .96);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    backdrop-filter: blur(12px);
    scrollbar-width: thin;
}

.admin-menu-link {
    flex: 0 0 auto;
    border-radius: 8px;
    padding: 9px 14px;
    color: #aab8cf;
    font-size: .88rem;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}

.admin-menu-link:hover {
    background: #182232;
    color: #fff;
}

.admin-menu-link.active {
    background: #24416b;
    color: #fff;
}

.admin-menu-logout {
    flex: 0 0 auto;
    margin-inline-start: auto;
}

.admin-page-layout {
    display: block;
}

.admin-page-layout.has-video-editor {
    display: grid;
    grid-template-columns: minmax(0, .92fr) minmax(340px, 1.08fr);
    align-items: start;
    gap: 18px;
    direction: ltr;
}

.admin-main-content,
.video-editor {
    min-width: 0;
    direction: rtl;
}

.video-editor {
    position: sticky;
    top: 82px;
}

.editor-preview-frame {
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid #273449;
    border-radius: 12px;
    background: #000;
}

.editor-preview-frame video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.editor-title {
    overflow-wrap: anywhere;
    margin: 16px 0 4px;
    font-size: 1.05rem;
}

.editor-duration {
    margin: 0 0 14px;
    font-size: .82rem;
}

.editor-schedule-form {
    display: grid;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #283347;
}

.editor-schedule-form .muted {
    margin: 0;
    font-size: .8rem;
    line-height: 1.8;
}

.editor-schedule-form input {
    direction: ltr;
    text-align: left;
}

.archive-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.archive-row {
    display: grid;
    grid-template-columns: minmax(100px, 140px) minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid #283347;
    border-radius: 12px;
    background: #0d1420;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.archive-row:hover {
    border-color: #405a80;
    background: #111b29;
}

.archive-row.selected,
.playlist-row.selected {
    border-color: #6293f5;
    background: #132039;
}

.archive-row-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    grid-column: 1 / -1;
}

.playlist-context-menu {
    position: fixed;
    z-index: 1000;
    display: grid;
    min-width: 196px;
    gap: 3px;
    padding: 6px;
    border: 1px solid #354258;
    border-radius: 10px;
    background: #111a28;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .42);
}

.playlist-context-menu button {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #e4eaf3;
    cursor: pointer;
    padding: 9px 11px;
    text-align: right;
}

.playlist-context-menu button:hover {
    background: #24334a;
}

.viewer-header,
.admin-header {
    margin-bottom: 24px;
}

.brand {
    font-size: 1.15rem;
    font-weight: 700;
}

.admin-link {
    color: #aab8cf;
    font-size: .9rem;
}

.admin-link:hover {
    color: #fff;
}

.player-card,
.panel {
    overflow: hidden;
    border: 1px solid #222b3a;
    border-radius: 18px;
    background: rgba(17, 24, 36, .94);
    box-shadow: 0 18px 60px rgba(0, 0, 0, .22);
}

.video-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.video-frame video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    padding: 30px 20px;
    background: rgba(0, 0, 0, .68);
    text-align: center;
    z-index: 1;
}

.player-overlay.hidden {
    display: none;
}

.player-overlay #player-state {
    color: #f4f7fb;
    font-size: .95rem;
}

.video-controls {
    position: absolute;
    inset: auto 0 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: ltr;
    padding: 16px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .72));
}

.video-control-group {
    display: flex;
    align-items: center;
    gap: 9px;
}

.video-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 50%;
    background: rgba(10, 14, 21, .78);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.video-control:hover {
    background: rgba(45, 59, 80, .9);
}

.video-control:focus-visible {
    outline: 2px solid #8db4ff;
    outline-offset: 2px;
}

.video-control svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.video-control #fullscreen-enter-icon,
.video-control #fullscreen-exit-icon {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.video-frame:fullscreen {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
}

.video-frame:fullscreen video {
    width: 100%;
    height: 100%;
}

.video-frame:fullscreen .video-controls {
    padding: 24px;
}

.program-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 26px 8px;
}

.program-info h1,
.panel h1,
.panel h2 {
    margin: 0;
    font-size: 1.35rem;
}

.eyebrow {
    margin: 0 0 4px;
    color: #95a5bd;
    font-size: .8rem;
}

.player-message {
    margin: 0;
    padding: 0 26px 24px;
    font-size: .87rem;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 75, 91, .3);
    border-radius: 99px;
    padding: 5px 11px;
    color: #ff808b;
    font-size: .78rem;
    white-space: nowrap;
}

.live-badge i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff4b5b;
    box-shadow: 0 0 10px #ff4b5b;
}

.muted {
    color: #93a0b4;
}

.admin-shell {
    width: min(1000px, calc(100% - 32px));
}

.panel {
    margin-bottom: 18px;
    padding: 24px;
}

.panel > .muted {
    margin: 8px 0 18px;
    line-height: 1.8;
}

.narrow-panel {
    max-width: 470px;
    margin: 8vh auto;
}

.stack-form,
.settings-grid,
.upload-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.settings-grid {
    grid-template-columns: minmax(230px, 1fr) minmax(230px, 1fr);
    align-items: end;
}

.upload-form {
    grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.5fr) auto;
    align-items: end;
}

.admin-profile-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    align-items: end;
    gap: 16px;
    margin-top: 20px;
}

.admin-create-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
    align-items: end;
    gap: 14px;
    margin: 20px 0;
}

.admins-list {
    display: grid;
    gap: 12px;
}

.admin-row {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #283347;
    border-radius: 12px;
    background: #0d1420;
}

.admin-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-row-header h3 {
    margin: 0;
    font-size: .95rem;
}

.admin-role-badge {
    border: 1px solid #344d70;
    border-radius: 99px;
    padding: 3px 9px;
    color: #b6d2ff;
    font-size: .75rem;
}

.admin-row-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
    align-items: end;
    gap: 12px;
}

label {
    display: grid;
    gap: 8px;
    color: #d3dae5;
    font-size: .88rem;
}

input:not([type="checkbox"]) {
    min-width: 0;
    width: 100%;
    border: 1px solid #354258;
    border-radius: 9px;
    outline: none;
    background: #0c121d;
    color: #f1f5fa;
    padding: 10px 12px;
}

input:focus {
    border-color: #6d9cff;
    box-shadow: 0 0 0 3px rgba(109, 156, 255, .13);
}

input[type="file"] {
    direction: ltr;
    text-align: left;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 43px;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    accent-color: #6293f5;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    transition: filter .15s ease, transform .15s ease;
}

.button:hover:not(:disabled) {
    filter: brightness(1.12);
}

.button:active:not(:disabled) {
    transform: translateY(1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.button-primary {
    min-height: 42px;
    padding: 9px 16px;
    background: #3976e8;
    color: white;
}

.button-secondary {
    min-height: 38px;
    padding: 8px 13px;
    border-color: #39465b;
    background: #182232;
    color: #e6ecf5;
}

.button-danger {
    min-height: 38px;
    padding: 8px 13px;
    border-color: #65323c;
    background: #321b22;
    color: #ffabb3;
}

.button-small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: .8rem;
}

.form-message {
    min-height: 1.2em;
    margin: 0;
    color: #91d6ad;
    font-size: .85rem;
}

.upload-progress {
    display: grid;
    grid-column: 1 / -1;
    gap: 8px;
    padding: 14px;
    border: 1px solid #28364b;
    border-radius: 12px;
    background: #0c131f;
}

.upload-progress-track {
    overflow: hidden;
    width: 100%;
    height: 10px;
    border-radius: 99px;
    background: #263246;
}

.upload-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #3976e8, #70b7ff);
    transition: width .25s ease;
}

.upload-progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #e7edf7;
    font-size: .88rem;
}

.upload-progress #upload-progress-detail,
.upload-progress #upload-progress-elapsed,
.upload-progress #upload-progress-eta {
    margin: 0;
    font-size: .8rem;
}

.error-text {
    color: #ff929b;
}

.playlist {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.playlist-row {
    position: relative;
    display: grid;
    grid-template-columns: 34px minmax(90px, 140px) minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid #283347;
    border-radius: 12px;
    background: #0d1420;
    transition: opacity .15s ease, border-color .15s ease, background .15s ease;
}

.playlist-row.dragging {
    opacity: .4;
}

.playlist-row.drop-before {
    border-top: 3px solid #76a8ff;
}

.playlist-row.drop-after {
    border-bottom: 3px solid #76a8ff;
}

.playlist-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #8fa1ba;
    cursor: grab;
    font-size: 1.55rem;
    letter-spacing: -.5rem;
    padding: 0 9px 5px 0;
    touch-action: none;
}

.playlist-drag-handle:hover {
    background: #1a2638;
    color: #fff;
}

.playlist-drag-handle:active {
    cursor: grabbing;
}

.playlist-preview {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid #2c394d;
    border-radius: 9px;
    background: linear-gradient(135deg, #1a2a3e, #0b1019);
}

.playlist-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-preview-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #91a1b7;
    font-size: .75rem;
}

.playlist-order {
    color: #8293ac;
    font-size: .75rem;
}

.playlist-details {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.playlist-details h3 {
    overflow-wrap: anywhere;
    margin: 0 0 4px;
    font-size: .95rem;
}

.playlist-details p {
    margin: 0;
    font-size: .8rem;
}

.playlist-row .row-actions {
    grid-column: 2 / -1;
}

.offset-control {
    font-size: .8rem;
}

.offset-control input {
    padding: 8px 10px !important;
    direction: ltr;
    text-align: left;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hidden {
    display: none !important;
}

@media (max-width: 780px) {
    .settings-grid,
    .upload-form,
    .admin-profile-form,
    .admin-create-form,
    .admin-row-controls {
        grid-template-columns: 1fr;
    }

    .admin-page-layout.has-video-editor {
        grid-template-columns: 1fr;
        direction: rtl;
    }

    .video-editor {
        position: static;
    }

    .playlist-row {
        grid-template-columns: 34px minmax(92px, 130px) minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        padding: 12px;
    }

    .playlist-drag-handle {
        grid-column: 1;
        grid-row: 1 / 3;
    }

    .playlist-preview {
        grid-column: 2;
        grid-row: 1;
    }

    .playlist-details {
        grid-column: 3;
        grid-row: 1;
    }

    .offset-control,
    .row-actions {
        grid-column: 2 / 4;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .archive-row {
        grid-template-columns: minmax(100px, 130px) minmax(0, 1fr);
        gap: 10px;
    }

    .archive-row-actions {
        grid-column: 1 / -1;
    }

    .viewer-shell,
    .admin-shell {
        width: min(100% - 20px, 1120px);
        padding-top: 18px;
    }

    .panel {
        padding: 18px;
    }

    .admin-menu {
        top: 4px;
        margin-inline: -4px;
    }

    .admin-menu-link {
        padding: 9px 11px;
        font-size: .82rem;
    }

    .program-info {
        padding: 18px 18px 8px;
    }

    .player-message {
        padding: 0 18px 18px;
    }
}
