@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Manrope:wght@200..800&display=swap');

:root {
    --brand-primary: #172033;
    --brand-secondary: #344054;
    --brand-bg: #F7F6F2;
    --brand-card: #FFFFFF;
    --brand-accent: #C58B55;
    --brand-accent-hover: #b07945;
    --brand-success: #2F7D5C;
    --brand-danger: #C94C4C;
    --brand-warning: #D97706;
    --brand-info: #2563EB;
    
    --brand-border: #E4E7EC;
    --brand-text: #1D2939;
    --brand-text-muted: #667085;
    --brand-sidebar-bg: #172033;
    --brand-sidebar-text: #E4E7EC;
    --brand-sidebar-muted: #98A2B3;
    --brand-sidebar-active: #C58B55;
    --brand-header-bg: #FFFFFF;
    
    --font-heading: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --sidebar-width: 230px;
    --sidebar-collapsed-width: 60px;
    --header-height: 56px;
    --border-radius: 6px;
    --transition: all 0.2s ease-in-out;
}

[data-bs-theme="dark"] {
    --brand-primary: #93C5FD;
    --brand-secondary: #CBD5E1;
    --brand-bg: #0F172A;
    --brand-card: #1E293B;
    --brand-accent: #E2A065;
    --brand-accent-hover: #C58B55;
    --brand-success: #34D399;
    --brand-danger: #F87171;
    --brand-warning: #FBBF24;
    --brand-info: #60A5FA;
    
    --brand-border: #334155;
    --brand-text: #F8FAFC;
    --brand-text-muted: #94A3B8;
    --brand-sidebar-bg: #090E1A;
    --brand-sidebar-text: #F1F5F9;
    --brand-sidebar-muted: #64748B;
    --brand-sidebar-active: #E2A065;
    --brand-header-bg: #1E293B;
}

/* Custom Thin Light Scrollbar Across Entire App (Requirement 3) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.45);
}

.app-sidebar::-webkit-scrollbar {
    width: 5px;
}
.app-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
}
.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}
.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.3) transparent;
}
.app-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(0, 0, 0, 0.15);
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--brand-text);
    background-color: var(--brand-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4, h5, h6, .page-title, .section-title, .card-title {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--brand-text);
    margin-bottom: 0.5rem;
}

.page-title {
    font-size: 24px;
    letter-spacing: -0.02em;
}

.section-title {
    font-size: 18px;
}

.card-title {
    font-size: 16px;
}

.dashboard-stat-number {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--brand-text);
    line-height: 1.2;
}

.text-muted-custom {
    color: var(--brand-text-muted) !important;
}

.btn {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 13.5px;
    border-radius: var(--border-radius);
    padding: 8px 16px;
    transition: var(--transition);
}

.btn-primary-custom {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #FFFFFF;
}
.btn-primary-custom:hover {
    background-color: #0F172A;
    border-color: #0F172A;
    color: #FFFFFF;
}

.btn-accent-custom {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
    color: #FFFFFF;
}
.btn-accent-custom:hover {
    background-color: var(--brand-accent-hover);
    border-color: var(--brand-accent-hover);
    color: #FFFFFF;
}

/* App Wrapper Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Styles */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--brand-sidebar-bg);
    color: var(--brand-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: width 0.05s ease-out, transform var(--transition);
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

/* Sidebar Resizer Handle (Requirement 4) */
.sidebar-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 1010;
    user-select: none;
    transition: background-color 0.2s ease;
}
.sidebar-resizer:hover,
.sidebar-resizer.is-resizing {
    background-color: var(--brand-accent);
}

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

.sidebar-brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 10px;
    color: var(--brand-sidebar-muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1;
}

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

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-sidebar-muted);
    padding: 10px 8px 3px 8px;
    opacity: 0.8;
}

.sidebar-item {
    margin-bottom: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    color: #CBD5E1;
    text-decoration: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 400;
    transition: var(--transition);
}

.sidebar-link i {
    font-size: 14px;
    width: 16px;
    text-align: center;
    color: #94A3B8;
    transition: var(--transition);
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
}

.sidebar-link:hover i {
    color: #FFFFFF;
}

.sidebar-link.active {
    background-color: rgba(197, 139, 85, 0.16);
    color: #FFFFFF;
    font-weight: 500;
    border-left: 2.5px solid var(--brand-accent);
}

