/* MyVdo — Admin portal (brand theme) */

:root {
    --bg: var(--brand-bg);
    --bg-card: var(--brand-surface);
    --bg-input: #F0F4F3;
    --border: var(--brand-border);
    --text: var(--brand-text);
    --text-muted: var(--brand-text-muted);
    --primary: var(--brand-teal);
    --primary-hover: var(--brand-teal-hover);
    --danger: var(--brand-danger);
    --success: var(--brand-teal);
    --warning: var(--brand-warning);
    --radius: var(--brand-radius-sm);
    --shadow: var(--brand-shadow);
    --nav-height: var(--brand-nav-h);
    --font: var(--brand-font);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; display: block; }

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(160deg, #E8FBF5 0%, var(--brand-bg) 45%, #FFFFFF 100%);
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: var(--brand-radius);
    padding: 32px;
    box-shadow: var(--brand-shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 28px; display: flex; justify-content: center; }
.auth-logo h1 { font-size: 1.75rem; font-weight: 700; color: var(--brand-charcoal); }

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.auth-tab.active, .auth-tab:hover { background: var(--brand-surface); color: var(--brand-charcoal); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

/* Forms */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: var(--brand-white);
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    color: var(--brand-text);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px var(--brand-teal-light);
}

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control { cursor: pointer; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background: var(--brand-teal); color: #fff; }
.btn-primary:hover { background: var(--brand-teal-hover); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--brand-border-strong);
    color: var(--brand-charcoal);
}
.btn-outline:hover { border-color: var(--brand-teal); color: var(--brand-teal); background: var(--brand-teal-light); }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error { background: rgba(220,38,38,0.08); border: 1px solid var(--brand-danger); color: #B91C1C; }
.alert-success { background: var(--brand-teal-light); border: 1px solid var(--brand-teal); color: var(--brand-teal-dark); }
.alert-warning { background: rgba(217,119,6,0.1); border: 1px solid var(--brand-warning); color: #B45309; }

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Portal Layout */
.portal-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-height);
    padding: 0 24px;
    background: var(--brand-surface);
    border-bottom: 1px solid var(--brand-border);
    box-shadow: 0 1px 8px rgba(31,33,36,0.04);
}

.nav-brand a { display: flex; align-items: center; }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    transition: 0.3s;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active { color: var(--brand-teal); background: var(--brand-teal-light); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.nav-username { font-size: 0.85rem; color: var(--text-muted); }
a.nav-username { color: var(--text-muted); text-decoration: none; }
a.nav-username:hover { color: var(--primary); }

/* Profile */
.profile-summary {
    display: flex;
    align-items: center;
    gap: 24px;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.profile-summary-info h2 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.profile-summary-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.profile-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .profile-summary { flex-direction: column; text-align: center; }
}

/* Branding / logo upload */
.logo-preview-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 28px;
}

.logo-preview-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.logo-preview-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.logo-preview-display {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    background: var(--brand-surface);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
    width: 100%;
    max-width: 360px;
}

.logo-preview-url {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.logo-preview-url code {
    font-size: 0.75rem;
    background: var(--brand-surface);
    padding: 2px 6px;
    border-radius: 4px;
}

.logo-upload-form { margin-bottom: 16px; }

.logo-remove-form {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.btn-outline.btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}

.btn-outline.btn-danger:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: var(--danger);
    color: var(--danger);
}

/* Video upload progress */
.upload-progress {
    margin: 20px 0 16px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.upload-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.upload-progress-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--brand-charcoal);
}

.upload-progress-pct {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--brand-teal-dark);
    font-variant-numeric: tabular-nums;
}

.upload-progress-track {
    height: 10px;
    background: var(--brand-border);
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--brand-teal), var(--brand-teal-hover));
    border-radius: 999px;
    transition: width 0.15s ease;
}

.upload-progress-bar.upload-progress-indeterminate {
    width: 40% !important;
    animation: upload-indeterminate 1.2s ease-in-out infinite;
}

