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

:root {
    --bg: #f0f2f5;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --success: #10b981;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 14px rgba(0,0,0,0.1);
    --input-bg: #fff;
}

/* ===== Dark Mode ===== */
body.dark-mode {
    --bg: #0f172a;
    --sidebar-bg: #1a1f2e;
    --sidebar-text: #8892a4;
    --card-bg: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 4px 14px rgba(0,0,0,0.4);
    --input-bg: #0f172a;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ===== Layout ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span {
    font-size: 12px;
    color: var(--sidebar-text);
    display: block;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    list-style: none;
    overflow-y: auto;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-nav svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Sidebar Section Headers */
.sidebar-section {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(148,163,184,0.6);
    padding: 16px 14px 6px;
    margin-top: 4px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
}

.sidebar-footer a {
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-footer a:hover { color: #fff; }

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-user-info strong {
    color: #e2e8f0;
    font-size: 14px;
}

/* Theme Toggle */
.theme-toggle {
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.theme-toggle .moon-icon { display: none; }
.theme-toggle .sun-icon { display: block; }

body.dark-mode .theme-toggle .moon-icon { display: block; }
body.dark-mode .theme-toggle .sun-icon { display: none; }

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

/* ===== Filter Card ===== */
.filter-card {
    padding: 16px 20px;
}

.filter-form {
    width: 100%;
}

.filter-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-row .form-control {
    min-width: 0;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 24px; height: 24px; }

.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }

body.dark-mode .stat-icon.blue   { background: rgba(59,130,246,0.15); }
body.dark-mode .stat-icon.green  { background: rgba(16,185,129,0.15); }
body.dark-mode .stat-icon.red    { background: rgba(239,68,68,0.15); }
body.dark-mode .stat-icon.orange { background: rgba(245,158,11,0.15); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Table ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover { background: rgba(0,0,0,0.02); }
body.dark-mode tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e2e8f0; color: #475569; }

body.dark-mode .badge-success { background: rgba(16,185,129,0.2); color: #6ee7b7; }
body.dark-mode .badge-warning { background: rgba(245,158,11,0.2); color: #fcd34d; }
body.dark-mode .badge-danger  { background: rgba(239,68,68,0.2); color: #fca5a5; }
body.dark-mode .badge-info    { background: rgba(59,130,246,0.2); color: #93c5fd; }
body.dark-mode .badge-secondary { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

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

.btn-secondary {
    background: #e2e8f0;
    color: var(--text);
}
.btn-secondary:hover { background: #cbd5e1; }

body.dark-mode .btn-secondary {
    background: #334155;
    color: #e2e8f0;
}
body.dark-mode .btn-secondary:hover { background: #475569; }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* ===== Bulk Action Bar ===== */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #1e40af;
}

body.dark-mode .bulk-bar {
    background: rgba(59,130,246,0.1);
    border-color: rgba(59,130,246,0.3);
    color: #93c5fd;
}

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Alert ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info    { background: #dbeafe; color: #1e40af; }

body.dark-mode .alert-success { background: rgba(16,185,129,0.15); color: #6ee7b7; }
body.dark-mode .alert-danger  { background: rgba(239,68,68,0.15); color: #fca5a5; }
body.dark-mode .alert-warning { background: rgba(245,158,11,0.15); color: #fcd34d; }
body.dark-mode .alert-info    { background: rgba(59,130,246,0.15); color: #93c5fd; }

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-box {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}

.login-box p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 14px;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
}

/* ===== License Type Tags ===== */
.license-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: #f1f5f9;
    color: var(--text);
}

body.dark-mode .license-type {
    background: rgba(255,255,255,0.08);
}

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

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p { margin-bottom: 20px; }

/* ===== Chart Bars (Reports) ===== */
.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-bar-label {
    width: 110px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-align: right;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-track {
    flex: 1;
    height: 24px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 6px;
    min-width: 2px;
    transition: width 0.5s ease;
}

.chart-bar-fill.chart-bar-orange {
    background: var(--warning);
}

.chart-bar-value {
    width: 36px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-align: left;
    flex-shrink: 0;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
}

.pagination a:hover {
    background: var(--border);
}

.pagination .active {
    background: var(--primary);
    color: #fff;
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== Actions Cell ===== */
.actions-cell { white-space: nowrap; }

/* ===== Confirm Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal-box h3 { margin-bottom: 12px; font-size: 18px; color: var(--text); }
.modal-box p { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.modal-box .btn-group { justify-content: center; }

/* ===== Activity Log ===== */
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.activity-item:last-child { border-bottom: none; }

/* ===== Checkbox styling ===== */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 20px 16px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .filter-row {
        flex-direction: column;
    }
    .filter-row .form-control,
    .filter-row .btn {
        width: 100%;
    }
    .mobile-toggle {
        display: block !important;
    }
    .bulk-bar {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
}
