/* =========================================================
   MiddleTube™
   Corporate Media Archive Interface
   ========================================================= */


/* =========================================================
   THEME VARIABLES
   ========================================================= */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-alt: #f8f9fa;

    --border: #d9dde3;
    --border-strong: #c8cdd5;

    --text: #20242a;
    --muted: #6b7280;
    --subtle: #8a919c;

    --accent: #315f9e;
    --accent-hover: #274e85;

    --danger: #b42318;
    --success: #16704a;

    --radius: 6px;

    --shadow:
        0 1px 2px rgba(0, 0, 0, 0.05);
}


html[data-theme="dark"] {
    --bg: #181a1f;
    --surface: #22252b;
    --surface-alt: #1e2126;

    --border: #343941;
    --border-strong: #454b55;

    --text: #e7e9ec;
    --muted: #a1a7b0;
    --subtle: #7d838d;

    --accent: #6b95d0;
    --accent-hover: #83a8dc;

    --danger: #f97066;
    --success: #54b88a;

    --shadow:
        0 1px 2px rgba(0, 0, 0, 0.25);
}


/* =========================================================
   BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;

    margin: 0;

    background: var(--bg);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}


/* =========================================================
   HEADER
   ========================================================= */

.topbar {
    width: 100%;

    background: var(--surface);

    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;

    width: min(1180px, calc(100% - 48px));

    min-height: 62px;

    margin: 0 auto;
}

.brand {
    color: var(--text);

    font-size: 18px;
    font-weight: 700;

    letter-spacing: -0.2px;
}

.brand span {
    color: var(--muted);

    font-size: 10px;

    vertical-align: super;
}

.nav {
    display: flex;
    align-items: center;

    height: 62px;

    margin-left: 35px;

    gap: 2px;
}

.nav a {
    display: flex;
    align-items: center;

    height: 100%;

    padding: 0 14px;

    border-bottom: 2px solid transparent;

    color: var(--muted);

    font-size: 13px;
    font-weight: 600;
}

.nav a:hover {
    color: var(--text);
    background: var(--surface-alt);
}

.nav a.active {
    color: var(--accent);

    border-bottom-color: var(--accent);
}


/* =========================================================
   MAIN
   ========================================================= */

main {
    width: min(1180px, calc(100% - 48px));

    margin: 0 auto;

    padding: 42px 0 65px;
}


/* =========================================================
   HERO
   ========================================================= */

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 40px;

    padding-bottom: 38px;

    border-bottom: 1px solid var(--border);
}

.eyebrow {
    margin-bottom: 7px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 700;

    letter-spacing: 0.8px;
}

.hero h1 {
    margin: 0;

    color: var(--text);

    font-size: 32px;
    font-weight: 700;

    letter-spacing: -0.8px;
}

.hero-description {
    max-width: 600px;

    margin: 8px 0 0;

    color: var(--muted);

    font-size: 14px;
}


/* =========================================================
   STATISTICS
   ========================================================= */

.library-stats {
    display: flex;

    gap: 10px;
}

.stat-card {
    min-width: 100px;

    padding: 11px 14px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

.stat-card strong {
    display: block;

    color: var(--text);

    font-size: 18px;
    font-weight: 700;
}

.stat-card span {
    display: block;

    margin-top: 1px;

    color: var(--muted);

    font-size: 11px;
}


/* =========================================================
   SECTIONS
   ========================================================= */

.section {
    margin-top: 35px;
}

.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 17px;
}

.section-header h2 {
    margin: 0;

    color: var(--text);

    font-size: 18px;
    font-weight: 700;
}

.section-header p {
    margin: 3px 0 0;

    color: var(--muted);

    font-size: 13px;
}

.view-all {
    color: var(--accent);

    font-size: 12px;
    font-weight: 600;
}

.view-all:hover {
    color: var(--accent-hover);

    text-decoration: underline;
}


/* =========================================================
   VIDEO GRID
   ========================================================= */

.video-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 16px;
}

.video-card {
    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);

    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease;
}

.video-card:hover {
    border-color: var(--border-strong);

    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.08);
}

.thumbnail {
    position: relative;

    aspect-ratio: 16 / 9;

    overflow: hidden;

    background: #111;
}

