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

/* ============================================================
   IPS INZEGANE - ERP Financial Styles
   Modern SaaS Aesthetic (Stripe/Linear/Filament inspired)
   ============================================================ */

:root {
    --primary: #2563eb; /* Modern, rich royal blue (Blue-600) */
    --primary-dark: #1d4ed8; /* Blue-700 */
    --primary-light: #3b82f6; /* Blue-500 */
    --primary-rgb: 37, 99, 235;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #0f172a;
    --light: #f8fafc;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    
    --accent-yellow: #f2c94c;
    --accent-yellow-dark: #d4af37;
    --accent-yellow-light: #fff9e6;

    --sidebar-width: 260px;
    --navbar-height: 64px;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --card-hover-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark Mode Variables */
[data-bs-theme="dark"] {
    --primary: #3b82f6; /* Blue-500 */
    --primary-dark: #2563eb; /* Blue-600 */
    --primary-light: #60a5fa; /* Blue-400 */
    --primary-rgb: 59, 130, 246;
    --secondary: #94a3b8;
    --dark: #f8fafc;
    --light: #090d16;
    --white: #111827;
    --border-color: #1f2937;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --card-hover-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   GENERAL & TYPOGRAPHY
   ============================================================ */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: var(--font-family);
    background: var(--light);
    color: var(--text-main);
    overflow-x: hidden;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6 {
    color: var(--dark);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Layout adjustments */
.container-fluid {
    padding-left: clamp(12px, 3vw, 32px);
    padding-right: clamp(12px, 3vw, 32px);
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.card { 
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius); 
    box-shadow: var(--card-shadow);
    transition: var(--transition); 
}
.card:hover { 
    box-shadow: var(--card-hover-shadow); 
}

.card-header {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 1.25rem;
}

.badge { 
    font-weight: 600; 
    font-size: 0.75rem;
    padding: 0.35em 0.65em; 
    border-radius: var(--border-radius-sm); 
    letter-spacing: 0.02em;
}

.bg-success {
    background-color: rgba(16, 185, 129, 0.12) !important;
    color: #065f46 !important;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.bg-danger {
    background-color: rgba(239, 68, 68, 0.12) !important;
    color: #991b1b !important;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.bg-warning {
    background-color: rgba(245, 158, 11, 0.12) !important;
    color: #92400e !important;
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.bg-info {
    background-color: rgba(59, 130, 246, 0.12) !important;
    color: #1e40af !important;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn { 
    border-radius: var(--border-radius-sm); 
    font-weight: 500; 
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: var(--transition); 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-sm { 
    font-size: 0.775rem;
    padding: 0.35rem 0.75rem;
}
.btn-lg {
    padding: 0.75rem 1.5rem;
}

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

.shadow-sm { 
    box-shadow: var(--card-shadow) !important; 
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgba(29, 78, 216, 0.95) 0%, rgba(15, 23, 42, 1) 90%);
    padding: 24px;
}

.login-container { 
    width: 100%; 
    max-width: 440px; 
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.login-header { 
    padding: 40px 40px 20px; 
}
.login-logo { 
    color: var(--primary);
    margin-bottom: 16px;
}
.login-logo i {
    filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.15));
}
.login-header h3 {
    font-size: 1.35rem;
    font-weight: 700;
}
.login-body { 
    padding: 0 40px 40px; 
}
.login-footer { 
    padding: 20px 40px; 
    background: var(--light); 
    border-top: 1px solid var(--border-color);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#wrapper {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background: #002CA3; /* Sleek dark navy/slate SaaS background */
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo { 
    color: var(--accent-yellow); 
}
.brand-title { 
    font-weight: 700; 
    font-size: 1.15rem; 
    color: var(--white);
    letter-spacing: 0.05em;
}
.brand-subtitle { 
    font-size: 0.7rem; 
    opacity: 0.6; 
}

.sidebar-user {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.sidebar-user .avatar-sm {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.sidebar-user .fw-bold {
    color: var(--white);
}

.sidebar-nav {
    list-style: none;
    padding: 16px 0;
    flex-grow: 1;
    margin: 0;
}

.nav-section {
    padding: 12px 24px 6px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.45;
    font-weight: 70;
    color: #e6b800;
}

.sidebar-nav .nav-item { 
    margin: 2px 12px; 
}
.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
    font-weight: 600;
    border-left: 3px solid var(--accent-yellow);
    padding-left: 13px; /* account for border width */
}

.sidebar-nav .nav-link i { 
    width: 18px; 
    text-align: center; 
    font-size: 1rem; 
    opacity: 0.85;
}
.sidebar-nav .nav-link.active i {
    color: var(--accent-yellow);
    opacity: 1;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.sidebar-footer .text-muted {
    color: rgba(255, 255, 255, 0.45) !important;
    font-size: 0.75rem;
}

#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
    width: calc(100% - var(--sidebar-width));
}

/* Sidebar Toggle button on top navbar */
#menuToggle {
    color: var(--text-main);
    font-size: 1.25rem;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}
#menuToggle:hover {
    background: var(--light);
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    background: var(--white);
    height: var(--navbar-height);
    border-bottom: 1px solid var(--border-color);
    padding: 0 clamp(12px, 3vw, 24px);
    display: flex;
    align-items: center;
}

.nav-icon {
    color: var(--text-muted);
    font-size: 1.15rem;
    position: relative;
    padding: 10px;
    border-radius: 50%;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-icon:hover {
    background: var(--light);
    color: var(--primary);
}

.notification-badge { 
    font-size: 0.65rem; 
    min-width: 16px; 
    height: 16px; 
    padding: 0; 
    line-height: 16px; 
    text-align: center;
}

.navbar-date { 
    color: var(--text-muted); 
    font-size: 0.85rem; 
    font-weight: 500;
}

/* Notification Dropdown */
.notification-dropdown { 
    width: 320px; 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 0; 
}
.notification-list { 
    max-height: 300px; 
    overflow-y: auto; 
}
.notification-footer { 
    padding: 12px; 
    border-top: 1px solid var(--border-color); 
}

/* ============================================================
   KPI CARDS (Executive Dashboard)
   ============================================================ */
.card-kpi {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
    height: 100%;
}

.card-kpi:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.04), 0 4px 6px -2px rgba(0,0,0,0.02); 
}

.kpi-label { 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    margin-bottom: 6px; 
    font-weight: 600; 
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.kpi-value { 
    font-weight: 700; 
    font-size: 1.6rem;
    margin-bottom: 4px; 
    color: var(--dark);
    letter-spacing: -0.03em;
}
.kpi-value small { 
    font-size: 0.8rem; 
    font-weight: 500; 
    color: var(--text-muted);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-soft-green { background: rgba(16, 185, 129, 0.08); }
.bg-soft-red { background: rgba(239, 68, 68, 0.08); }
.bg-soft-primary { background: rgba(15, 81, 50, 0.08); }
.bg-soft-info { background: rgba(59, 130, 246, 0.08); }
.bg-soft-warning { background: rgba(245, 158, 11, 0.08); }

.card-kpi-sm {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}
.card-kpi-sm:hover { 
    transform: translateY(-2px); 
    box-shadow: var(--card-hover-shadow); 
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    margin-bottom: 0;
    vertical-align: middle;
}
.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
    background-color: var(--light);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
}
.table tbody td {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}
.table-hover tbody tr {
    transition: var(--transition);
}
.table-hover tbody tr:hover {
    background-color: rgba(15, 81, 50, 0.02) !important;
}

/* Avatar styling */
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-label { 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--dark); 
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--white);
    color: var(--text-main);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}
.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* ============================================================
   REPORTS & STATISTICS
   ============================================================ */
.report-card { 
    transition: var(--transition); 
}
.report-card:hover { 
    transform: translateY(-3px); 
}
.report-icon { 
    width: 64px; 
    height: 64px; 
    border-radius: var(--border-radius); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* ============================================================
   DATA TABLES (JQUERY PLUGIN OVERRIDES)
   ============================================================ */
.dataTables_wrapper {
    padding: 4px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--border-radius-sm) !important;
    padding: 0.35em 0.85em !important;
    font-weight: 500 !important;
    font-size: 0.8rem !important;
    transition: var(--transition);
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--light) !important;
    color: var(--primary) !important;
    border-color: var(--border-color) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--white) !important;
}

