/* SNG Finances - Styles */
:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --accent: #ed8936;
    --success: #38a169;
    --danger: #e53e3e;
    --bg: #f7fafc;
    --card: #ffffff;
    --text: #2d3748;
    --text-muted: #718096;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }

/* Login */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: var(--card); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { color: var(--primary); font-size: 1.5rem; margin-bottom: 5px; }
.login-header p { color: var(--text-muted); font-size: 0.9rem; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }
.login-form input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.login-form input:focus { outline: none; border-color: var(--primary); }
.forgot-link { display: block; text-align: center; margin-top: 15px; color: var(--primary); text-decoration: none; font-size: 0.9rem; }
.forgot-link:hover { text-decoration: underline; }

/* Buttons */
.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; text-decoration: none; transition: background 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 6px 12px; font-size: 0.875rem; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c53030; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; }
.alert-error { background: #fed7d7; color: #c53030; }
.alert-success { background: #c6f6d5; color: #276749; }

/* Page layout - contenu centré */
.page-wrapper { max-width: 1200px; margin: 0 auto; width: 100%; }

/* Dashboard */
.dashboard-header { background: var(--primary); color: white; padding: 12px 24px; }
.dashboard-header .page-wrapper { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: nowrap; }
.header-left { flex: 0 0 auto; min-width: 0; }
.header-society { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-society select { padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.15); color: white; font-size: 0.9rem; cursor: pointer; }
.header-society select option { background: #1a365d; color: white; }
.header-right { display: flex; align-items: center; gap: 15px; flex: 1; justify-content: flex-end; min-width: 0; flex-shrink: 1; }
.dashboard-header a { color: rgba(255,255,255,0.9); text-decoration: none; padding: 4px 8px; border-radius: 4px; font-size: 0.9rem; }
.dashboard-header a:hover { background: rgba(255,255,255,0.15); color: white; }
.header-brand a { font-weight: 700; font-size: 1.1rem; }
.header-nav { display: flex; gap: 5px; flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; }
.header-user { position: relative; font-size: 0.9rem; min-width: 0; flex-shrink: 1; }
.header-user-btn { background: none; border: none; color: rgba(255,255,255,0.9); font-size: inherit; cursor: pointer; padding: 4px 8px; border-radius: 4px; font-family: inherit; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; text-align: left; }
.header-user-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.header-user-menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; min-width: 160px; background: var(--card); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.2); padding: 6px 0; z-index: 1000; }
.header-user-menu a { display: block; padding: 10px 16px; color: var(--text) !important; text-decoration: none; font-size: 0.9rem; }
.header-user-menu a:hover { background: var(--bg); color: var(--text) !important; }
.header-user.dropdown.is-open .header-user-menu { display: block; }

.dashboard-main { max-width: 1400px; margin: 0 auto; padding: 24px; }
.dashboard-title { margin-bottom: 24px; font-size: 1.5rem; color: var(--primary); }

/* Carte filtre dashboard - évite le débordement horizontal */
.dashboard-filter-card { overflow-x: hidden; }
.dashboard-filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; max-width: 100%; }
.dashboard-filter-form .form-group { min-width: 0; flex: 0 1 auto; }
.dashboard-filter-form .filter-block,
.dashboard-filter-form .filter-comp { min-width: 0; flex-wrap: wrap; }
.dashboard-filter-form input[type="date"],
.dashboard-filter-form select { min-width: 0; max-width: 100%; }

/* Cards */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-bottom: 30px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.card .value.positive { color: var(--success); }
.card .value.negative { color: var(--danger); }

