/* Variables - Light Mode (default) */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;

    /* Mobile touch targets (WCAG 2.5.5) */
    --touch-target-min: 44px;
    --mobile-font-min: 14px;
    --mobile-font-table: 13px;

    /* Semantic colors */
    --bg-body: var(--gray-100);
    --bg-card: #ffffff;
    --bg-sidebar: var(--gray-900);
    --bg-input: #ffffff;
    --bg-hover: var(--gray-50);
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-muted: var(--gray-500);
    --border-color: var(--gray-200);
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Dark Mode */
[data-theme="dark"] {
    --gray-50: #1f2937;
    --gray-100: #111827;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #f9fafb;

    /* Semantic colors dark */
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-input: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);

    /* Adjusted colors for dark mode */
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

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

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    transition: width 0.3s, background-color 0.3s;
    z-index: 100;
    border-right: 1px solid var(--border-color);
}
[data-theme="dark"] .sidebar {
    border-right: 1px solid #1e293b;
}
[data-theme="dark"] .nav-item {
    color: #cbd5e1;
}
[data-theme="dark"] .nav-item:hover {
    color: #ffffff;
    background: #334155;
}
[data-theme="dark"] .sidebar-header h1 {
    color: #f1f5f9;
}
[data-theme="dark"] .user-name {
    color: #f1f5f9;
}
[data-theme="dark"] .user-role {
    color: #94a3b8;
}
[data-theme="dark"] .logout-btn {
    color: #94a3b8;
}
[data-theme="dark"] .logout-btn:hover {
    color: #f1f5f9;
}
[data-theme="dark"] .app-version {
    color: #64748b;
}
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .label,
.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn {
    display: none;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-700);
}
.sidebar-header h1 {
    font-size: 18px;
    white-space: nowrap;
}
.toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--gray-300);
    transition: all 0.2s;
}
.nav-item:hover {
    background: var(--gray-700);
    color: white;
    text-decoration: none;
}
.nav-item.active {
    background: var(--primary);
    color: white;
}
.nav-item .icon {
    font-size: 20px;
    margin-right: 12px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-700);
}
.user-info {
    margin-bottom: 10px;
}
.user-name {
    display: block;
    font-weight: 600;
}
.user-role {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: capitalize;
}
.logout-btn {
    display: block;
    color: var(--gray-500);
    font-size: 14px;
}
.logout-btn:hover {
    color: white;
}
.btn-save-zip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    margin: 10px 0;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-save-zip:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-save-zip:disabled {
    background: var(--gray-500);
    cursor: wait;
    transform: none;
    box-shadow: none;
}
.btn-save-zip .save-icon {
    font-size: 14px;
}
.sidebar.collapsed .btn-save-zip {
    display: none;
}
.btn-claude-md {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    margin: 5px 0;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-claude-md:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.btn-claude-md:disabled {
    background: var(--gray-500);
    cursor: wait;
    transform: none;
    box-shadow: none;
}
.btn-claude-md .save-icon {
    font-size: 14px;
}
.sidebar.collapsed .btn-claude-md {
    display: none;
}
.app-version {
    margin-top: 15px;
    font-size: 11px;
    color: var(--gray-600);
    text-align: center;
    opacity: 0.7;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s;
    display: flex;
    flex-direction: column;
}
.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
}

.page-header {
    background: var(--bg-card);
    padding: 8px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background-color 0.3s, border-color 0.3s;
}
.page-header h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

/* Global filters in header */
.global-filters {
    display: flex;
    align-items: center;
    gap: 8px;
}
.global-filters form {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--gray-100);
    padding: 3px 6px;
    border-radius: 5px;
}
.filter-group label {
    font-size: 10px;
    color: var(--gray-500);
    white-space: nowrap;
}
.global-filters select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 11px;
    min-width: 120px;
}
.global-filters select:focus {
    border-color: var(--primary);
    outline: none;
}
.global-filters select.filter-active {
    background: #e3f2fd;
    border-color: var(--primary);
    font-weight: 600;
}
[data-theme="dark"] .global-filters select.filter-active {
    background: #1e3a5f;
    color: #93c5fd;
}
.btn-clear-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    text-decoration: none;
}
.btn-clear-filter:hover {
    background: #dc2626;
    text-decoration: none;
}

/* Filter banner */
.filter-banner {
    background: linear-gradient(90deg, #e3f2fd, #bbdefb);
    padding: 8px 25px;
    font-size: 12px;
    color: #1565c0;
    border-bottom: 1px solid #90caf9;
    position: sticky;
    top: 60px; /* Hauteur approximative du page-header */
    z-index: 49;
}
.filter-banner strong {
    color: #0d47a1;
}

/* Inline filter in page-actions */
.filter-inline {
    margin-left: auto;
}
.filter-inline select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
}