.sidebar-link.active i {
    color: var(--brand-sidebar-active);
}

.sidebar-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--brand-accent);
    color: #FFFFFF;
}

/* Main Content Area */
.app-main {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
    width: calc(100vw - var(--sidebar-width));
}

/* Header Styles */
.app-header {
    height: var(--header-height);
    background-color: var(--brand-header-bg);
    border-bottom: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 990;
    transition: background-color var(--transition), border-color var(--transition);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid var(--brand-border);
    color: var(--brand-text);
    width: 38px;
    height: 38px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.sidebar-toggle-btn:hover {
    background-color: var(--brand-bg);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--brand-border);
    color: var(--brand-text);
    width: 38px;
    height: 38px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}
.theme-toggle-btn:hover {
    background-color: var(--brand-bg);
    color: var(--brand-accent);
}

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--brand-accent);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* Page Body Container */
.app-content {
    padding: 24px;
    flex-grow: 1;
}

/* Custom Cards */
.custom-card {
    background-color: var(--brand-card);
    border: 1px solid var(--brand-border);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
    transition: background-color var(--transition), border-color var(--transition);
}

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--brand-border);
}

/* Stat Cards */
.stat-card {
    background-color: var(--brand-card);
    border: 1px solid var(--brand-border);
    border-radius: var(--border-radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.primary { background: rgba(23, 32, 51, 0.08); color: var(--brand-primary); }
.stat-icon.accent { background: rgba(197, 139, 85, 0.12); color: var(--brand-accent); }
.stat-icon.success { background: rgba(47, 125, 92, 0.12); color: var(--brand-success); }
.stat-icon.danger { background: rgba(201, 76, 76, 0.12); color: var(--brand-danger); }
.stat-icon.warning { background: rgba(217, 119, 6, 0.12); color: var(--brand-warning); }
.stat-icon.info { background: rgba(37, 99, 235, 0.12); color: var(--brand-info); }

[data-bs-theme="dark"] .stat-icon.primary { background: rgba(147, 197, 253, 0.15); color: #93C5FD; }

/* Filter Box */
.filter-card {
    background-color: var(--brand-card);
    border: 1px solid var(--brand-border);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* Custom Table */
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
}

.custom-table th {
    background-color: var(--brand-bg);
    color: var(--brand-text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    border-top: 1px solid var(--brand-border);
    border-bottom: 1px solid var(--brand-border);
}

.custom-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--brand-border);
    color: var(--brand-text);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background-color: rgba(0, 0, 0, 0.015);
}

[data-bs-theme="dark"] .custom-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge-custom {
    font-size: 11.5px;
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-paid, .badge-active, .badge-available, .badge-resolved, .badge-present {
    background-color: rgba(47, 125, 92, 0.12);
    color: var(--brand-success);
}

.badge-pending, .badge-in-progress, .badge-leave {
    background-color: rgba(217, 119, 6, 0.12);
    color: var(--brand-warning);
}

.badge-overdue, .badge-danger, .badge-absent, .badge-full, .badge-failed {
    background-color: rgba(201, 76, 76, 0.12);
    color: var(--brand-danger);
}

.badge-partial, .badge-info {
    background-color: rgba(37, 99, 235, 0.12);
    color: var(--brand-info);
}

/* Form Controls */
.form-label {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13px;
    color: var(--brand-text);
    margin-bottom: 5px;
}

.form-control, .form-select {
    font-family: var(--font-body);
    font-size: 13.5px;
    color: var(--brand-text);
    background-color: var(--brand-card);
    border: 1px solid var(--brand-border);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(197, 139, 85, 0.15);
    background-color: var(--brand-card);
    color: var(--brand-text);
}

/* Responsive & Toggle */
.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}
.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-brand-sub,
.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-badge {
    display: none;
}
.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100vw - var(--sidebar-collapsed-width));
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show-mobile {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0 !important;
        width: 100vw !important;
    }
}

/* Print Receipt Styles */
@media print {
    .app-sidebar, .app-header, .no-print, .btn {
        display: none !important;
    }
    .app-main {
        margin: 0 !important;
        width: 100% !important;
    }
    .custom-card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
}