/* ============================================================
   RESPONSIVE DESIGN (Adaptive & Fluid)
   ============================================================ */

/* Base Typography Fluidity */
h4 { font-size: clamp(1.15rem, 2.5vw, 1.45rem); }
h5 { font-size: clamp(1rem, 2vw, 1.2rem); }
h6 { font-size: clamp(0.85rem, 1.5vw, 0.95rem); }

/* Spacing Fluidity */
.py-3 { padding-top: clamp(0.75rem, 2vh, 1.5rem) !important; padding-bottom: clamp(0.75rem, 2vh, 1.5rem) !important; }
.mb-4 { margin-bottom: clamp(1rem, 3vh, 1.75rem) !important; }

/* Responsive tables with clean scroll mechanism */
.table-responsive {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive .table {
    min-width: 750px; /* Forces horizontal scroll only on tables that need it on small viewports */
}

/* Adaptive Breakpoint grid styling */

@media (min-width: 992px) {
    /* Support sidebar toggle on desktop viewports */
    .sidebar.active {
        margin-left: calc(-1 * var(--sidebar-width));
    }
    #page-content-wrapper.active {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 991.98px) {
    /* Collapse sidebar on tablets and phones */
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: none;
        z-index: 1050;
    }
    .sidebar.active {
        margin-left: 0;
        box-shadow: 10px 0 30px rgba(0,0,0,0.15);
    }
    #page-content-wrapper {
        margin-left: 0;
        width: 100%;
    }
    #page-content-wrapper.active {
        margin-left: var(--sidebar-width);
    }
    #sidebarOverlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(2px);
        z-index: 1049;
        transition: var(--transition);
    }
    #sidebarOverlay.active { 
        display: block; 
    }

    /* Stack Filter Rows on Smaller Viewports */
    .filter-row .col-md-2,
    .filter-row .col-md-3,
    .filter-row .col-md-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 8px;
    }
}