.page-content {
    padding: 25px;
}

.page-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow-color);
    margin-bottom: 20px;
    transition: background-color 0.3s, box-shadow 0.3s;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}
.card-body {
    padding: 20px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
}
.table tbody tr:hover {
    background: var(--bg-hover);
}
.table .text-right {
    text-align: right;
}
.table .actions {
    text-align: right;
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn:hover {
    background: var(--bg-hover);
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
}
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.btn-success:hover {
    background: #388e3c;
}
.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: white;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}
.btn-block {
    width: 100%;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.alert-success {
    background: #e8f5e9;
    border: 1px solid var(--success);
    color: #2e7d32;
}
.alert-danger {
    background: #ffebee;
    border: 1px solid var(--danger);
    color: #c62828;
}
.alert-warning {
    background: #fff3cd;
    border: 1px solid var(--warning);
    color: #856404;
}
.alert-info {
    background: #e3f2fd;
    border: 1px solid #2196F3;
    color: #1565c0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--gray-200);
    color: var(--gray-700);
}
.badge-success {
    background: #d1fae5;
    color: #065f46;
}
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}
.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Forms */
.form {
    max-width: 800px;
}
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}
.form-group {
    flex: 1;
}
.form-group.flex-2 {
    flex: 2;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-700);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, background-color 0.3s;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}
.form-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.checkbox-label input {
    width: auto;
}

.form h4 {
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
}

/* Filter form */
.filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
}
.search-form {
    display: flex;
    gap: 8px;
}
.search-form input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    width: 250px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.stats-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}
.stat-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px var(--shadow-color);
    transition: background-color 0.3s;
}
.stat-card.highlight {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}
.stat-card.success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}
.stat-card.info {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}
.stat-card.large {
    padding: 24px;
}
.stat-split {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
}
.stat-half {
    flex: 1;
    text-align: center;
}
.stat-half .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}
.stat-half .stat-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
}
.stat-divider {
    width: 1px;
    height: 50px;
    background: rgba(255,255,255,0.3);
}
.stat-icon {
    font-size: 32px;
}
.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
}
.stat-label {
    font-size: 14px;
    opacity: 0.8;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.dashboard-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}
.dashboard-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}
.dashboard-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}
.dashboard-grid .card.full-width {
    grid-column: 1 / -1;
}

/* Detail page */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px 16px;
}
.detail-list dt {
    font-weight: 500;
    color: var(--gray-500);
}
.detail-list dd {
    color: var(--gray-900);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Empty state */
.empty {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}
.empty.success {
    color: var(--success);
}

/* Auth page */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9)),
                url('/gestionimmo/static/img/login-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}
.auth-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 45px 40px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1);
}
.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}
.auth-logo-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 15px;
    display: block;
}
.auth-logo h1 {
    font-size: 26px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-logo p {
    color: var(--gray-500);
    font-size: 14px;
}
.auth-form .form-group {
    margin-bottom: 20px;
}
.auth-form .form-group label {
    font-weight: 500;
    color: #333;
}
.auth-form .form-group input {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-form .form-group input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    outline: none;
}
.auth-form .password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.auth-form .password-wrapper input {
    flex: 1;
    padding-right: 45px;
    width: 100%;
}
.auth-form .password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-form .password-toggle:hover {
    color: #667eea;
}
.auth-form .btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.auth-form .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}
.auth-footer {
    text-align: center;
    margin-top: 25px;
    color: var(--gray-500);
    font-size: 13px;
}

/* Error page */
.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.error-content {
    text-align: center;
}
.error-content h1 {
    font-size: 72px;
    color: var(--gray-300);
}
.error-content p {
    margin: 20px 0;
    color: var(--gray-500);
}

/* Info box */
.info-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 16px;
    margin: 16px 0;
}
.info-box h4 {
    margin: 0 0 10px;
    border: none;
    padding: 0;
}
.info-box ul {
    margin: 0;
    padding-left: 20px;
}
.info-box li {
    margin: 4px 0;
}

/* Utilities */
.text-muted {
    color: var(--gray-500);
}
.text-right {
    text-align: right;
}

/* Responsive */
/* Couleurs utilitaires */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--gray-500) !important; }

