/* =========================================================
   Gandiva ERP - Design System & Modern UI Stylesheet
   GandivaBiztech Solutions
   ========================================================= */

:root {
    --primary: #0b57d0;
    --primary-hover: #0842a0;
    --primary-light: #e8f0fe;
    --secondary: #0088d1;
    --secondary-hover: #0277bd;
    --dark-bg: #0f172a;
    --sidebar-bg: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --card-bg: #ffffff;
    --body-bg: #f8fafc;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Bootstrap 5 CSS Variable Dynamic Binding */
    --bs-primary: var(--primary);
    --bs-primary-rgb: 11, 87, 208;
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-hover);
}

.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    filter: brightness(0.9);
}

.btn-outline-primary {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* App Layout Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

/* Sidebar Navigation */
.app-sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    left: 0;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    border-right: 1px solid rgba(255,255,255,0.06);
    overflow-x: hidden;
}

.sidebar-header-wrapper {
    height: 70px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    padding-right: 8px;
}

.sidebar-brand {
    height: 70px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand img {
    height: 38px;
    width: 38px;
    min-width: 38px;
    filter: drop-shadow(0 2px 8px rgba(37,99,235,0.3));
    display: block;
}

.sidebar-brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
    line-height: 1.2;
    transition: opacity 0.2s ease, visibility 0.2s;
    white-space: nowrap;
}

.sidebar-brand-text span {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #38bdf8;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 10px;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for sidebar menu */
.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.menu-header {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 14px 12px 6px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.menu-item {
    margin-bottom: 3px;
    position: relative;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.menu-link i {
    font-size: 1.15rem;
    width: 22px;
    min-width: 22px;
    text-align: center;
    color: #94a3b8;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-link span {
    transition: opacity 0.2s ease;
}

.menu-link:hover {
    color: #ffffff;
    background-color: rgba(255,255,255,0.06);
}

.menu-link:hover i {
    color: #38bdf8;
}

.menu-item.active .menu-link {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.menu-item.active .menu-link i {
    color: #ffffff;
}

/* =========================================================
   Collapsed / Minimized Sidebar State (Desktop)
   ========================================================= */
body.sidebar-collapsed .app-sidebar {
    width: 74px;
}

body.sidebar-collapsed .sidebar-brand {
    padding: 0 18px;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .menu-header,
body.sidebar-collapsed .menu-link span {
    display: none !important;
}

body.sidebar-collapsed .menu-link {
    justify-content: center;
    padding: 12px;
}

body.sidebar-collapsed .menu-link i {
    margin: 0;
    font-size: 1.25rem;
}

/* Main Content Area */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--body-bg);
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Navbar */
.app-navbar {
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    transition: var(--transition);
}

.sidebar-toggle-btn {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: #f8fafc;
    transition: var(--transition);
}

.sidebar-toggle-btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--primary);
}

.app-navbar .dropdown-menu {
    z-index: 1050 !important;
}

.navbar-search {
    position: relative;
    width: 360px;
    display: flex;
    align-items: center;
}

.navbar-search input {
    width: 100%;
    padding: 8px 16px 8px 38px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: #f1f5f9;
    font-size: 0.88rem;
    transition: var(--transition);
    height: 38px;
}

.navbar-search input:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.15);
}

.navbar-search i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.user-profile-badge:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #0288d1);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.88rem;
    flex-shrink: 0;
}

/* Content Body */
.content-body {
    padding: 24px 28px;
    flex-grow: 1;
    width: 100%;
    min-width: 0;
}

/* Page Headers */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.page-subtitle {
    font-size: 0.86rem;
    color: var(--text-muted);
    margin: 4px 0 0 0;
}

/* KPI Cards */
.kpi-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.kpi-icon.blue { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
.kpi-icon.green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.kpi-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.kpi-icon.rose { background: rgba(244, 63, 94, 0.1); color: #f43f5e; }

.kpi-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Custom Card Container */
.erp-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.erp-card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background-color: #ffffff;
}

.erp-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
}

.erp-card-body {
    padding: 24px;
}

/* Custom Table Styling */
.table-responsive {
    border-radius: var(--radius-sm);
    margin: 0;
}

.erp-table {
    margin-bottom: 0;
    width: 100%;
}

.erp-table thead th {
    background-color: #f8fafc;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid var(--border-color);
    padding: 14px 18px;
    vertical-align: middle;
    white-space: nowrap;
}

