/* ============================================================
   FrozenTrack Admin — Professional Dashboard CSS
   Theme: Blue Clear White + Dark Mode
   ============================================================ */

/* ── CSS Variables ── */
:root, [data-theme="light"] {
    --bg-primary: #F1F5F9;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F8FAFC;
    --sidebar-bg: #0F172A;
    --sidebar-hover: #1E293B;
    --sidebar-active: rgba(59, 130, 246, 0.15);
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-sidebar: #CBD5E1;
    --text-sidebar-active: #FFFFFF;
    --accent: #3B82F6;
    --accent-light: #DBEAFE;
    --accent-dark: #1D4ED8;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --error: #EF4444;
    --error-light: #FEE2E2;
    --info: #06B6D4;
    --info-light: #CFFAFE;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #162032;
    --sidebar-bg: #0B1120;
    --sidebar-hover: #162032;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent-light: rgba(59, 130, 246, 0.15);
    --success-light: rgba(16, 185, 129, 0.15);
    --warning-light: rgba(245, 158, 11, 0.15);
    --error-light: rgba(239, 68, 68, 0.15);
    --info-light: rgba(6, 182, 212, 0.15);
    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font-family: inherit; }

/* ── App Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand-icon {
    width: 40px; height: 40px;
    background: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}
.brand-logo-img {
    width: 36px; height: 36px;
    object-fit: contain;
    border-radius: 50%;
}
.brand-name { font-weight: 700; font-size: 1.15rem; color: #fff; display: block; }
.brand-sub { font-size: 0.75rem; color: var(--text-muted); display: block; }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}
.nav-section { margin-bottom: 8px; }
.nav-section-title {
    display: block;
    padding: 10px 20px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    font-size: 0.92rem; font-weight: 500;
    border-radius: 0;
    transition: all 0.2s;
    position: relative;
}
.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.nav-link.active {
    background: var(--sidebar-active);
    color: var(--accent);
    font-weight: 600;
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-link i { font-size: 18px; width: 20px; text-align: center; }

.sidebar-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.admin-info { display: flex; align-items: center; gap: 10px; }
.admin-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), #8B5CF6);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px;
}
.admin-name { font-weight: 600; font-size: 0.85rem; color: #fff; display: block; }
.admin-role { font-size: 0.7rem; color: var(--text-muted); display: block; }
.btn-logout {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 18px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.btn-logout:hover { color: var(--error); background: rgba(239,68,68,0.1); }

/* ── Main Wrapper ── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top Bar ── */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); font-size: 22px; padding: 6px;
}
.top-bar-title h1 {
    font-size: 1.25rem; font-weight: 700; color: var(--text-primary);
}
.top-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px; cursor: pointer;
    color: var(--text-secondary); font-size: 18px;
    transition: all 0.2s;
}
.theme-toggle:hover { background: var(--accent-light); color: var(--accent); }

/* ── Main Content ── */
.main-content {
    flex: 1;
    padding: 24px;
}

/* ── Cards ── */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 {
    font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.card-header h2 i { color: var(--accent); font-size: 18px; }
.card-body { padding: 20px; }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: flex-start; gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--error-light); color: var(--error); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8B5CF6; }
.stat-value { font-size: 1.75rem; font-weight: 800; display: block; line-height: 1.2; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%; border-collapse: collapse;
}
thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--bg-tertiary); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--error-light); color: var(--error); }
.badge-cyan { background: var(--info-light); color: var(--info); }
.badge-gray { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-purple { background: rgba(139,92,246,0.1); color: #8B5CF6; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem; font-weight: 600;
    border: none; cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost {
    background: var(--bg-tertiary); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
    width: 34px; height: 34px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer; transition: all 0.2s;
    font-size: 16px;
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.btn-icon.danger:hover { background: var(--error-light); color: var(--error); border-color: var(--error); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; margin-bottom: 6px;
    font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
}
.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.92rem;
    transition: all 0.2s;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Toolbar (search, filter, actions) ── */
.toolbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-box {
    flex: 1; min-width: 200px;
    position: relative;
}
.search-box i {
    position: absolute;
    left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 16px;
}
.search-box input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}
.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* ── Alerts ── */
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem; font-weight: 500;
    animation: slideDown 0.3s ease;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-error { background: var(--error-light); color: var(--error); }
.alert-close {
    margin-left: auto; background: none; border: none;
    cursor: pointer; color: inherit; opacity: 0.7;
    font-size: 16px;
}
.alert-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Pagination ── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 6px;
    margin-top: 24px;
    list-style: none;
    flex-wrap: wrap;
    padding: 0;
}
.pagination li, .pagination .page-item {
    display: inline-block;
}
.pagination li a, .pagination li span,
.pagination .page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem; font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
}
.pagination li a:hover, .pagination .page-item a.page-link:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}
.pagination li.active span, .pagination .page-item.active .page-link {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}
.pagination li.disabled span, .pagination .page-item.disabled .page-link {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}
/* Fix: arrow icon di pagination jangan oversized */
.pagination li a svg, .pagination li span svg,
.pagination .page-link svg {
    width: 14px !important; height: 14px !important;
}

/* ── Activity Feed ── */
.activity-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.activity-icon.driver { background: var(--warning-light); color: var(--warning); }
.activity-icon.sales { background: var(--accent-light); color: var(--accent); }
.activity-time { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.activity-user { font-weight: 600; font-size: 0.88rem; }
.activity-detail { font-size: 0.85rem; color: var(--text-secondary); flex: 1; }
.activity-extra { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }

/* ── Content Grid ── */
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.content-grid-full { grid-column: 1 / -1; }

/* ── Empty State ── */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E3A5F 50%, #0F172A 100%);
    padding: 20px;
}
.login-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.login-brand-area {
    text-align: center; margin-bottom: 32px;
}
.login-brand-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--accent), #06B6D4);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    color: white; font-size: 28px;
    margin-bottom: 16px;
}
.login-brand-area h1 { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); }
.login-brand-area p { color: var(--text-muted); font-size: 0.92rem; margin-top: 4px; }
.login-error {
    background: var(--error-light); color: var(--error);
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}

/* ── Chart Container ── */
.chart-container { position: relative; height: 260px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .content-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
}
