/* =============================================
   GAI Mini ERP — Design System v2.0
   Modern · Clean · Premium
   ============================================= */

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

:root {
    /* Brand */
    --primary:        #4f46e5;
    --primary-light:  #6366f1;
    --primary-dark:   #3730a3;
    --primary-glow:   rgba(79, 70, 229, 0.15);

    /* Semantic */
    --success:  #10b981;
    --danger:   #ef4444;
    --warning:  #f59e0b;
    --info:     #0ea5e9;

    /* Neutral */
    --dark:       #0f172a;
    --body-text:  #1e293b;
    --muted:      #64748b;
    --border:     #e8edf4;
    --light:      #f8fafc;
    --white:      #ffffff;

    /* Surfaces */
    --bg-main:      #f1f5f9;
    --sidebar-bg:   #0f172a;
    --sidebar-text: rgba(255,255,255,0.65);
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(79,70,229,0.85);
    --topbar-bg:    #ffffff;

    /* Dimensions */
    --sidebar-width:  255px;
    --header-height:  64px;
    --footer-height:  52px;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm:  0 2px 8px rgba(0,0,0,0.06);
    --shadow:     0 4px 16px rgba(0,0,0,0.08);
    --shadow-md:  0 8px 24px rgba(0,0,0,0.10);
    --shadow-lg:  0 20px 48px rgba(0,0,0,0.14);

    /* Radii */
    --radius-xs: 0.25rem;
    --radius-sm: 0.5rem;
    --radius:    0.875rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.2s;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    background-color: var(--bg-main);
    color: var(--body-text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===================================================
   AUTH PAGE — Login
   =================================================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 100%);
    position: relative;
    overflow: hidden;
}

/* Decorative floating orbs */
.auth-wrapper::before,
.auth-wrapper::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}
.auth-wrapper::before {
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(99,102,241,0.35) 0%, transparent 70%);
    top: -150px; left: -150px;
}
.auth-wrapper::after {
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(16,185,129,0.2) 0%, transparent 70%);
    bottom: -100px; right: -100px;
}

.auth-card {
    background: #ffffff;
    padding: 2.75rem 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: 0 32px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.06);
    max-width: 440px;
    width: 100%;
    position: relative;
    z-index: 1;
    animation: authSlideIn 0.45s var(--ease);
}

@keyframes authSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

/* grad-primary icon inside white card stays visible */
.auth-logo .grad-primary {
    display: inline-flex;
    box-shadow: 0 8px 24px rgba(79,70,229,0.35);
    margin-bottom: 0.75rem;
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

/* Auth form — light Bootstrap-compatible */
.auth-card .form-label { color: var(--muted); font-size: 0.82rem; }
.auth-card .smaller    { font-size: 0.78rem; }

.auth-card .input-group-text {
    background: #fff;
    border-color: var(--border);
    color: var(--muted);
}
.auth-card .form-control {
    border-color: var(--border);
    color: var(--body-text);
}
.auth-card .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.auth-card .form-control::placeholder { color: #94a3b8; }

.auth-card .btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border: none;
    padding: 0.875rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(79,70,229,0.4);
    transition: all 0.25s var(--ease);
    letter-spacing: 0.02em;
}
.auth-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79,70,229,0.5);
    background: linear-gradient(135deg, #3730a3, #4f46e5);
}

/* Alert on auth — light red on white card */
.auth-card .alert-danger {
    background: rgba(239,68,68,0.08) !important;
    border: 1px solid rgba(239,68,68,0.2) !important;
    color: #b91c1c !important;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* ===================================================
   APP LAYOUT
   =================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===================================================
   SIDEBAR
   =================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: left var(--duration) var(--ease);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #818cf8);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}

.sidebar-brand-text {
    margin-left: 0.75rem;
    line-height: 1.2;
}
.sidebar-brand-text strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}
.sidebar-brand-text span {
    font-size: 0.65rem;
    font-weight: 500;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255,255,255,0.25);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0 0.75rem;
    margin-bottom: 0.375rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.575rem 0.875rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-weight: 500;
    font-size: 0.825rem;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
    position: relative;
}

.nav-link i {
    width: 18px;
    font-size: 0.9rem;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity var(--duration);
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.9);
    transform: translateX(2px);
}
.nav-link:hover i { opacity: 1; }

.nav-link.active {
    background: rgba(79,70,229,0.2);
    color: #a5b4fc;
    font-weight: 600;
}
.nav-link.active i { opacity: 1; color: #818cf8; }
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: #6366f1;
    border-radius: 0 4px 4px 0;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.575rem 0.875rem;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    transition: all var(--duration);
}
.sidebar-footer a:hover {
    background: rgba(239,68,68,0.12);
    color: #fca5a5;
}

/* ===================================================
   MAIN VIEWPORT
   =================================================== */
.main-viewport {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--duration) var(--ease);
}

/* ===================================================
   TOPBAR
   =================================================== */
.topbar {
    height: var(--header-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-xs);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    width: 36px; height: 36px;
    border: none;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--duration);
    font-size: 1rem;
}
.sidebar-toggle:hover { background: var(--border); color: var(--body-text); }

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--body-text);
    letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* FY Badge */
.fy-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    background: var(--primary-glow);
    border: 1px solid rgba(79,70,229,0.2);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}
.fy-badge i { font-size: 0.7rem; }

/* Notification bell */
.topbar-btn {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--duration);
}
.topbar-btn:hover { background: var(--bg-main); color: var(--primary); border-color: var(--primary); }

