:root {
    --bg-base: #0b0c10;
    --bg-surface: #13151f;
    --bg-elevated: #1a1d2b;
    --bg-input: #12141c;
    --border-subtle: #232738;
    --border-focus: #3b82f6;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.35);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --font-sans: 'Cairo', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100vh;
}

/* HEADER */
.app-header {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-box {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: 12px;
    color: var(--text-dim);
}

.header-account {
    background-color: #12141d;
    border: 1px solid var(--border-subtle);
    border-radius: 30px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-muted);
}

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

/* MAIN CONTENT */
.app-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

/* CONTROL CARD */
.control-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.title-with-icon i {
    color: #38bdf8;
    font-size: 18px;
}

.title-with-icon h2 {
    font-size: 16px;
    font-weight: 700;
}

.badge-tip {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    background-color: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    font-weight: 600;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.select-wrapper {
    display: flex;
    gap: 6px;
}

select, input[type="text"] {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 13.5px;
    outline: none;
    transition: all 0.2s;
}

select:focus, input[type="text"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.btn-icon {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-muted);
    padding: 0 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: #fff;
    border-color: #3b82f6;
}

.action-buttons-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 11px 22px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

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

.btn-danger {
    background-color: var(--danger);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 11px 20px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Auto Sync Switch */
.auto-sync-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #12141e;
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #2a2f42;
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #10b981;
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.auto-sync-text {
    display: flex;
    flex-direction: column;
    font-size: 12px;
}

.auto-sync-text b {
    color: #fff;
}

.auto-sync-text span {
    color: var(--text-dim);
    font-size: 10.5px;
}

/* PROGRESS BOX */
.progress-box {
    margin-top: 18px;
    background-color: #0f1118;
    border: 1px solid #23283b;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
}

.progress-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #38bdf8;
}

.progress-percent {
    font-family: var(--font-mono);
    color: #38bdf8;
    font-weight: 700;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: #1e2335;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #2563eb);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
}

/* STATS BAR */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-pill {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.stat-label {
    color: var(--text-dim);
}

.stat-value {
    color: #38bdf8;
    font-family: var(--font-mono);
}

.search-pill {
    flex: 1;
    min-width: 220px;
    padding: 4px 10px;
}

.search-pill input {
    border: none;
    background: transparent;
    padding: 6px;
    font-size: 13px;
}

.search-pill input:focus {
    box-shadow: none;
}

/* VAULT GALLERY */
.vault-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-top h2 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-refresh {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    border-radius: 7px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-refresh:hover {
    color: #fff;
    background-color: var(--bg-elevated);
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

/* VIDEO CARD */
.video-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, border-color 0.2s;
}

.video-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.video-player-box {
    width: 100%;
    height: 200px;
    background-color: #000;
    position: relative;
}

.video-player-box video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-info-box {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.video-chat-tag {
    font-size: 11.5px;
    font-weight: 700;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.video-topic-tag {
    font-size: 11px;
    font-weight: 600;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    padding: 2px 7px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
}

.topic-loading {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #f59e0b;
    font-size: 14px;
}

.video-caption {
    font-size: 12.5px;
    color: var(--text-main);
    line-height: 1.5;
    max-height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.video-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-top: auto;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.video-actions-row {
    padding: 10px 14px;
    background-color: #0e1017;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.btn-download-video {
    flex: 1;
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #fff;
    border-radius: 7px;
    padding: 7px 12px;
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-download-video:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-delete-video {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    border-radius: 7px;
    padding: 7px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-video:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* EMPTY STATE */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-subtle);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.empty-state i {
    font-size: 40px;
    color: var(--text-dim);
}

.empty-state p {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.empty-state span {
    font-size: 13px;
    color: var(--text-dim);
}

/* FOOTER */
.app-footer {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-dim);
    padding: 10px 0;
    font-family: var(--font-mono);
}

/* RESPONSIVE */
@media (max-width: 600px) {
    .app-container {
        padding: 10px;
    }
    .videos-grid {
        grid-template-columns: 1fr;
    }
}
