/* ============================================================
   MesBiens Immobiliers — app.css
   ============================================================ */

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

:root {
    --blue-dark:   #0C447C;
    --blue-mid:    #185FA5;
    --blue-light:  #378ADD;
    --blue-pale:   #E6F1FB;
    --green-bg:    #EAF3DE;
    --green-text:  #3B6D11;
    --green-dot:   #639922;
    --gray-dot:    #888780;
    --red-text:    #A32D2D;
    --red-bg:      #FCEBEB;
    --sidebar-w:   220px;
    --topbar-h:    52px;
    --radius-md:   8px;
    --radius-lg:   12px;
}

html, body { height: 100%; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; color: #1a1a1a; background: #f4f5f7; }

a { text-decoration: none; color: inherit; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-body { background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 50%, var(--blue-light) 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }

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

.login-card { background: #fff; border-radius: var(--radius-lg); padding: 2.5rem 2rem; border: 0.5px solid rgba(0,0,0,0.08); }

.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo-icon { width: 56px; height: 56px; background: linear-gradient(135deg, var(--blue-mid), var(--blue-light)); border-radius: var(--radius-lg); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.75rem; }
.login-logo-title { font-size: 18px; font-weight: 500; color: #1a1a1a; }
.login-logo-sub { font-size: 13px; color: #666; margin-top: 3px; }

.login-divider { height: 3px; background: linear-gradient(90deg, var(--blue-mid), var(--blue-light), #85B7EB); border-radius: 2px; margin-bottom: 1.75rem; }

.login-error { background: var(--red-bg); border: 0.5px solid #F09595; color: var(--red-text); border-radius: var(--radius-md); padding: 10px 14px; font-size: 13px; margin-bottom: 1rem; }

.login-field { margin-bottom: 1rem; }
.login-field label { display: block; font-size: 12px; font-weight: 500; color: #555; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }

.login-input-wrap { display: flex; align-items: center; border: 1px solid #d0d5dd; border-radius: var(--radius-md); background: #f9fafb; overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s; }
.login-input-wrap:focus-within { border-color: var(--blue-mid); background: #fff; box-shadow: 0 0 0 3px rgba(24,95,165,0.12); }

.login-input-prefix { display: flex; align-items: center; justify-content: center; width: 38px; height: 40px; flex-shrink: 0; border-right: 1px solid #e4e7ec; background: #f3f4f6; color: var(--blue-light); }

.login-input-wrap input { flex: 1; height: 40px; padding: 0 12px; border: none; background: transparent; color: #1a1a1a; font-size: 14px; outline: none; min-width: 0; }
.login-input-wrap input::placeholder { color: #aaa; }

.login-pw-toggle { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border: none; border-left: 1px solid #e4e7ec; background: #f3f4f6; cursor: pointer; color: var(--blue-mid); }

.login-row { display: flex; align-items: center; justify-content: space-between; margin: 0.75rem 0 1.25rem; }

.login-remember { display: flex; align-items: center; gap: 7px; font-size: 13px; color: #555; cursor: pointer; }
.login-remember input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--blue-mid); cursor: pointer; }

.login-forgot { font-size: 13px; color: var(--blue-mid); }
.login-forgot:hover { text-decoration: underline; }

.login-btn { width: 100%; height: 42px; background: linear-gradient(135deg, var(--blue-mid), var(--blue-light)); color: #fff; border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; cursor: pointer; letter-spacing: 0.02em; transition: opacity 0.15s; }
.login-btn:hover { opacity: 0.9; }
.login-btn:active { opacity: 0.85; transform: scale(0.99); }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.login-footer { text-align: center; margin-top: 1.5rem; font-size: 11px; color: #aaa; letter-spacing: 0.03em; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.layout { display: flex; min-height: 100vh; isolation: auto; }

/* ---- SIDEBAR ---- */
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: linear-gradient(180deg, var(--blue-dark) 0%, var(--blue-mid) 60%, var(--blue-light) 100%); display: flex; flex-direction: column; }

.sidebar-logo { padding: 1.25rem 1rem 1rem; border-bottom: 0.5px solid rgba(255,255,255,0.15); position: relative; }
.sidebar-close { display: none; position: absolute; top: 14px; right: 12px; background: none; border: none; cursor: pointer; color: rgba(255,255,255,0.7); padding: 4px; }

.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-sq { width: 34px; height: 34px; background: rgba(255,255,255,0.15); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-text { font-size: 13px; font-weight: 500; color: #fff; line-height: 1.3; }
.logo-sub { font-size: 11px; color: rgba(255,255,255,0.5); }

.nav-section { padding: 1rem 0.75rem 0.5rem; flex: 1; }
.nav-label { font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0.5rem; margin-bottom: 4px; }

.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-md); font-size: 13px; color: rgba(255,255,255,0.7); cursor: pointer; margin-bottom: 2px; transition: background 0.15s, color 0.15s; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 500; }

.sidebar-footer { padding: 1rem; border-top: 0.5px solid rgba(255,255,255,0.15); }
.user-row { display: flex; align-items: center; gap: 9px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; color: #fff; flex-shrink: 0; }
.user-name { font-size: 12px; font-weight: 500; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }
.logout-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #fff; background: rgba(239,83,80,0.3); border: 1px solid rgba(239,83,80,0.5); border-radius: 6px; cursor: pointer; padding: 6px 10px; width: 100%; margin-top: 8px; text-decoration: none; }
.logout-link:hover { background: rgba(239,83,80,0.45); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 199; }

/* ---- MAIN ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---- TOPBAR ---- */
.topbar { height: var(--topbar-h); background: #fff; border-bottom: 0.5px solid #e4e7ec; display: flex; align-items: center; padding: 0 1.5rem; justify-content: space-between; flex-shrink: 0; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 500; color: #1a1a1a; }
.topbar-date { font-size: 12px; color: #888; }
.hamburger { display: none; background: none; border: none; cursor: pointer; color: #555; padding: 4px; }

/* ---- CONTENT ---- */
.content { padding: 1.5rem; flex: 1; overflow-y: auto; }

.alert { padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 1rem; }
.alert-error   { background: var(--red-bg);   border: 0.5px solid #F09595; color: var(--red-text); }
.alert-success { background: var(--green-bg); border: 0.5px solid #97C459; color: var(--green-text); }

.welcome-text { font-size: 13px; color: #555; margin-bottom: 1.25rem; }
.welcome-text strong { font-weight: 500; color: #1a1a1a; }

/* ---- STATS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }

.stat-card { background: #fff; border: 0.5px solid #e4e7ec; border-top: 3px solid var(--blue-mid); border-radius: var(--radius-md); padding: 1rem; }
.stat-label { font-size: 12px; color: #666; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 500; color: var(--blue-mid); line-height: 1; }
.stat-sub { font-size: 11px; color: #999; margin-top: 4px; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-blue  { background: var(--blue-mid); }
.dot-green { background: var(--green-dot); }
.dot-gray  { background: var(--gray-dot); }

/* ---- TABLE ---- */
.section-title { font-size: 13px; font-weight: 500; color: #1a1a1a; margin-bottom: 0.75rem; }

.data-table-wrap { background: #fff; border: 0.5px solid #e4e7ec; border-radius: var(--radius-lg); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead tr { background: #f9fafb; }
.data-table th { padding: 9px 1rem; text-align: left; font-size: 11px; font-weight: 500; color: #888; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 0.5px solid #e4e7ec; white-space: nowrap; }
.data-table th:nth-child(5) { min-width: 90px; }
.data-table th:nth-child(7) { min-width: 200px; }
.data-table td:nth-child(5) { min-width: 90px; }
.data-table td:nth-child(7) { min-width: 200px; }
.data-table td { padding: 10px 1rem; border-bottom: 0.5px solid #f0f0f0; color: #1a1a1a; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }

.user-cell { display: flex; align-items: center; gap: 9px; }
.user-avatar-sm { width: 28px; height: 28px; border-radius: 50%; background: var(--blue-pale); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 500; color: var(--blue-dark); flex-shrink: 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap; min-width: 70px; justify-content: center; }
.badge-admin { background: var(--blue-pale);  color: var(--blue-dark); }
.badge-green { background: var(--green-bg);   color: var(--green-text); }
.badge-gray  { background: #f1f1ee;           color: #5f5e5a; }

.text-muted  { color: #888; }
.text-center { text-align: center; }

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; left: 0; height: 100vh; transform: translateX(-100%); transition: transform 0.25s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }
    .sidebar-overlay.open { display: block; }
    .hamburger { display: flex; }
    .topbar-date { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) { display: none; }
}

@media (max-width: 480px) {
    .content { padding: 1rem; }
    .login-card { padding: 2rem 1.25rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* ============================================================
   ADMIN — GESTION UTILISATEURS
   ============================================================ */

.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 12px; }

.btn-primary { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; background: #4CAF50; color: #fff; border: none; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { height: 38px; padding: 0 16px; background: #fff; color: #555; border: 1px solid #d0d5dd; border-radius: var(--radius-md); font-size: 13px; cursor: pointer; }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; background: #EF5350; color: #fff; border: none; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 12px; background: #FFA726; color: #fff; border: none; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn-warning:hover { opacity: 0.9; }
.btn-activate { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 12px; background: #4CAF50; color: #fff; border: none; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn-activate:hover { opacity: 0.9; }

.btn-toggle { background: none; border: none; cursor: pointer; color: var(--color-text-secondary); padding: 4px; display: flex; align-items: center; border-radius: 4px; }
.btn-toggle:hover { color: #185FA5; background: #E6F1FB; }
.btn-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Modal ---- */
.modal-overlay { display: none; visibility: hidden; position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.45); z-index: 9999; align-items: center; justify-content: center; padding: 1rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-overlay.open { display: flex; visibility: visible; }

.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 520px; border: 0.5px solid #e4e7ec; overflow: hidden; }

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem 1rem; border-bottom: 0.5px solid #e4e7ec; }
.modal-title { font-size: 16px; font-weight: 500; color: #1a1a1a; }
.modal-close { background: none; border: none; cursor: pointer; color: #888; padding: 4px; display: flex; }
.modal-close:hover { color: #1a1a1a; }

.modal-alert { margin: 1rem 1.5rem 0; padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; }
.modal-alert-error   { background: #FCEBEB; border: 0.5px solid #F09595; color: #A32D2D; }
.modal-alert-success { background: #EAF3DE; border: 0.5px solid #97C459; color: #3B6D11; }

.modal form { padding: 1.25rem 1.5rem 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 1.25rem 1.5rem 1.5rem; border-top: 0.5px solid #f0f0f0; margin-top: 0; }

/* ---- Champs formulaire modal ---- */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: 12px; font-weight: 500; color: #555; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.form-field input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid #d0d5dd; border-radius: var(--radius-md); background: #f9fafb; color: #1a1a1a; font-size: 14px; outline: none; }
.form-field input:focus { border-color: #185FA5; background: #fff; box-shadow: 0 0 0 3px rgba(24,95,165,0.12); }

.field-hint { font-size: 10px; color: #999; font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px; }

.pw-input-wrap { position: relative; }
.pw-input-wrap input { padding-right: 36px; }
.pw-toggle-sm { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: #888; display: flex; padding: 2px; }
.pw-toggle-sm:hover { color: #185FA5; }

@media (max-width: 480px) {
    .form-row-2 { grid-template-columns: 1fr; }
    .modal { max-width: 100%; }
}

/* ============================================================
   MAINTENANCE
   ============================================================ */
.badge-danger  { background: #FCEBEB; color: #A32D2D; }
.dot-red       { background: #E24B4A; }
.badge-warning { background: #FAEEDA; color: #633806; }

.maint-alert { padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }
.maint-alert-success { background: #EAF3DE; border: 0.5px solid #97C459; color: #3B6D11; }
.maint-alert-error   { background: #FCEBEB; border: 0.5px solid #F09595; color: #A32D2D; }
.maint-alert-info    { background: #E6F1FB; border: 0.5px solid #85B7EB; color: #0C447C; }
