/**
 * Boutique ERP - Main Stylesheet
 * Modern, responsive design with Bootstrap 5 customizations
 */

/* ============================================
   CSS Variables - Theme Configuration
   ============================================ */
:root {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;

    /* Secondary Colors */
    --secondary: #64748b;
    --secondary-dark: #475569;
    --secondary-light: #94a3b8;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;

    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 64px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
}

/* ============================================
   Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-700);
    background-color: var(--gray-100);
    overflow-x: hidden;
}

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

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

/* ============================================
   Layout - Sidebar
   ============================================ */
/* Sidebar theme variables - set from PHP or defaults */
:root {
    --sb-g1: var(--dash-g1, #6366f1);
    --sb-g2: var(--dash-g2, #4338ca);
    --sb-accent: var(--dash-accent, #818cf8);
    --sb-light: var(--dash-light, #eef2ff);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1a1230 0%, #1e1b35 40%, #141227 100%);
    z-index: 1040;
    transition: width var(--transition-normal);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    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;
    background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 100%);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}

.sidebar-logo:hover { color: var(--white); }

.sidebar-logo img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.sidebar-menu {
    padding: 0.75rem 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu::-webkit-scrollbar {
    width: 3px;
}

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

.menu-label {
    padding: 1rem 1.25rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
}

.nav-item {
    margin: 2px 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.9rem;
    color: rgba(255, 255, 255, 0.55);
    border-radius: 10px;
    transition: all var(--transition-fast);
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.9);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--sb-g1), var(--sb-g2));
    color: var(--white);
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25), 0 0 20px color-mix(in srgb, var(--sb-g1) 20%, transparent);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.85;
}

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

.nav-link .badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-weight: 600;
}

/* Submenu */
.submenu {
    display: none;
    padding-left: 2.5rem;
}

.submenu.show {
    display: block;
}

.submenu .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.825rem;
}

/* Sidebar theme picker footer */
.sidebar-footer {
    flex-shrink: 0;
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    font-weight: 500;
    user-select: none;
}
.sidebar-theme-toggle:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.8); }
.sidebar-theme-toggle .stt-swatch {
    width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.sidebar-theme-toggle i { margin-left: auto; font-size: 0.7rem; transition: transform 0.2s; }
.sidebar-theme-toggle.open i { transform: rotate(180deg); }

.sidebar-theme-options {
    display: none; padding: 8px 4px 4px;
    gap: 6px; flex-wrap: wrap; justify-content: center;
}
.sidebar-theme-options.open { display: flex; }

.sidebar-theme-swatch {
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}
.sidebar-theme-swatch:hover { transform: scale(1.15); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.sidebar-theme-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--sb-g1), 0 4px 12px rgba(0,0,0,0.4); }

/* ============================================
   Layout - Main Content
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   Header
   ============================================ */
.main-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
}

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

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: var(--gray-50);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.search-box i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--border-radius);
    color: var(--gray-600);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.header-icon:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.header-icon .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-dropdown:hover {
    background: var(--gray-100);
}

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

.user-info {
    line-height: 1.3;
}

.user-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ============================================
   Page Content
   ============================================ */
.page-content {
    padding: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
}

.breadcrumb-item a {
    color: var(--gray-500);
}