/* Tables */
.table-container { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
tr:hover { background: #fafafa; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* Forms */
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* Page layout */
.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: #e6fffa; color: #234e52; }
.badge-super { background: #fef3c7; color: #92400e; }

/* Logs */
.logs-table .details { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logs-table .username { font-weight: 500; }

.roles-checkboxes { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.roles-checkboxes label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: normal; }
.form-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.societies-perms-list { display: flex; flex-direction: column; gap: 10px; max-height: 280px; overflow-y: auto; }
.society-perm-row { display: flex; align-items: center; gap: 16px; }
.society-perm-row label { flex: 0 0 140px; font-weight: 500; }
.society-perm-row select { flex: 0 0 140px; padding: 8px 10px; }

/* User form - sections ergonomiques */
.user-form-sections { display: grid; grid-template-columns: 1fr 1.5fr; gap: 32px; margin-bottom: 24px; }
.user-form-sections.user-form-edit { grid-template-columns: 1fr; }
@media (max-width: 900px) { .user-form-sections { grid-template-columns: 1fr; } }
.user-form-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.user-form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: 0.9rem; color: var(--primary); margin-bottom: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.roles-groups { display: flex; flex-wrap: wrap; gap: 20px 32px; }
.roles-group { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 140px; }
.roles-group-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.roles-group .roles-checkboxes { gap: 8px 16px; }
.societies-quick-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.btn-society-batch { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-society-batch:hover { background: var(--border); }
.societies-perms-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px 32px; max-height: 280px; overflow-y: auto; padding: 12px 0; }
.societies-perms-table .society-perm-row { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 8px 0; }
.societies-perms-table .society-name { flex: none; margin: 0; font-weight: 500; }
.societies-perms-table .society-perm-select { width: 100%; min-width: 140px; padding: 10px 12px; }
.user-form-societies .form-section-title { margin-bottom: 16px; }
.user-form-societies .form-hint { margin-bottom: 16px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.modal-overlay.is-open { opacity: 1; visibility: visible; }
.modal { background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); padding: 0 8px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }

/* PDF Export - styles pour une capture lisible */
#dashboard-export.pdf-export-mode {
    min-width: 794px;
    font-size: 14px;
}
#dashboard-export.pdf-export-mode .card h3 { font-size: 1rem; }
#dashboard-export.pdf-export-mode .card .value { font-size: 2rem; }
#dashboard-export.pdf-export-mode .card small { font-size: 0.95rem; }
#dashboard-export.pdf-export-mode th, #dashboard-export.pdf-export-mode td { padding: 14px 18px; font-size: 0.95rem; }
#dashboard-export.pdf-export-mode th { font-size: 0.95rem; }
#dashboard-export.pdf-export-mode h3 { font-size: 1.1rem; }
#dashboard-export.pdf-export-mode h4 { font-size: 1rem; }
#dashboard-export.pdf-export-mode .table-container { font-size: 0.95rem; }
#dashboard-export.pdf-export-mode .chart-container { height: 400px !important; }

/* Hamburger menu - mobile */
.header-hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 44px; height: 44px; padding: 10px; background: none; border: none; cursor: pointer; color: white; margin-left: auto; -webkit-tap-highlight-color: transparent; }
.header-hamburger span { display: block; width: 22px; height: 2px; background: currentColor; border-radius: 1px; transition: transform 0.3s, opacity 0.3s; }
.header-hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.header-hamburger.is-open span:nth-child(2) { opacity: 0; }
.header-hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.header-mobile-menu { display: none; position: fixed; top: 0; right: 0; width: min(320px, 85vw); height: 100vh; background: var(--card); box-shadow: -4px 0 20px rgba(0,0,0,0.2); z-index: 1001; flex-direction: column; overflow-y: auto; transform: translateX(100%); transition: transform 0.3s ease; }
.header-mobile-menu.is-open { transform: translateX(0); }
.mobile-menu-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); background: var(--primary); color: white; }
.mobile-user-info { font-weight: 600; font-size: 0.95rem; }
.mobile-menu-close { background: none; border: none; color: white; font-size: 1.8rem; cursor: pointer; padding: 0 8px; line-height: 1; }
.mobile-menu-nav { display: flex; flex-direction: column; padding: 16px 0; }
.mobile-menu-nav a { padding: 14px 20px; color: var(--text); text-decoration: none; font-size: 1rem; border-bottom: 1px solid var(--border); }
.mobile-menu-nav a:hover { background: var(--bg); }
.mobile-menu-user { display: flex; flex-direction: column; padding: 16px 0; margin-top: auto; border-top: 1px solid var(--border); }
.mobile-menu-user a { padding: 14px 20px; color: var(--text); text-decoration: none; font-size: 0.95rem; }
.mobile-menu-user a:hover { background: var(--bg); }
.header-mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; pointer-events: none; }
.header-mobile-overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

@media (max-width: 900px) {
    .header-hamburger { display: flex; }
    .header-right { display: none; }
    .header-mobile-menu { display: flex; }
    .header-mobile-overlay { display: block; }
    .header-inner { flex-wrap: wrap; }
    .header-society select { max-width: 140px; font-size: 0.85rem; }
    .dashboard-main { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .btn { min-height: 44px; padding: 10px 16px; }
}

@media (min-width: 901px) {
    .header-hamburger { display: none !important; }
    .header-mobile-menu,
    .header-mobile-overlay {
        display: none !important;
        visibility: hidden !important;
    }
    .header-mobile-menu.is-open { transform: translateX(100%); }
}

/* Responsive général */
@media (max-width: 768px) {
    .dashboard-header .page-wrapper { padding: 0 16px; }
    .table-container { font-size: 0.9rem; }
    th, td { padding: 10px 12px; }
    .card { padding: 16px; }
}