/* User Avatar Dropdown */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--white);
    transition: all var(--duration);
    text-decoration: none;
    color: inherit;
}
.user-menu:hover { background: var(--bg-main); border-color: var(--primary); }

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #818cf8);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.user-info strong {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--body-text);
    line-height: 1.2;
}
.user-info span {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Dropdown */
.dropdown-menu {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 0.5rem !important;
    min-width: 220px;
}
.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.875rem;
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--body-text);
    transition: all var(--duration);
}
.dropdown-item:hover { background: var(--bg-main); color: var(--primary); }
.dropdown-item.text-danger:hover { background: rgba(239,68,68,0.06); }
.dropdown-divider { border-color: var(--border); margin: 0.375rem 0; }

/* ===================================================
   CONTENT
   =================================================== */
.content-body {
    flex: 1;
    padding: 1.75rem;
    animation: fadeInUp 0.35s var(--ease) forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--dark);
}
.page-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.125rem;
}

/* ===================================================
   CARDS
   =================================================== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

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

.card-header {
    padding: 1.125rem 1.5rem;
    background: transparent;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--dark);
}

.card-body { padding: 1.5rem; }

/* ===================================================
   STAT CARDS (Dashboard)
   =================================================== */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1.125rem;
    padding: 1.375rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.25s var(--ease);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 100%;
    background: inherit;
    opacity: 0;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md) !important; }

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

.stat-content { flex: 1; }

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--dark);
    letter-spacing: -0.03em;
    display: block;
    line-height: 1;
}

.stat-trend {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ===================================================
   TABLES
   =================================================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: var(--light);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #f8fafc;
    font-size: 0.825rem;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbff; }

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* DataTables Override */
.dataTables_wrapper { padding: 0; }
.dataTables_wrapper .row { margin: 0; padding: 0.75rem 1rem; }
.dataTables_filter input {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.8rem;
    outline: none;
}
.dataTables_filter input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-glow) !important;
}

/* ===================================================
   FORM CONTROLS
   =================================================== */
.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--body-text);
    margin-bottom: 0.4rem;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.875rem;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--body-text);
    background-color: var(--white);
    transition: border-color var(--duration), box-shadow var(--duration);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

.input-group-text {
    background: var(--light);
    border-color: var(--border);
    color: var(--muted);
    font-size: 0.85rem;
}

/* ===================================================
   BUTTONS
   =================================================== */
.btn {
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.25rem;
    font-weight: 600;
    font-size: 0.825rem;
    transition: all 0.2s var(--ease);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79,70,229,0.4);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.btn-success:hover { background: #059669; transform: translateY(-1px); color: #fff; }

.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); color: #fff; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #d97706; transform: translateY(-1px); }

.btn-outline-primary {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-light {
    background: var(--bg-main);
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-light:hover { background: var(--border); color: var(--body-text); }

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.775rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 36px; height: 36px;
    justify-content: center;
}

/* ===================================================
   BADGES
   =================================================== */
.badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    letter-spacing: 0.04em;
}

/* ===================================================
   FOOTER
   =================================================== */
.content-footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    background: var(--white);
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: auto;
}

.footer-left strong { color: var(--body-text); font-weight: 600; }
.footer-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.footer-right a {
    color: var(--muted);
    font-weight: 500;
    transition: color var(--duration);
}
.footer-right a:hover { color: var(--primary); }

/* ===================================================
   GRADIENTS (legacy compat)
   =================================================== */
.grad-primary { background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%); color: #fff; }
.grad-success { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); color: #fff; }
.grad-danger  { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); color: #fff; }
.grad-warning { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); color: #fff; }

/* ===================================================
   INVOICE / LINE-ITEM TABLES
   =================================================== */
.line-items-header {
    background: #0f172a;
    color: #cbd5e1;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.line-item-row { transition: background var(--duration); }
.line-item-row:nth-child(even) { background: #f8fafc; }
.line-item-row:hover { background: #eef2ff; }

/* ===================================================
   ALERTS
   =================================================== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    padding: 0.875rem 1rem;
    font-size: 0.825rem;
    font-weight: 500;
}
.alert-success { background: rgba(16,185,129,0.1); color: #065f46; }
.alert-danger  { background: rgba(239,68,68,0.1);  color: #991b1b; }
.alert-warning { background: rgba(245,158,11,0.1); color: #92400e; }
.alert-info    { background: rgba(14,165,233,0.1); color: #0c4a6e; }

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 991.98px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
    }
    .sidebar.open {
        left: 0;
        box-shadow: 0 0 60px rgba(0,0,0,0.35);
    }
    .main-viewport { margin-left: 0 !important; }
    .sidebar-toggle { display: flex; }
    .fy-badge, .user-info { display: none; }
}

@media (max-width: 575.98px) {
    .content-body { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .content-footer { padding: 0 1rem; flex-direction: column; height: auto; gap: 0.25rem; padding: 0.75rem 1rem; }
}

/* ===================================================
   UTILITIES
   =================================================== */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--muted)   !important; }
.text-dark    { color: var(--dark)    !important; }

.bg-primary-soft { background: var(--primary-glow); }
.bg-success-soft { background: rgba(16,185,129,0.1); }
.bg-danger-soft  { background: rgba(239,68,68,0.1); }
.bg-warning-soft { background: rgba(245,158,11,0.1); }

/* Animate */
.animate-fade-in { animation: fadeInUp 0.35s var(--ease) forwards; }

/* Custom scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