.bg-success { background-color: var(--success) !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-warning { background-color: var(--warning) !important; }

/* Stats grid amélioré */
.stats-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.danger { border-left: 4px solid var(--danger); }
.stat-card.warning { border-left: 4px solid var(--warning); }

/* Filter card */
.filter-card { margin-bottom: 20px; }
.filter-card .card-body { padding: 15px; }
.filter-form { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.filter-form .form-group { margin-bottom: 0; }
.filter-form select, .filter-form input { min-width: 120px; }

/* Responsive */
@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid.cols-3,
    .dashboard-grid.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-grid.cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid.cols-3,
    .dashboard-grid.cols-4 {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 900px) {
    .dashboard-grid.cols-2 {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        flex-direction: column;
    }
}

/* =====================================================
   MOBILE STYLES - Responsive Design
   ===================================================== */

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Hamburger Menu Button - touch-friendly */
.mobile-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    background: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 10px;
    gap: 5px;
    margin-right: 12px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.mobile-hamburger:active {
    background: var(--primary-dark);
    transform: scale(0.95);
}
.mobile-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

/* Tables Responsive - Mode Hybride */
.table-responsive-mobile {
    width: 100%;
}

/* Mobile Breakpoint */
@media (max-width: 768px) {
    /* Overlay visible */
    .mobile-overlay {
        display: block;
    }

    /* Hamburger visible */
    .mobile-hamburger {
        display: flex;
    }

    /* Sidebar as Drawer */
    .sidebar {
        width: var(--sidebar-width) !important;
        left: -260px;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
        z-index: 200;
    }
    .sidebar.mobile-open {
        left: 0;
    }
    .sidebar .label {
        display: inline !important;
    }
    .sidebar .user-info,
    .sidebar .logout-btn {
        display: block !important;
    }
    .sidebar.collapsed {
        width: var(--sidebar-width) !important;
    }

    /* Navigation items - touch-friendly */
    .nav-item {
        min-height: var(--touch-target-min);
        padding: 14px 20px;
    }
    .nav-item:active {
        background: var(--primary-dark);
    }

    /* Main content full width */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    .main-content.expanded {
        margin-left: 0 !important;
    }

    /* Page header compact */
    .page-header {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .page-header h2 {
        font-size: 16px;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Global filters stacked */
    .global-filters {
        width: 100%;
        order: 3;
    }
    .global-filters form {
        flex-direction: column;
        gap: 8px;
    }
    .global-filters .filter-group {
        width: 100%;
    }
    .global-filters select {
        width: 100%;
        min-width: unset;
    }

    /* Page content reduced padding */
    .page-content {
        padding: 15px;
    }

    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    .card-header {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-body {
        padding: 15px;
    }

    /* Stats grid 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stats-grid.cols-4,
    .stats-grid.cols-5 {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-card {
        padding: 12px;
    }
    .stat-card .value {
        font-size: 20px;
    }

    /* Tables - Mode Hybride avec touch-friendly rows */
    .table {
        font-size: var(--mobile-font-min);
    }
    .table th,
    .table td {
        padding: 12px 10px; /* Min 44px row height with content */
    }
    .table tbody tr {
        min-height: var(--touch-target-min);
    }
    /* Clickable rows need visual feedback */
    .table tbody tr[onclick],
    .table tbody tr[data-href],
    .table tbody tr.clickable {
        cursor: pointer;
    }
    .table tbody tr[onclick]:active,
    .table tbody tr[data-href]:active,
    .table tbody tr.clickable:active {
        background: var(--bg-hover);
    }

    /* Hide secondary columns on mobile */
    .table .hide-mobile,
    .table th.hide-mobile,
    .table td.hide-mobile {
        display: none;
    }

    /* Table wrapper scrollable */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    .table-wrapper table {
        min-width: 500px;
    }

    /* Action buttons - touch-friendly (min 44px height) */
    .btn {
        padding: 10px 16px;
        font-size: var(--mobile-font-min);
        min-height: var(--touch-target-min);
    }
    .btn-sm {
        padding: 8px 12px;
        font-size: var(--mobile-font-min);
        min-height: var(--touch-target-min);
    }
    .actions {
        gap: 6px;
    }

    /* Icon-only buttons need explicit size */
    .btn-icon,
    .actions .btn:not(:has(span)):not(:has(.label)) {
        min-width: var(--touch-target-min);
        padding: 10px;
    }

    /* Forms */
    .form-group {
        margin-bottom: 12px;
    }
    .form-group label {
        font-size: 13px;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 10px 12px;
    }

    /* Filter form */
    .filter-form {
        flex-direction: column;
        gap: 10px;
    }
    .filter-form .form-group {
        width: 100%;
    }
    .filter-form select,
    .filter-form input {
        width: 100%;
        min-width: unset;
    }

    /* Dashboard grid */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Modales full-screen */
    .glass-modal,
    .glass-modal-large {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 100vh !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    .glass-header {
        padding: 15px;
        border-radius: 0;
    }
    .glass-body {
        max-height: calc(100vh - 60px);
        padding: 15px;
    }
    .glass-footer {
        padding: 15px;
        border-radius: 0;
    }

    /* Popup backdrop */
    .popup-backdrop {
        padding: 0;
        align-items: stretch;
    }

    /* Box grid */
    .box-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* Hide toggle button on mobile (use hamburger instead) */
    .toggle-btn {
        display: none;
    }

    /* Sidebar footer */
    .sidebar-footer {
        padding: 15px;
    }
    .btn-save-zip {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Small mobile (iPhone SE, etc.) */
@media (max-width: 375px) {
    .page-header h2 {
        font-size: var(--mobile-font-min);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .box-grid {
        grid-template-columns: 1fr;
    }

    /* Tables - maintain readable font size */
    .table {
        font-size: var(--mobile-font-table);
    }
    .table th,
    .table td {
        padding: 10px 8px; /* Increased vertical padding for touch */
    }

    /* Buttons - keep touch-friendly even on small screens */
    .btn {
        padding: 10px 12px;
        font-size: var(--mobile-font-min);
        min-height: var(--touch-target-min);
        width: 100%; /* Full width on very small screens */
    }

    /* Stack action buttons vertically */
    .actions {
        flex-direction: column;
        width: 100%;
    }
    .actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Forms - larger touch targets */
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: var(--touch-target-min);
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Navigation links in sidebar */
    .nav-link {
        min-height: var(--touch-target-min);
        padding: 12px 16px;
    }
}

/* =====================================================
   DARK MODE TOGGLE
   ===================================================== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}
.theme-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-300);
}
.theme-toggle-label svg {
    width: 16px;
    height: 16px;
}
.theme-toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--gray-700);
    border-radius: 11px;
    transition: background 0.3s;
}
.theme-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}
[data-theme="dark"] .theme-toggle-switch {
    background: var(--primary);
}
[data-theme="dark"] .theme-toggle-switch::after {
    transform: translateX(18px);
}
.sidebar.collapsed .theme-toggle {
    display: none;
}

/* Dark mode adjustments for specific elements */
[data-theme="dark"] .info-box {
    background: var(--bg-hover);
    border-color: var(--border-color);
}
[data-theme="dark"] .filter-banner {
    background: linear-gradient(90deg, #1e3a5f, #1e40af);
    color: #93c5fd;
    border-color: #2563eb;
}
[data-theme="dark"] .filter-banner strong {
    color: #60a5fa;
}
[data-theme="dark"] .search-form input {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .filter-form select,
[data-theme="dark"] .filter-form input {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .form-group label {
    color: var(--text-secondary);
}

/* Dark mode for auth page */
[data-theme="dark"] .auth-page {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95)),
                url('/gestionimmo/static/img/login-bg.jpg');
    background-size: cover;
    background-position: center;
}
[data-theme="dark"] .auth-box {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
}
[data-theme="dark"] .auth-logo h1 {
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
[data-theme="dark"] .auth-logo p {
    color: var(--text-secondary);
}
[data-theme="dark"] .auth-footer {
    color: var(--text-muted);
}
[data-theme="dark"] .auth-form input {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .auth-form input:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.2);
}

/* Dark mode for gestion-import page */
[data-theme="dark"] .import-pdf-panel,
[data-theme="dark"] .filter-form-inline,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .mapping-popup-content,
[data-theme="dark"] .popup-content {
    background: var(--bg-card) !important;
    color: var(--text-primary);
}
[data-theme="dark"] .import-pdf-actions,
[data-theme="dark"] .import-pdf-footer,
[data-theme="dark"] .history-header,
[data-theme="dark"] .card-header,
[data-theme="dark"] .history-table thead th,
[data-theme="dark"] .filters-panel {
    background: var(--bg-hover) !important;
    color: var(--text-primary);
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .btn-close-popup {
    background: #475569;
}
[data-theme="dark"] .btn-close-popup:hover {
    background: #64748b;
}
[data-theme="dark"] .history-table tbody tr:hover,
[data-theme="dark"] #importTable tbody tr:hover {
    background: var(--bg-hover) !important;
}
[data-theme="dark"] .history-table tbody td,
[data-theme="dark"] #importTable tbody td {
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .stat-value {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .stat-label {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .history-count {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
[data-theme="dark"] .history-empty,
[data-theme="dark"] .history-empty .empty-hint {
    color: var(--text-muted);
}
[data-theme="dark"] .filter-form-inline label {
    color: var(--text-primary);
}
[data-theme="dark"] .filter-form-inline select,
[data-theme="dark"] .editable-cell input,
[data-theme="dark"] .editable-cell select {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .btn-reset {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-reset:hover {
    background: var(--danger);
    color: white;
}
[data-theme="dark"] .selected-count {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] #importTable tbody tr {
    background: var(--bg-card);
}
[data-theme="dark"] #importTable tbody tr:nth-child(even) {
    background: var(--bg-hover);
}
[data-theme="dark"] .table-container {
    background: var(--bg-card);
}
[data-theme="dark"] .editable-cell {
    color: var(--text-primary);
}
[data-theme="dark"] .stat-card-enhanced {
    background: var(--bg-card) !important;
}
[data-theme="dark"] .stat-card-enhanced.chart-card {
    background: linear-gradient(135deg, rgba(102,126,234,0.15), rgba(118,75,162,0.15)) !important;
}
[data-theme="dark"] .stat-card-enhanced.previsions-card {
    background: linear-gradient(135deg, rgba(23,162,184,0.2), rgba(32,201,151,0.2)) !important;
}
[data-theme="dark"] .stat-card-enhanced.previsions-card:hover {
    background: linear-gradient(135deg, rgba(23,162,184,0.3), rgba(32,201,151,0.3)) !important;
}

/* =====================================================
   Gestion Import - Layout fixe avec scroll tableau
   ===================================================== */

/* Page gestion-import: layout vertical avec scroll uniquement sur le tableau */
.gestion-import-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px); /* Hauteur viewport moins la navbar */
    overflow: hidden;
    padding-top: 4px;
}

/* Parties fixes en haut */
.gestion-import-page .stats-enhanced,
.gestion-import-page .search-filters-bar,
.gestion-import-page .filters-panel {
    flex-shrink: 0;
}

/* Card qui prend le reste de l'espace */
.gestion-import-page .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
}

/* Header fixe */
.gestion-import-page .card-header {
    flex-shrink: 0;
}

/* Body scrollable */
.gestion-import-page .card-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
}

/* Table container scrollable */
.gestion-import-page .table-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

/* Thead sticky dans le scroll */
.gestion-import-page #importTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8f9fa;
}

.gestion-import-page #importTable thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

[data-theme="dark"] .gestion-import-page #importTable thead,
[data-theme="dark"] .gestion-import-page #importTable thead th {
    background: var(--bg-card);
    border-color: var(--border-color);
}

/* ========================================
   Glass Overlay - Popups globaux
   ======================================== */
.glass-overlay {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.05);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}
.glass-overlay.active {
    display: flex !important;
    justify-content: center;
    align-items: flex-start;
}

/* Popup Bail - fond transparent sans flou */
#bailModal.glass-overlay {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ========================================
   Flags pour identifier les popups locaux/globaux
   ======================================== */
.popup-flag {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}
.popup-flag-local {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
}
.popup-flag-global {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: white;
}

/* ========================================
   Icône Alertes/Notifications (cloche header)
   ======================================== */
.alertes-bell-container {
    display: flex;
    align-items: center;
    margin-left: 12px;
    margin-right: auto;
    position: relative;
}

.alertes-bell-btn {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 8px;
    color: #555;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.alertes-bell-btn:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    transform: scale(1.1);
}

.alertes-bell-btn:active {
    transform: scale(0.95);
}

.alertes-badge-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 1.2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: alertes-pulse 2s infinite;
}

.alertes-badge-count.empty {
    display: none;
}

@keyframes alertes-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Dark mode support */
[data-theme="dark"] .alertes-bell-btn {
    color: #ccc;
}

[data-theme="dark"] .alertes-bell-btn:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
}

/* ========== TOAST NOTIFICATIONS GLOBALES ========== */
.gestion-toast {
    position: fixed; bottom: 20px; right: 20px; z-index: 50000;
    padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
    color: white; max-width: 500px; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    animation: gestionToastIn 0.3s ease, gestionToastOut 0.4s ease forwards;
    animation-duration: 0.3s, 0.4s;
}
.gestion-toast-icon { font-size: 16px; flex-shrink: 0; }
.gestion-toast-msg { flex: 1; }
.gestion-toast-success { background: linear-gradient(135deg, #2e7d32, #43a047); }
.gestion-toast-error { background: linear-gradient(135deg, #c62828, #e53935); }
.gestion-toast-info { background: linear-gradient(135deg, #1565c0, #1e88e5); }
.gestion-toast-warning { background: linear-gradient(135deg, #e65100, #f57c00); }
@keyframes gestionToastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes gestionToastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ========================================
   Popup Bail Détachable (floating, draggable, persistant)
   ======================================== */