.breadcrumb-item.active {
    color: var(--gray-700);
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    background: transparent;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* Stats Cards */
.stat-card {
    padding: 1.25rem;
    border-radius: var(--border-radius-lg);
    background: var(--white);
    border: 1px solid var(--gray-200);
    transition: all var(--transition-fast);
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stat-card.primary .stat-icon {
    background: var(--primary-bg);
    color: var(--primary);
}

.stat-card.success .stat-icon {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card.warning .stat-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-card.danger .stat-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-card.info .stat-icon {
    background: var(--info-bg);
    color: var(--info);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

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

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

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

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

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ============================================
   Forms
   ============================================ */
.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

.form-control, .form-select {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

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

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.invalid-feedback {
    font-size: 0.8125rem;
    color: var(--danger);
}

.input-group-text {
    background: var(--gray-100);
    border-color: var(--gray-300);
    font-size: 0.875rem;
}

.form-text {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

/* ============================================
   Tables
   ============================================ */
.table {
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-responsive {
    border-radius: var(--border-radius);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 20px;
}

.badge.bg-primary { background: var(--primary) !important; }
.badge.bg-success { background: var(--success) !important; }
.badge.bg-warning { background: var(--warning) !important; color: var(--gray-900); }
.badge.bg-danger { background: var(--danger) !important; }
.badge.bg-info { background: var(--info) !important; }
.badge.bg-secondary { background: var(--gray-500) !important; }

.badge-soft-primary { background: var(--primary-bg); color: var(--primary); }
.badge-soft-success { background: var(--success-bg); color: var(--success); }
.badge-soft-warning { background: var(--warning-bg); color: var(--warning); }
.badge-soft-danger { background: var(--danger-bg); color: var(--danger); }
.badge-soft-info { background: var(--info-bg); color: var(--info); }

/* ============================================
   Alerts
   ============================================ */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
}

.alert-danger {
    background: var(--danger-bg);
    color: #991b1b;
}

.alert-info {
    background: var(--info-bg);
    color: #1e40af;
}

/* ============================================
   Modals
   ============================================ */
.modal-content {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown-menu {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    font-size: 0.875rem;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    color: var(--gray-700);
}

.dropdown-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.dropdown-item i {
    width: 20px;
    margin-right: 0.5rem;
    color: var(--gray-500);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--gray-200);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2rem;
}

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

.login-card {
    background: var(--white);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
}

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

.login-logo img {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}

.login-logo p {
    color: var(--gray-500);
    margin: 0;
    font-size: 0.875rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .form-control {
    padding: 0.75rem 1rem;
}

.login-form .btn-primary {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

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

.bg-light { background: var(--gray-100) !important; }
.bg-primary-light { background: var(--primary-bg) !important; }

.rounded-lg { border-radius: var(--border-radius-lg) !important; }
.rounded-xl { border-radius: var(--border-radius-xl) !important; }

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

.cursor-pointer { cursor: pointer; }
.transition { transition: all var(--transition-normal); }

/* ============================================
   Loading & Spinner
   ============================================ */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ============================================
   Mobile Bottom Navigation
   ============================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    z-index: 1050;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.08);
}

.mobile-bottom-nav .nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--gray-500);
    font-size: 0.625rem;
    text-decoration: none;
    gap: 0.25rem;
    min-width: 64px;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.mobile-bottom-nav .nav-link i {
    font-size: 1.25rem;
}

.mobile-bottom-nav .nav-link.active {
    color: var(--sb-g1, var(--primary));
    background: var(--sb-light, var(--primary-bg));
}

.mobile-bottom-nav .nav-link:hover {
    color: var(--sb-g1, var(--primary));
}

.mobile-bottom-nav .nav-link .badge {
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(100%);
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
}

/* Mobile FAB (Floating Action Button) */
.mobile-fab {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: none;
    box-shadow: var(--shadow-lg);
    z-index: 1040;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mobile-fab:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.mobile-fab:active {
    transform: scale(0.95);
}

/* ============================================
   Responsive - Tablet and Desktop
   ============================================ */
@media (max-width: 1199.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
        opacity: 0;
        transition: opacity var(--transition-normal);
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
}

/* ============================================
   Responsive - Tablet
   ============================================ */
@media (max-width: 991.98px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header > div:last-child {
        width: 100%;
    }

    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* Better chart sizing on tablet */
    .card canvas {
        min-height: 200px;
    }

    /* Stack columns on tablet */
    .col-lg-6,
    .col-lg-8,
    .col-lg-4 {
        margin-bottom: 1rem;
    }
}

/* ============================================
   Responsive - Mobile
   ============================================ */
@media (max-width: 767.98px) {
    /* Root adjustments for mobile */
    :root {
        --header-height: 56px;
    }

    body {
        font-size: 15px;
        -webkit-tap-highlight-color: transparent;
        padding-bottom: 70px; /* Space for bottom nav */
    }

    /* Header adjustments */
    .main-header {
        padding: 0 1rem;
        height: var(--header-height);
    }

    .search-box {
        display: none !important;
    }

    .header-left {
        gap: 0.5rem;
    }

    .header-right .user-info,
    .header-right .fa-chevron-down {
        display: none !important;
    }

    .header-right {
        gap: 0.25rem;
    }

    .header-icon {
        width: 36px;
        height: 36px;
    }

    /* Branch selector on mobile */
    .header-right .dropdown .btn-outline-secondary {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .header-right .dropdown .btn-outline-secondary .fa-building {
        display: none;
    }

    /* Sidebar full width on mobile */
    .sidebar {
        width: 280px;
    }

    /* Page content */
    .page-content {
        padding: 1rem;
    }

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

    /* Stat cards - 2 per row on mobile */
    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.375rem;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Card adjustments */
    .card {
        border-radius: var(--border-radius);
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-title {
        font-size: 0.9375rem;
    }

    /* Show mobile bottom nav */
    .mobile-bottom-nav {
        display: block;
    }

    .mobile-fab {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide desktop footer on mobile */
    .main-footer {
        display: none;
    }

    /* Tables - Responsive card view */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
        border: none;
    }

    .table {
        font-size: 0.8125rem;
    }

    .table th {
        padding: 0.625rem 0.75rem;
        font-size: 0.75rem;
    }

    .table td {
        padding: 0.625rem 0.75rem;
    }

    /* Stack table for small data sets */
    .table-stack-mobile thead {
        display: none;
    }

    .table-stack-mobile tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--gray-200);
        border-radius: var(--border-radius);
        padding: 0.75rem;
        background: var(--white);
    }

    .table-stack-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--gray-100);
    }

    .table-stack-mobile tbody td:last-child {
        border-bottom: none;
    }

    .table-stack-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    /* Buttons - Touch friendly */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.9375rem;
        min-height: 44px;
    }

    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
        min-height: 36px;
    }

    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        min-height: 52px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
    }

    .btn-icon.btn-sm {
        width: 36px;
        height: 36px;
    }

    /* Button groups on mobile */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }

    /* Forms - Touch friendly */
    .form-control,
    .form-select {
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px;
        border-radius: var(--border-radius);
    }

    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }

    .input-group-text {
        padding: 0.75rem 1rem;
        min-height: 48px;
    }

    /* Form row adjustments */
    .row.g-3 > [class*="col-"] {
        margin-bottom: 0.75rem;
    }

    /* Stack form buttons */
    .card-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .card-footer .btn:last-child {
        margin-bottom: 0;
    }

    .card-footer .d-flex {
        flex-direction: column;
    }

    /* Modals - Full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
    }

    .modal-content {
        border: none;
        border-radius: 0;
        min-height: 100vh;
    }

    .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: var(--white);
        z-index: 10;
    }

    .modal-body {
        padding: 1rem;
        padding-bottom: 100px;
    }

    .modal-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--white);
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .modal-footer .btn {
        flex: 1;
    }

    /* Alerts - Full width on mobile */
    .alert {
        border-radius: var(--border-radius);
        padding: 0.875rem 1rem;
        margin-bottom: 1rem;
    }

    /* Badges */
    .badge {
        padding: 0.375rem 0.625rem;
        font-size: 0.6875rem;
    }

    /* Dropdown menus */
    .dropdown-menu {
        font-size: 0.9375rem;
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.8125rem;
        flex-wrap: wrap;
    }

    /* DataTables adjustments */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        margin-bottom: 1rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: center;
        margin-top: 1rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.5rem 0.75rem;
    }

    /* Select2 adjustments */
    .select2-container--bootstrap-5 .select2-selection {
        min-height: 48px;
        padding: 0.5rem 0.75rem;
        font-size: 16px;
    }

    .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
        line-height: 28px;
    }

    /* Charts responsive */
    .card canvas {
        min-height: 180px;
        max-height: 250px;
    }

    /* Quick action cards on mobile */
    .quick-action-card {
        padding: 1rem;
    }

    .quick-action-card i {
        font-size: 1.5rem;
    }

    /* Login page mobile */
    .login-page {
        padding: 1rem;
    }

    .login-card {
        padding: 1.5rem;
        border-radius: var(--border-radius-lg);
    }

    .login-logo h1 {
        font-size: 1.25rem;
    }

    .login-form .form-control {
        padding: 0.875rem 1rem;
    }
}