.thumbnail img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.thumbnail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    color: #8b919a;

    font-size: 12px;
}

.duration {
    position: absolute;

    right: 6px;
    bottom: 6px;

    padding: 2px 5px;

    background: rgba(0, 0, 0, 0.78);

    border-radius: 3px;

    color: #fff;

    font-size: 10px;
    font-weight: 600;
}

.video-info {
    padding: 11px 12px 13px;
}

.video-info h3 {
    display: -webkit-box;

    margin: 0;

    overflow: hidden;

    color: var(--text);

    font-size: 13px;
    font-weight: 600;

    line-height: 1.4;

    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.creator {
    margin: 6px 0 0;

    color: var(--muted);

    font-size: 11px;
}

.metadata {
    margin: 3px 0 0;

    color: var(--subtle);

    font-size: 10px;
}

.tags {
    display: flex;

    flex-wrap: wrap;

    gap: 4px;

    margin-top: 8px;
}

.tags span {
    padding: 2px 6px;

    background: var(--surface-alt);

    border: 1px solid var(--border);

    border-radius: 3px;

    color: var(--muted);

    font-size: 9px;
}


/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty-state {
    grid-column: 1 / -1;

    padding: 45px 20px;

    background: var(--surface);

    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);

    color: var(--muted);

    text-align: center;

    font-size: 13px;
}


/* =========================================================
   PAGE HEADER
   ========================================================= */

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    margin: 0 0 6px;

    color: var(--text);

    font-size: 30px;
    font-weight: 700;

    letter-spacing: -0.7px;
}

.page-header p {
    margin: 0;

    color: var(--muted);

    font-size: 13px;
}


/* =========================================================
   FILTERS
   ========================================================= */

.filters {
    display: flex;
    align-items: center;

    gap: 8px;

    margin-bottom: 20px;
}

.filters select,
.filter-select {
    padding: 8px 10px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 5px;

    color: var(--text);

    outline: none;
}

.filters select:focus,
.filter-select:focus {
    border-color: var(--accent);
}


/* =========================================================
   SETTINGS
   ========================================================= */

.settings-section {
    margin-bottom: 24px;
}

.form-card {
    padding: 22px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

.form-card h2 {
    margin: 0 0 5px;

    color: var(--text);

    font-size: 17px;
}

.form-card > p {
    margin: 0 0 20px;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.6;
}


/* =========================================================
   SETTINGS ROWS
   ========================================================= */

.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 25px;

    padding: 16px 0;

    border-bottom: 1px solid var(--border);
}

.admin-row:first-child {
    padding-top: 0;
}

.admin-row:last-child {
    padding-bottom: 0;

    border-bottom: 0;
}

.admin-row > div {
    min-width: 0;
}

.admin-row strong {
    display: block;

    color: var(--text);

    font-size: 13px;
    font-weight: 600;
}

.admin-row small {
    display: block;

    margin-top: 4px;

    color: var(--muted);

    font-size: 11px;
    line-height: 1.5;
}

.admin-directory-input {
    width: 45%;

    flex-shrink: 0;
}


/* =========================================================
   FORM INPUTS
   ========================================================= */

.settings-section input,
.settings-section select,
.settings-section textarea {
    display: block;

    width: 100%;

    padding: 9px 10px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 5px;

    color: var(--text);

    outline: none;
}

.settings-section input:focus,
.settings-section select:focus,
.settings-section textarea:focus {
    border-color: var(--accent);

    box-shadow:
        0 0 0 2px
        rgba(49, 95, 158, 0.12);
}


/* =========================================================
   BUTTONS
   ========================================================= */

.actions {
    display: flex;

    flex-wrap: wrap;

    gap: 8px;

    margin-top: 18px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 8px 13px;

    background: var(--accent);

    border: 1px solid var(--accent);
    border-radius: 5px;

    color: #fff;

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;
}

.button:hover {
    background: var(--accent-hover);

    border-color: var(--accent-hover);
}

.button:disabled {
    opacity: 0.55;

    cursor: not-allowed;
}

.button.secondary {
    background: var(--surface);

    border-color: var(--border-strong);

    color: var(--text);
}

.button.secondary:hover {
    background: var(--surface-alt);
}


/* =========================================================
   THEME SELECTOR
   ========================================================= */