.erp-table tbody td {
    padding: 14px 18px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.erp-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Status Badges */
.badge-status {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.badge-status.paid { background: #dcfce7; color: #15803d; }
.badge-status.partially_paid { background: #fef3c7; color: #b45309; }
.badge-status.approved { background: #e0f2fe; color: #0369a1; }
.badge-status.cancelled { background: #fee2e2; color: #b91c1c; }
.badge-status.overdue { background: #ffe4e6; color: #be123c; }
.badge-status.active { background: #dcfce7; color: #15803d; }
.badge-status.inactive { background: #f1f5f9; color: #64748b; }

/* Action Buttons */
.btn-primary-erp {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.btn-primary-erp:hover {
    filter: brightness(0.92);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* Toast Container */
.erp-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* POS & Invoice Item Table */
.item-calc-input {
    font-size: 0.88rem;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 100%;
}

.item-calc-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.15);
}

/* Modals Alignment */
.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding: 16px 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Session Timer Component Styles */
.session-timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.02em;
}

.session-timer-badge .timer-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulseDot 2s infinite ease-in-out;
}

.session-timer-clock {
    font-family: 'Outfit', 'Inter', monospace, sans-serif;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: 0.04em;
}

.session-dashboard-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 16px;
    padding: 20px 24px;
    color: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2);
    position: relative;
    overflow: hidden;
}

.session-dashboard-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.session-timer-display {
    font-family: 'Outfit', monospace, sans-serif;
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.05em;
    color: #38bdf8;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
    font-variant-numeric: tabular-nums;
}

.session-timer-display .timer-colon {
    opacity: 0.7;
    animation: blinkColon 1s infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.75; }
}

@keyframes blinkColon {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Print Styles */
@media print {
    body {
        background: #ffffff;
    }
    .app-sidebar, .app-navbar, .no-print, .btn, .btn-group, .sidebar-backdrop, .sidebar-toggle-btn {
        display: none !important;
    }
    .content-body {
        padding: 0 !important;
        max-width: 100% !important;
    }
    .print-container {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }
}

/* =========================================================
   Mobile Responsiveness & Breakpoint Adaptations
   ========================================================= */

/* Backdrop overlay for mobile sidebar */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

/* Large and Medium screens adjustments (<= 992px) */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        width: 270px;
        transform: translateX(-100%);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
        z-index: 1040;
    }

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

    /* Reset desktop collapsed rules on tablet/mobile */
    body.sidebar-collapsed .app-sidebar {
        width: 270px;
        transform: translateX(-100%);
    }

    body.sidebar-collapsed.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .menu-header,
    body.sidebar-collapsed .menu-link span {
        display: inline-block !important;
    }

    body.sidebar-collapsed .sidebar-brand {
        padding: 0 20px;
        justify-content: flex-start;
    }

    body.sidebar-collapsed .menu-link {
        justify-content: flex-start;
        padding: 10px 14px;
    }

    .app-navbar {
        padding: 0 16px;
    }

    .content-body {
        padding: 18px 16px;
    }

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

    .page-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-title {
        font-size: 1.25rem;
    }
}

/* Small screens / Mobile phones (<= 767.98px) */
@media (max-width: 767.98px) {
    .app-navbar {
        height: 60px;
        padding: 0 12px;
    }

    .sidebar-brand,
    .sidebar-header-wrapper {
        height: 60px;
    }

    .sidebar-toggle-btn {
        width: 36px;
        height: 36px;
        padding: 4px;
    }

    .navbar-actions {
        gap: 8px;
    }

    .navbar-actions .btn span {
        display: none;
    }

    .navbar-actions .btn {
        padding: 6px 10px;
    }

    .user-profile-badge {
        padding: 3px 6px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .content-body {
        padding: 14px 10px;
    }

    .erp-card {
        border-radius: 12px;
    }

    .erp-card-body,
    .card-body {
        padding: 14px;
    }

    .kpi-card {
        padding: 16px;
    }

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

    .session-dashboard-card {
        padding: 16px;
    }

    .session-timer-display {
        font-size: 1.75rem;
    }

    /* Modal full-width on mobile */
    .modal-dialog {
        margin: 10px;
    }

    /* Table horizontal scrolling indicator & touch friendly */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        margin-bottom: 12px;
        border-radius: var(--radius-sm);
    }

    .erp-table th,
    .erp-table td {
        padding: 10px 8px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    /* Form control touch sizing */
    .form-control,
    .form-select,
    .input-group-text,
    .btn {
        font-size: 0.88rem;
    }
}

/* Extra small devices (<= 480px) */
@media (max-width: 480px) {
    .login-card {
        padding: 24px 18px !important;
    }
}