/* ============================================
   Responsive - Small Mobile
   ============================================ */
@media (max-width: 575.98px) {
    body {
        font-size: 14px;
    }

    .page-content {
        padding: 0.75rem;
    }

    .page-header {
        margin-bottom: 1rem;
    }

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

    /* Stack stat cards vertically */
    .row > .col-sm-6.col-xl-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .stat-card {
        padding: 0.875rem;
    }

    .stat-card .stat-value {
        font-size: 1.125rem;
    }

    .stat-card .stat-label {
        font-size: 0.75rem;
    }

    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
        margin-bottom: 0.75rem;
    }

    /* Card adjustments */
    .card {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .card-body {
        padding: 0.875rem;
    }

    /* Table font size */
    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }

    /* Smaller action buttons in tables */
    .table .btn-icon {
        width: 32px;
        height: 32px;
    }

    /* Mobile FAB position */
    .mobile-fab {
        bottom: 75px;
        right: 0.75rem;
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }

    /* Bottom nav adjustments */
    .mobile-bottom-nav .nav-link {
        padding: 0.5rem 0.75rem;
        min-width: 56px;
        font-size: 0.5625rem;
    }

    .mobile-bottom-nav .nav-link i {
        font-size: 1.125rem;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px;
        padding: 0.625rem 0.875rem;
    }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover states on touch devices */
    .btn:hover {
        transform: none;
    }

    .stat-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }

    .nav-link:hover {
        background: transparent;
    }

    /* Active states for touch */
    .btn:active {
        transform: scale(0.98);
    }

    .nav-link:active {
        background: rgba(255, 255, 255, 0.08);
    }

    /* Larger touch targets */
    .dropdown-item {
        padding: 0.875rem 1rem;
    }

    .nav-link {
        padding: 0.75rem 1rem;
    }

    /* Disable text selection on interactive elements */
    .btn,
    .nav-link,
    .dropdown-item {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ============================================
   Landscape Mobile Orientation
   ============================================ */
@media (max-width: 767.98px) and (orientation: landscape) {
    .mobile-bottom-nav {
        padding: 0.25rem 0;
    }

    .mobile-bottom-nav .nav-link {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.375rem 0.75rem;
    }

    .mobile-bottom-nav .nav-link i {
        font-size: 1rem;
    }

    body {
        padding-bottom: 50px;
    }

    .mobile-fab {
        bottom: 60px;
    }
}

/* ============================================
   iOS Safe Area Support
   ============================================ */
@supports (padding: max(0px)) {
    .mobile-bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }

    .modal-footer {
        padding-bottom: max(1rem, calc(1rem + env(safe-area-inset-bottom)));
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar,
    .main-header,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }
}