@keyframes upload-indeterminate {
    0% { margin-left: 0; }
    50% { margin-left: 60%; }
    100% { margin-left: 0; }
}

.upload-progress-hint {
    margin: 10px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Program share link */
.share-link-box {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--brand-teal-light);
    border: 1px solid rgba(0, 200, 151, 0.25);
    border-radius: var(--radius);
}

.share-link-box label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--brand-charcoal);
}

.share-link-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.share-link-row-compact {
    margin-top: 12px;
}

.share-link-input {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    background: var(--brand-white);
}

.share-link-row .copy-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.analytics-summary-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.analytics-summary-inline strong {
    color: var(--brand-charcoal);
}

.portal-main { padding: 24px 0 48px; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--brand-teal); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.content-card,
a.content-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
    color: inherit;
    text-decoration: none;
}

.content-card:hover {
    transform: translateY(-2px);
    border-color: var(--brand-teal);
    box-shadow: var(--brand-shadow);
}

.content-card-thumb {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--bg-input);
    overflow: hidden;
}

.content-card-thumb img { width: 100%; height: 100%; object-fit: cover; }

.content-card-thumb .placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 2.5rem;
}

.content-card-body { padding: 16px; }
.content-card-body h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.content-card-body p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

.content-card-meta {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary { background: var(--brand-teal-light); color: var(--brand-teal-dark); }
.badge-success { background: var(--brand-teal-light); color: var(--brand-teal-dark); }
.badge-warning { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-muted { background: rgba(136,136,160,0.2); color: var(--text-muted); }

/* Access code gate */
.access-gate {
    max-width: 420px;
    margin: 40px auto;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 24px;
}

.access-gate-icon { font-size: 2.5rem; margin-bottom: 12px; }
.access-gate h2 { font-size: 1.25rem; margin-bottom: 8px; }
.access-gate p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }

.access-gate-thumb {
    max-width: 200px;
    margin: 0 auto 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.access-gate-form { text-align: left; }

.access-code-input {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    text-align: center;
}

.code-display {
    font-family: monospace;
    font-size: 1rem;
    letter-spacing: 1px;
    color: var(--brand-teal-dark);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-teal);
}

/* Locked content */
.content-card-locked .content-card-thumb img {
    opacity: 0.6;
}

.lock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 1rem;
}

.content-card-thumb { position: relative; }

/* Video Player */
.video-player-container {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.video-player-container video { width: 100%; max-height: 70vh; }

.video-info { margin-bottom: 32px; }
.video-info h1 { font-size: 1.5rem; margin-bottom: 8px; }
.video-info p { color: var(--text-muted); }

/* Episode List */
.episode-list { margin-top: 24px; }
.episode-list h2 { font-size: 1.1rem; margin-bottom: 16px; }

.episode-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.episode-item:hover, .episode-item.active { border-color: var(--brand-teal); }
.episode-item a { color: inherit; display: flex; align-items: center; gap: 16px; flex: 1; }

.episode-num {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.episode-title { font-weight: 500; }
.episode-duration { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }

/* Tables */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th { background: var(--bg-input); color: var(--brand-text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }

/* Panel / Card */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.panel-highlight {
    border-color: var(--brand-teal);
    background: var(--bg-input);
}

.panel h2 { font-size: 1.1rem; margin-bottom: 20px; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }

/* Search */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-bar .form-control { flex: 1; }

/* Section */
.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    margin-top: 32px;
}

.section-title:first-child { margin-top: 0; }

/* Responsive */
@media (max-width: 768px) {
    .nav-toggle { display: flex; }

    .nav-menu {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        padding: 12px;
    }

    .nav-menu.open { display: flex; }

    .nav-user {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid var(--border);
        width: 100%;
        justify-content: space-between;
    }

    .form-row { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }

    .auth-card { padding: 24px 20px; }

    .content-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

    .content-card-body { padding: 12px; }
    .content-card-body h3 { font-size: 0.9rem; }

    th, td { padding: 10px 12px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }
}
