@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---- DESIGN SYSTEM VARIABLES ---- */
:root {
    --sidebar-bg:      #1e1b4b;
    --sidebar-text:    #c7d2fe;
    --sidebar-active:  #4f46e5;
    --primary:         #4f46e5;
    --primary-dark:    #3730a3;
    --accent:          #3b82f6;
    --content-bg:      #f1f5f9;
    --card-bg:         #ffffff;
    --text-primary:    #0f172a;
    --text-secondary:  #64748b;
    --border:          #e2e8f0;
    --success:         #10b981;
    --warning:         #f59e0b;
    --danger:          #ef4444;
    --sidebar-width:   260px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--content-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* ======== SIDEBAR ======== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 22px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar-brand-sub {
    color: var(--sidebar-text);
    font-size: 0.68rem;
    opacity: 0.6;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
}

.sidebar-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--sidebar-text);
    opacity: 0.45;
    padding: 10px 10px 4px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    opacity: 0.75;
    flex-shrink: 0;
}

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

.sidebar-nav .nav-link:hover i { opacity: 1; }

.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79,70,229,0.4);
}

.sidebar-nav .nav-link.active i { opacity: 1; }

.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

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

.sidebar-user-name {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: var(--sidebar-text);
    font-size: 0.68rem;
    opacity: 0.55;
}

/* ======== MAIN WRAPPER ======== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ======== TOPBAR ======== */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px 5px 5px;
    background: var(--content-bg);
    border-radius: 50px;
    border: 1px solid var(--border);
}

.user-chip-avatar {
    width: 30px;
    height: 30px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
}

.user-chip-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: background 0.2s;
}

.hamburger-btn:hover { background: var(--content-bg); }

/* ======== CONTENT ======== */
.content {
    flex: 1;
    padding: 28px;
}

/* ======== OVERLAY mobile ======== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ======== CARDS ======== */
.card {
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.09), 0 2px 4px rgba(0,0,0,0.05);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: 12px 12px 0 0 !important;
    padding: 15px 20px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.card-body { padding: 20px; }

/* ======== KPI CARDS (Dashboard) ======== */
.kpi-card {
    border-left: 4px solid;
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.kpi-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.kpi-card.primary { border-color: var(--primary); }
.kpi-card.warning { border-color: var(--warning); }
.kpi-card.success { border-color: var(--success); }
.kpi-card.accent  { border-color: var(--accent);  }

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 5px;
}

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.kpi-icon.primary { background: rgba(79,70,229,0.1);  color: var(--primary); }
.kpi-icon.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.kpi-icon.success { background: rgba(16,185,129,0.1); color: var(--success); }
.kpi-icon.accent  { background: rgba(59,130,246,0.1); color: var(--accent);  }

/* ======== QUICK ACTION BUTTONS ======== */
.action-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.action-btn:hover {
    border-color: var(--primary);
    background: rgba(79,70,229,0.04);
    color: var(--primary);
    transform: translateX(4px);
}

.action-btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.action-btn-icon.primary { background: rgba(79,70,229,0.1);  color: var(--primary); }
.action-btn-icon.success { background: rgba(16,185,129,0.1); color: var(--success); }
.action-btn-icon.accent  { background: rgba(59,130,246,0.1); color: var(--accent);  }

.action-btn-label { font-weight: 600; font-size: 0.875rem; }
.action-btn-sub   { font-size: 0.74rem; color: var(--text-secondary); margin-top: 2px; }

/* ======== PAGE HEADER ======== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ======== SEARCH BOX ======== */
.search-box { position: relative; }

.search-box i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.8rem;
    pointer-events: none;
}

.search-box .form-control { padding-left: 34px; min-width: 220px; }

/* ======== TABLES ======== */
.table {
    border-radius: 8px;
    overflow: hidden;
    margin: 0;
}

.table thead th {
    background: var(--content-bg);
    color: var(--text-secondary);
    border: none;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px;
}

.table tbody td {
    border-color: var(--border);
    padding: 13px 16px;
    vertical-align: middle;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:hover { background: rgba(79,70,229,0.04); }

/* Remove Bootstrap striped alternating rows */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: transparent;
    background-color: transparent;
}

/* ======== BADGES ======== */
.badge {
    font-size: 0.71rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 50px;
    letter-spacing: 0.02em;
}

.badge.bg-success { background-color: rgba(16,185,129,0.12) !important; color: #065f46 !important; }
.badge.bg-warning { background-color: rgba(245,158,11,0.12) !important; color: #92400e !important; }
.badge.bg-danger  { background-color: rgba(239,68,68,0.12) !important; color: #7f1d1d !important; }
.badge.bg-primary { background-color: rgba(79,70,229,0.12) !important; color: #312e81 !important; }

/* ======== BUTTONS ======== */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 8px 16px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
    border-color: #059669;
    color: white;
}

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

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-secondary {
    background: var(--content-bg);
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: var(--border);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ======== FORMS ======== */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 1.5px solid var(--border);
    padding: 9px 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: var(--card-bg);
    font-family: 'Inter', sans-serif;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
    outline: none;
}

.form-control::placeholder { color: #94a3b8; }

.input-group-text {
    background: var(--content-bg);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.input-group .form-control:not(:first-child),
.input-group .form-select:not(:first-child) { border-left: none; }

.input-group .form-control:not(:last-child),
.input-group .form-select:not(:last-child) { border-right: none; }

/* ======== ALERTS ======== */
.alert {
    border: none;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 12px 16px;
}

.alert-success { background: rgba(16,185,129,0.1); color: #065f46; }
.alert-danger   { background: rgba(239,68,68,0.1);  color: #7f1d1d; }
.alert-warning  { background: rgba(245,158,11,0.1); color: #92400e; }
.alert-info     { background: rgba(59,130,246,0.1); color: #1e40af; }

/* ======== MODALS ======== */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    background: var(--primary);
    color: white;
    border-radius: 16px 16px 0 0;
    border: none;
    padding: 18px 24px;
}

.modal-header .btn-close { filter: invert(1); }
.modal-title { font-weight: 600; font-size: 1rem; }

.modal-body    { padding: 24px; }
.modal-footer  { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ======== LOGIN PAGE ======== */
.login-body {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    padding: 20px;
}

.login-card {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    border: none;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.22);
    max-width: 400px;
    width: 100%;
    padding: 44px 40px;
}

.login-icon-wrap {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    margin: 0 auto 18px;
    box-shadow: 0 8px 24px rgba(79,70,229,0.35);
}

.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}

.login-sub {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.875rem;
    margin-bottom: 30px;
}

/* ======== ANIMATIONS ======== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}

.fade-in { animation: fadeInUp 0.35s ease both; }

/* ======== CUSTOM SCROLLBAR ======== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ======== RESPONSIVE ======== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .hamburger-btn {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .kpi-card {
        padding: 16px;
    }

    .kpi-value {
        font-size: 1.6rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .user-chip-name {
        display: none;
    }

    .search-box .form-control {
        min-width: 140px;
    }

    .login-card {
        padding: 32px 24px;
    }
}
