/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-elevated: #1a1a1a;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-muted: #888888;
    --primary: #fbbf24;
    --primary-dark: #f59e0b;
    --danger: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --header-height: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    height: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
}

/* ===== App Container ===== */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg);
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 2px solid var(--primary);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    flex-shrink: 0;
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    stroke: #000;
    stroke-width: 2.5;
    fill: none;
}

/* ===== Main ===== */
.main {
    flex: 1;
    padding: 16px 16px calc(20px + var(--safe-bottom));
    overflow-y: auto;
}

.section-header {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.section-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.section-header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2px;
}

/* ===== List View ===== */
.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.list-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.06);
}

.list-thumb {
    width: 100px;
    height: 64px;
    background: #111;
    border-radius: 4px;
    flex-shrink: 0;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s;
}

.list-thumb:hover {
    transform: scale(1.03);
}

.list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.list-thumb .thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
    color: var(--text-muted);
    font-size: 18px;
}

.list-thumb .thumb-placeholder svg {
    width: 24px;
    height: 24px;
    opacity: 0.3;
    stroke: var(--text-muted);
}

.list-info {
    flex: 1;
    min-width: 0;
}

.list-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    word-wrap: break-word;
}

.list-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
    flex-wrap: wrap;
}

.list-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.list-meta svg {
    width: 13px;
    height: 13px;
    stroke: var(--text-muted);
}

.list-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon-sm {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 12px;
    gap: 4px;
}

.btn-icon-sm:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
}

.btn-icon-sm svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon svg {
    width: 64px;
    height: 64px;
    stroke: var(--text-muted);
    opacity: 0.2;
}

.empty-state p {
    margin-top: 12px;
    font-size: 1rem;
}

/* ===== Video Modal ===== */
.video-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.video-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    width: 92%;
    max-width: 800px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--primary);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    border: 1px solid var(--primary);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--primary);
    color: #000;
}

.modal-content video {
    display: block;
    width: 100%;
    max-height: 80vh;
    background: #000;
}

/* ===== Admin Styles ===== */
.admin-container {
    max-width: 800px;
    margin: 0 auto;
}

.admin-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.admin-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
}

.admin-form .form-group {
    margin-bottom: 14px;
}

.admin-form .form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.admin-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.2s;
}

.admin-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.admin-form input[type="file"] {
    width: 100%;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
}

.admin-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.admin-card:hover {
    border-color: var(--primary);
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.admin-card-header .video-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.admin-card-header .video-id {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.admin-card-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.admin-card-info span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.admin-card-info svg {
    width: 12px;
    height: 12px;
    stroke: var(--text-muted);
}

.admin-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-card-actions .btn-action {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--bg-elevated);
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    transition: all 0.2s;
    font-family: var(--font);
}

.admin-card-actions .btn-action:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.admin-card-actions .btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.admin-card-actions .btn-action svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

.user-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-right: 6px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Login ===== */
.login-page {
    background: var(--bg);
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height) - 80px);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 380px;
    width: 100%;
    border: 1px solid var(--border);
}

.login-card h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.login-card .subtitle {
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 14px;
}

.login-form .form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-footer {
    margin-top: 14px;
    text-align: center;
}

.login-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.login-footer a:hover {
    color: var(--primary);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 300;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 90%;
    text-align: center;
}

.toast-success {
    background: var(--primary);
    color: #000;
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ===== Dropzone ===== */
.dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s, background 0.3s;
    cursor: pointer;
    overflow: hidden;
}

.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(251, 191, 36, 0.05);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.dropzone-content {
    text-align: center;
    pointer-events: none;
    padding: 20px;
    color: var(--text-muted);
}

.dropzone-content .dropzone-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--text-muted);
    opacity: 0.4;
}

.dropzone-text {
    font-weight: 500;
    margin-top: 4px;
    font-size: 0.9rem;
}

.dropzone-hint {
    font-size: 0.75rem;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    width: 100%;
    pointer-events: none;
}

.file-preview[hidden] {
    display: none !important;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 0.9rem;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-clear {
    pointer-events: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-primary {
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-full {
    width: 100%;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .list-thumb {
        width: 72px;
        height: 48px;
    }
    
    .list-info h4 {
        font-size: 0.85rem;
    }
    
    .list-meta {
        font-size: 0.7rem;
        gap: 8px;
    }
    
    .btn-icon-sm {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .btn-icon-sm svg {
        width: 13px;
        height: 13px;
    }
    
    .section-header h1 {
        font-size: 1.2rem;
    }
    
    .admin-card-info {
        flex-direction: column;
        gap: 3px;
    }
}