:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-container { width: 100%; max-width: 420px; }
.login-box {
    background: var(--card);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .logo { margin-bottom: 16px; display: inline-flex; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.login-header p { color: var(--text-light); font-size: 0.875rem; }

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.875rem;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper svg {
    position: absolute;
    left: 12px;
    color: var(--text-light);
    pointer-events: none;
}
.input-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    transition: all 0.2s;
    background: var(--card);
}
.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-light);
}
.security-note { margin-top: 8px; opacity: 0.7; }

/* App Layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width);
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.125rem; }
.sidebar-close { display: none; background: none; border: none; cursor: pointer; color: var(--text-light); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.2s;
}
.nav-item:hover, .nav-item.active {
    background: #eef2ff;
    color: var(--primary);
}
.nav-divider { height: 1px; background: var(--border); margin: 16px 12px; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; }
.user-name { font-size: 0.875rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--text-light); }
.logout-btn { color: var(--text-light); text-decoration: none; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    max-width: calc(100% - var(--sidebar-width));
    min-width: 0;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
}
.page-title { font-size: 1.5rem; font-weight: 700; flex: 1; }
.top-actions { display: flex; gap: 12px; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-green { background: #f0fdf4; color: #16a34a; }
.icon-purple { background: #faf5ff; color: #9333ea; }
.icon-orange { background: #fff7ed; color: #ea580c; }
.icon-red { background: #fef2f2; color: #dc2626; }
.icon-teal { background: #f0fdfa; color: #0d9488; }
.stat-value { font-size: 1.5rem; font-weight: 700; display: block; }
.stat-label { font-size: 0.875rem; color: var(--text-light); }

/* Content Sections */
.content-section { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-header h3 { font-size: 1.125rem; font-weight: 600; }
.view-all { color: var(--primary); text-decoration: none; font-size: 0.875rem; font-weight: 500; }

/* File Grid */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.file-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}
.file-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.file-preview {
    aspect-ratio: 16/10;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}
.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
}
.file-preview img.loaded { opacity: 1; }
.video-placeholder, .doc-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-light);
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}
.doc-placeholder .doc-ext {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}
.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}
.file-info { padding: 14px; }
.file-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}
.file-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 10px;
}
.file-uploader {
    font-size: 0.75rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}
.file-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.action-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Upload Page */
.upload-container { max-width: 900px; }
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    background: var(--card);
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 24px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: #eef2ff;
}
.upload-zone-content svg { margin-bottom: 16px; }
.upload-zone-content h3 { font-size: 1.125rem; margin-bottom: 8px; }
.upload-zone-content p { color: var(--text-light); margin-bottom: 16px; }
.text-link { color: var(--primary); cursor: pointer; font-weight: 500; }
.upload-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 0.8125rem;
    color: var(--text-light);
    flex-wrap: wrap;
}
.upload-options { margin-bottom: 24px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.file-queue {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 24px;
}
.queue-header { display: flex; justify-content: space-between; margin-bottom: 16px; }
.queue-header h4 { font-size: 1rem; }
.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    margin-bottom: 8px;
}
.queue-item-info { flex: 1; min-width: 0; }
.queue-item-name { font-size: 0.875rem; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-meta { font-size: 0.75rem; color: var(--text-light); }
.queue-progress { width: 100px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.queue-progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; width: 0%; }
.queue-item-status { font-size: 0.75rem; color: var(--text-light); min-width: 60px; text-align: right; }
.queue-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; }

.upload-results {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}
.results-header { margin-bottom: 16px; }
.results-header h4 { font-size: 1rem; }
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.875rem;
}
.result-item.success { background: #f0fdf4; color: #166534; }
.result-item.error { background: #fef2f2; color: #991b1b; }

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.tab-count { opacity: 0.7; margin-left: 4px; }

/* Search */
.search-bar { margin-bottom: 24px; }
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 480px;
}
.search-input-wrapper svg {
    position: absolute;
    left: 14px;
    color: var(--text-light);
}
.search-input-wrapper input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
}
.search-clear {
    position: absolute;
    right: 14px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.8125rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
}
.page-info { font-size: 0.875rem; color: var(--text-light); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-light);
}
.empty-state svg { margin-bottom: 16px; }
.empty-state p { font-size: 1rem; margin-bottom: 8px; color: var(--text); }
.empty-sub { font-size: 0.875rem; color: var(--text-light); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1;
}
.modal-sm { max-width: 480px; }
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
}
.modal-body img, .modal-body video { max-width: 100%; border-radius: var(--radius-sm); display: block; }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text-light); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }
.badge-admin { background: #eff6ff; color: #1d4ed8; }
.badge-staff { background: #f0fdf4; color: #15803d; }
.badge-active { background: #f0fdf4; color: #15803d; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .main-content { margin-left: 0; max-width: 100%; padding: 16px; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr; }
    .file-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .top-bar { flex-direction: column; align-items: flex-start; }
    .page-title { font-size: 1.25rem; }
    .upload-zone { padding: 32px 16px; }
    .upload-info { flex-direction: column; gap: 4px; }
    .filter-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .data-table { font-size: 0.8125rem; }
    .data-table th, .data-table td { padding: 8px 12px; }
    .modal-content { width: 95%; padding: 16px; }
}

@media (max-width: 480px) {
    .file-grid { grid-template-columns: 1fr; }
    .login-box { padding: 24px; }
    .queue-item { flex-direction: column; align-items: flex-start; gap: 8px; }
    .queue-progress { width: 100%; }
    .stats-grid { gap: 12px; }
    .stat-card { padding: 16px; }
}