.theme-options {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 10px;
}

.theme-option {
    display: flex !important;
    align-items: center;

    gap: 10px;

    margin: 0 !important;

    padding: 13px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 5px;

    cursor: pointer;
}

.theme-option:hover {
    border-color: var(--border-strong);
}

.theme-option input {
    width: 16px !important;
    height: 16px;

    margin: 0 !important;

    accent-color: var(--accent);
}

.theme-option strong {
    display: block;

    color: var(--text);

    font-size: 13px;
}

.theme-option small {
    display: block;

    margin-top: 2px;

    color: var(--muted);

    font-size: 10px;
}


/* =========================================================
   ABOUT
   ========================================================= */

.about-card {
    display: flex;
    align-items: center;

    gap: 15px;
}

.about-logo {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 52px;
    height: 52px;

    flex-shrink: 0;

    background: var(--accent);

    border-radius: 6px;

    color: #fff;

    font-size: 15px;
    font-weight: 700;
}

.about-card h3 {
    margin: 0 0 3px;

    font-size: 16px;
}

.about-card p {
    margin: 0;

    color: var(--muted);

    font-size: 12px;
}


/* =========================================================
   STATUS
   ========================================================= */

.status {
    min-height: 18px;

    margin-top: 10px;

    color: var(--muted);

    font-size: 12px;
}

.status.success {
    color: var(--success);
}

.status.error {
    color: var(--danger);
}


/* =========================================================
   VIDEO PAGE
   ========================================================= */

.video-page {
    width: min(1200px, calc(100% - 48px));

    margin: 0 auto;

    padding: 35px 0 60px;
}

.video-player-wrapper {
    overflow: hidden;

    background: #000;

    border-radius: var(--radius);
}

.video-player-wrapper video,
video[data-player] {
    display: block;

    width: 100%;

    max-height: 75vh;

    background: #000;
}

.video-details {
    margin-top: 22px;
}

.video-details h1 {
    margin: 0;

    font-size: 25px;
    font-weight: 700;

    line-height: 1.3;
}

.video-meta {
    margin-top: 7px;

    color: var(--muted);

    font-size: 12px;
}

.video-description {
    margin-top: 18px;

    padding: 16px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    color: var(--muted);

    font-size: 13px;
    line-height: 1.7;

    white-space: pre-wrap;
}


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

footer {
    width: 100%;

    border-top: 1px solid var(--border);

    background: var(--surface);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: min(1180px, calc(100% - 48px));

    min-height: 52px;

    margin: 0 auto;

    color: var(--muted);

    font-size: 10px;
}


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

@media (max-width: 1000px) {

    .video-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }
}


@media (max-width: 720px) {

    .topbar-inner {
        width: calc(100% - 32px);

        min-height: 56px;

        flex-wrap: wrap;
    }

    .nav {
        height: 48px;

        margin-left: 20px;
    }

    .nav a {
        height: 48px;

        padding: 0 10px;
    }

    main {
        width: calc(100% - 32px);

        padding-top: 30px;
    }

    .hero {
        align-items: flex-start;

        flex-direction: column;
    }

    .library-stats {
        width: 100%;
    }

    .stat-card {
        flex: 1;
    }

    .video-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .admin-row {
        align-items: stretch;

        flex-direction: column;

        gap: 12px;
    }

    .admin-directory-input {
        width: 100%;
    }

    .theme-options {
        grid-template-columns: 1fr;
    }

    footer .footer-inner {
        width: calc(100% - 32px);
    }
}


@media (max-width: 480px) {

    .brand {
        font-size: 16px;
    }

    .nav {
        margin-left: 10px;
    }

    .nav a {
        padding: 0 8px;

        font-size: 11px;
    }

    .hero h1 {
        font-size: 27px;
    }

    .library-stats {
        display: grid;

        grid-template-columns:
            repeat(3, 1fr);

        gap: 6px;
    }

    .stat-card {
        min-width: 0;

        padding: 9px;
    }

    .stat-card strong {
        font-size: 15px;
    }

    .video-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        align-items: flex-start;

        flex-direction: column;
    }

    .footer-inner {
        align-items: flex-start;

        flex-direction: column;

        justify-content: center;

        gap: 2px;
    }
}