/* =============================================
   Smart Study Aborad CRM - Custom Styles
   Light theme, compact spacing, professional
   ============================================= */

:root {
    --primary: #9f0808;
    --primary-light: #c62828;
    --primary-dark: #7f0000;
    --primary-50: #fef2f2;
    --primary-100: #fee2e2;
    --primary-200: #fecaca;
    --secondary: rgb(27, 18, 18);
    --secondary-light: #2d2020;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Sidebar ---- */
.sidebar {
    width: 240px;
    background: var(--secondary);
    color: #fff;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}


.sidebar-logo {
    padding: 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo h1 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-logo p {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-user {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }
.sidebar-user-info .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-role-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.role-super_admin { background: rgba(239,68,68,0.15); color: #fca5a5; }
.role-manager { background: rgba(245,158,11,0.15); color: #fcd34d; }
.role-branch_manager { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.role-processor { background: rgba(59,130,246,0.15); color: #93c5fd; }

.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.sidebar-nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
    font-weight: 600;
    padding: 8px 12px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: var(--transition);
    margin-bottom: 1px;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.sidebar-link.active {
    color: #fff;
    background: var(--primary);
    font-weight: 500;
}

.sidebar-link i, .sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-link .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    margin-left: auto;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---- Main Content ---- */
.main-content {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ---- Header ---- */
.top-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}

.top-header-left { display: flex; align-items: center; gap: 12px; }
.top-header-left h2 { font-size: 16px; font-weight: 600; color: var(--text-color); }
.top-header-left .date { font-size: 11px; color: var(--text-muted); }

.top-header-right { display: flex; align-items: center; gap: 8px; }

.header-btn {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    text-decoration: none;
}
.header-btn:hover { background: var(--bg-secondary); color: var(--text-color); }

.notification-badge {
    position: relative;
}
.notification-badge .count {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle {
    display: none;
    padding: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    align-items: center;
    justify-content: center;
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: inline-flex;
    }
}

/* ---- Page Content ---- */
.page-content { flex: 1; padding: 16px 20px; }

/* ---- Cards ---- */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.card-body { padding: 16px; }
.card-body-compact { padding: 12px 16px; }

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.red { background: var(--primary-50); color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.teal { background: #f0fdfa; color: #0d9488; }

.stat-info h4 { font-size: 20px; font-weight: 700; color: var(--text-color); line-height: 1; }
.stat-info p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: var(--bg-secondary);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-color);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr:hover { background: var(--bg-secondary); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Filters ---- */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.filter-input, .filter-select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-color);
    transition: var(--transition);
    outline: none;
}

.filter-input:focus, .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.filter-input { min-width: 160px; }
.filter-select { min-width: 130px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn i, .btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-color);
    border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--bg-secondary); }

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}
.btn-danger:hover { background: #fecaca; }

.btn-success {
    background: #dcfce7;
    color: #16a34a;
    border-color: #bbf7d0;
}
.btn-success:hover { background: #bbf7d0; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; border-radius: 4px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 12px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.form-label .required { color: var(--primary); }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-color);
    background: var(--bg-primary);
    transition: var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-input::placeholder { color: var(--text-light); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-input:disabled, .form-select:disabled { background: var(--bg-tertiary); cursor: not-allowed; opacity: 0.7; }

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-paid, .badge-approved { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-muted); }

/* ---- Action Buttons in Tables ---- */
.action-btns { display: flex; gap: 4px; align-items: center; }

.action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    text-decoration: none;
}

.action-btn:hover { background: var(--bg-secondary); color: var(--text-color); }
.action-btn.danger:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.action-btn i, .action-btn svg { width: 14px; height: 14px; }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.pagination-links { display: flex; gap: 4px; }

.pagination-links a, .pagination-links span {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 12px;
    transition: var(--transition);
}

.pagination-links a:hover { background: var(--bg-secondary); color: var(--text-color); }
.pagination-links .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Flash Messages ---- */
.flash-msg {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    animation: slideDown 0.3s ease;
}

.flash-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.flash-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.flash-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

.flash-msg .close-btn {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0;
}
.flash-msg .close-btn:hover { opacity: 1; }

/* ---- Footer ---- */
.main-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i, .empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: 0.3; }
.empty-state h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.empty-state p { font-size: 12px; }

/* ---- Charts ---- */
.chart-container { position: relative; height: 220px; }

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 14px; font-weight: 600; }
.modal-body { padding: 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 8px; }

/* ---- Animations ---- */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fadeIn { animation: fadeIn 0.3s ease; }

/* ---- Login Page ---- */
.login-container {
    min-height: 100vh;
    display: flex;
}

.login-left {
    flex: 1;
    background: var(--secondary);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 50px;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(159,8,8,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.login-right {
    width: 440px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 50px;
    background: var(--bg-primary);
}

/* ---- Password Display ---- */
.password-cell {
    font-family: 'Courier New', monospace;
    background: var(--bg-tertiary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* ---- Video Cards ---- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.video-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.video-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.video-thumbnail {
    position: relative;
    padding-top: 56.25%;
    background: #000;
    overflow: hidden;
}

.video-thumbnail iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-info { padding: 12px; }
.video-info h4 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.video-info p { font-size: 12px; color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-container { flex-direction: column; }
    .login-left { display: none; }
    .login-right { width: 100%; padding: 30px 20px; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filter-input, .filter-select { min-width: 100%; }
    .page-content { padding: 12px; }
    .top-header { padding: 8px 12px; }
    .video-grid { grid-template-columns: 1fr; }
}

/* ---- Overlay for mobile ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 35;
}

.sidebar-overlay.show { display: block; }

/* ---- Upload area ---- */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-50); }
.upload-area.has-file { border-color: #16a34a; background: #f0fdf4; }

/* Detail pairs */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.detail-item label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.detail-item span {
    font-size: 14px;
    color: var(--text-color);
    font-weight: 500;
}