@media (max-width: 767.98px) {
    :root {
        --navbar-height: 56px;
    }
    
    .top-navbar {
        height: var(--navbar-height);
    }
    .navbar-date {
        display: none !important;
    }
    
    /* Layout styling for mobile devices */
    .kpi-value { 
        font-size: 1.3rem; 
    }
    .kpi-icon {
        width: 40px;
        height: 40px;
    }
    
    .card-body {
        padding: 12px !important;
    }

    .notification-dropdown {
        width: calc(100vw - 24px) !important;
        right: -60px !important;
        position: fixed !important;
        top: 60px !important;
        left: 12px !important;
    }

    /* Stack actions column buttons for touch access */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .btn-group-mobile .btn {
        width: 100%;
        margin-bottom: 0 !important;
    }

    /* 2 column grid for KPI metrics on phones */
    .row.g-3 > .col-xl-3.col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .row.g-3 > .col-xl-2 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 575.98px) {
    /* 1 Column stack on small mobile screens */
    .row.g-3 > .col-xl-3.col-md-6,
    .row.g-3 > .col-xl-2,
    .row.g-3 > div[class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .d-flex.justify-content-between.align-items-center.mb-4 > div,
    .d-flex.justify-content-between.align-items-center.mb-3 > div {
        width: 100%;
    }
    
    .d-flex.justify-content-between.align-items-center.mb-4 select,
    .d-flex.justify-content-between.align-items-center.mb-3 select {
        width: 100% !important;
    }
}

/* ============================================================
   RECEIPT CARD & INVOICES
   ============================================================ */
@media screen and (max-width: 991.98px) {
    .receipt-card {
        width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        margin: 0 !important;
    }
}
@media screen and (max-width: 575.98px) {
    .receipt-header img {
        height: 48px !important;
    }
    .receipt-header h4 {
        font-size: 1rem !important;
    }
    .receipt-table {
        font-size: 0.72rem !important;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary { 
    color: var(--primary) !important; 
}
.unread { 
    background-color: rgba(15, 81, 50, 0.03) !important; 
}
[data-bs-theme="dark"] .unread {
    background-color: rgba(25, 135, 84, 0.05) !important;
}

.actions-col {
    width: 1%;
    white-space: nowrap;
}

@media print {
    .sidebar, .top-navbar, .btn, .sidebar-toggle, .no-print, #sidebarToggle, #menuToggle { 
        display: none !important; 
    }
    #page-content-wrapper { 
        margin-left: 0 !important; 
        width: 100% !important;
    }
    .card { 
        box-shadow: none !important; 
        border: 1px solid var(--border-color) !important; 
    }
}
