﻿/* ========== RESET & VARIABLES ========== */
:root {
    --primary: #4F6EF7;
    --primary-light: #7B93FA;
    --primary-dark: #3A54D4;
    --accent: #FFB74D;
    --accent-light: #FFCC80;
    --danger: #EF5350;
    --success: #66BB6A;
    --warning: #FFA726;
    --info: #42A5F5;
    --bg: #F0F2F8;
    --surface: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #94A3B8;
    --border: #E2E8F0;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.10);
    --radius: 14px;
    --radius-sm: 10px;
    --transition: 0.2s ease;
    --sidebar-width: 240px;
    --header-height: 64px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    color: var(--text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform var(--transition);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px;
    font-weight: 700; font-size: 1.1rem;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
}
.sidebar-brand i { font-size: 1.4rem; color: var(--primary); }
.sidebar-nav { list-style: none; padding: 12px 10px; flex: 0 0 auto; }
.sidebar-nav li { margin-bottom: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-item:hover { background: #F1F5F9; color: var(--text); }
.nav-item.active { background: #EEF2FF; color: var(--primary); font-weight: 600; }
.nav-item i { width: 20px; text-align: center; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 14px; }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.sidebar-footer .nav-item { font-size: 0.85rem; }

/* ── Recherche dans la sidebar ── */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 8px 8px 4px;
    padding: 6px 10px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}
.sidebar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,.1);
}
.sidebar-search i { color: var(--text-secondary); font-size: 0.8rem; flex-shrink: 0; }
.sidebar-search input {
    border: none; background: transparent; outline: none;
    font-size: 0.82rem; color: var(--text); width: 100%;
}
.sidebar-search input::placeholder { color: var(--text-secondary); }

/* ── Filtres intervenants dans la sidebar ── */
.sidebar-filters {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
    border-top: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-filters-title {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 6px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.sidebar-filter-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
}
.sidebar-filter-chip:hover { background: var(--bg); }
.sidebar-filter-chip input[type="checkbox"] { display: none; }
.sidebar-filter-chip:has(input:checked) {
    color: var(--text);
    font-weight: 600;
}
.sidebar-filter-chip:has(input:checked) .chip-dot {
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--chip-color, var(--primary));
}
.sidebar-filter-chip:has(input:not(:checked)) { opacity: .45; }
.sidebar-filter-chip .chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.dark-mode .sidebar-filters-title { background: var(--surface); }
body.dark-mode .sidebar-filter-chip:hover { background: #1E293B; }
body.dark-mode .sidebar-search { background: #1E293B; border-color: #334155; }
body.dark-mode .sidebar-search input { color: #F1F5F9; }

/* ── Documentation sidebar ── */
.sidebar-docs {
    padding: 4px 0 2px;
    border-top: 1px solid rgba(255,255,255,.1);
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.sidebar-docs-title {
    padding: 4px 12px 2px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .8px;
    opacity: .45;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-docs-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all .15s;
    border-radius: 6px;
    margin: 1px 4px;
}
.sidebar-docs-link:hover {
    background: var(--bg);
    color: var(--primary);
    border-left-color: var(--primary);
}
.sidebar-docs-link i { width: 14px; text-align: center; font-size: 0.75rem; opacity: .8; }

/* ── Bas de sidebar : utilisateur connecté + version + serveurs ── */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 4px 14px 6px;
    flex-shrink: 0;
}
.sidebar-server-status {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}
.srv-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.srv-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9e9e9e;
    flex-shrink: 0;
    transition: background .3s;
}
.sidebar-version {
    font-size: 0.68rem;
    color: var(--text-secondary);
    opacity: .7;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 8px;
    border-top: 1px solid var(--border);
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 28px;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

/* ========== SIDEBAR COLLAPSE (desktop) ========== */
.sidebar-collapse-btn {
    position: fixed;
    left: var(--sidebar-width);
    top: 50%;
    transform: translateY(-50%) translateX(-50%);
    z-index: 101;
    width: 18px;
    height: 48px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.65rem;
    transition: left var(--transition), background var(--transition), color var(--transition);
    box-shadow: 2px 0 6px rgba(0,0,0,.08);
    padding: 0;
}
.sidebar-collapse-btn:hover { background: var(--primary); color: #fff; }
body.sidebar-hidden .sidebar-collapse-btn {
    left: 0;
    transform: translateY(-50%);
    border-left: 1px solid var(--border);
}
body.sidebar-hidden .sidebar { transform: translateX(-100%); }
body.sidebar-hidden .main-content { margin-left: 0; }

/* Préférence auto-masquage dans le footer sidebar */
.sidebar-auto-pref {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.66rem;
    color: var(--text-secondary);
    opacity: .75;
}
.sidebar-pref-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.62rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.sidebar-pref-toggle.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.mobile-menu-btn {
    display: none;
    background: none; border: none;
    font-size: 1.4rem; color: var(--text);
    cursor: pointer; padding: 8px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: 0.875rem;
    cursor: pointer; border: 1.5px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: #F8FAFC; border-color: #CBD5E1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; line-height: 1; }
.btn-full { width: 100%; justify-content: center; }

/* ========== CARDS ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-icon { font-size: 1.8rem; color: var(--primary); margin-bottom: 12px; }
.card h3 { font-size: 1rem; margin-bottom: 6px; }
.card p { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 14px; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-weight: 600; font-size: 0.8rem;
    color: var(--text-secondary); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.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(79,110,247,.12);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-row { display: flex; align-items: center; gap: 12px; }
.checkbox-label { font-weight: 500; font-size: 0.85rem; display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); text-transform: none; letter-spacing: 0; }
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--primary); }
.admin-form fieldset {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 18px; background: #fff;
}
.admin-form legend {
    font-weight: 700; font-size: 0.9rem; padding: 0 12px;
    color: var(--primary);
}

/* ========== TABLES ========== */
.table-responsive { overflow-x: auto; }
.admin-table {
    width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.admin-table th {
    text-align: left; padding: 10px 12px;
    font-weight: 700; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-secondary); border-bottom: 2px solid var(--border);
}
.admin-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tr:hover td { background: #F8FAFC; }
/* Tri des colonnes */
.admin-table.sortable th[data-sort] { cursor: pointer; user-select: none; }
.admin-table.sortable th[data-sort]:hover { color: var(--primary); }
.admin-table.sortable th[data-sort]::after { content: ' ⇅'; font-size: .65rem; opacity: .35; }
.admin-table.sortable th[data-sort].sort-asc::after { content: ' ▲'; opacity: 1; color: var(--primary); }
.admin-table.sortable th[data-sort].sort-desc::after { content: ' ▼'; opacity: 1; color: var(--primary); }
/* Table utilisateurs compacte (une ligne par utilisateur) */
.users-table { font-size: .8rem; }
.users-table th { padding: 6px 8px; }
.users-table td { padding: 4px 8px; white-space: nowrap; vertical-align: middle; }
.users-table .col-trunc { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.user-color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
}
.badge-admin { background: #EEF2FF; color: var(--primary); }
.badge-user { background: #F1F5F9; color: var(--text-secondary); }
.badge-info { background: #E0F2FE; color: #0369A1; }

/* ========== MODALS ========== */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius); width: 90%; max-width: 540px;
    max-height: 96vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
/* Description dans les cartes de résultats de recherche */
.search-result-desc {
    flex: 0 0 40%;
    min-width: 0;
    padding: 10px 14px;
    border-left: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.55;
    white-space: pre-wrap;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
}
.search-result-desc:empty::after {
    content: '—';
    opacity: 0.3;
}
.modal-sm { max-width: 400px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 18px; border-bottom: 1px solid var(--border);
    font-weight: 700;
}
.modal-header h3 { font-size: 0.95rem; }
.modal-body { padding: 12px 18px; }
.modal-footer {
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
    padding: 10px 18px; border-top: 1px solid var(--border);
}
/* Formulaire compact dans modal RDV */
.modal .form-group { margin-bottom: 8px; }
.modal .form-group label { margin-bottom: 2px; font-size: 0.75rem; }
.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea { padding: 6px 10px; font-size: 0.86rem; }
.modal .form-row-2 { gap: 10px; }
.modal .btn { padding: 6px 14px; font-size: 0.84rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }

/* ========== FLASH ========== */
.flash-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 300px;
    pointer-events: none;
}
.flash {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-weight: 500; display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
    pointer-events: auto;
    box-shadow: var(--shadow-md);
}
.flash-success { background: #E8F5E9; color: #2E7D32; border: 1px solid #C8E6C9; }
.flash-error { background: #FFEBEE; color: #C62828; border: 1px solid #FFCDD2; }
.flash-warning { background: #FFF3E0; color: #E65100; border: 1px solid #FFE0B2; }
.flash-info { background: #E3F2FD; color: #1565C0; border: 1px solid #BBDEFB; }
.flash-close { cursor: pointer; opacity: 0.7; }

/* ========== TABS ========== */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab-btn {
    background: none; border: none; padding: 10px 18px;
    font-weight: 600; font-size: 0.85rem; color: var(--text-secondary);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== PLANNING ========== */
.planning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}
.calendar-toolbar h3 {
    font-size: 0.95rem;
    font-weight: 700;
    min-width: 200px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.week-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(79,110,247,.1);
    border: 1px solid rgba(79,110,247,.25);
    border-radius: 10px;
    padding: 1px 7px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.calendar-toolbar .btn { padding: 5px 11px; }
.view-btn {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.view-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79,110,247,.3);
}
.view-btn:not(.active):hover {
    background: #F1F5F9;
    color: var(--text);
}
/* ========== DAY / WEEK VIEWS ========== */
.day-view, .week-view {
    display: flex;
    position: relative;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.week-header {
    display: grid;
    grid-template-columns: 52px repeat(7, minmax(120px, 1fr));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    padding: 10px 0;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    box-shadow: var(--shadow);
}
.week-header > div:first-child {
    min-width: 52px;
}
.day-column {
    flex: 1;
    min-width: 120px;
    position: relative;
    border-left: 1px solid var(--border);
}
.week-col {
    flex: 1;
    min-width: 120px;
    position: relative;
    border-right: 1px solid var(--border);
}
.week-col:last-child {
    border-right: none;
}
.day-hours {
    display: flex;
    flex-direction: column;
    min-width: 52px;
    flex-shrink: 0;
    background: #FAFBFC;
    border-right: 2px solid var(--border);
}
.hour-slot {
    height: 14px;
    min-height: 14px;
    display: flex;
    align-items: flex-start;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-bottom: 1px solid #E8ECF1;
    cursor: pointer;
    transition: background 0.15s ease;
    padding: 1px 3px 0;
    position: relative;
}
.hour-slot:hover {
    background: rgba(79, 110, 247, 0.04);
}
.hour-slot.slot-hour {
    font-weight: 700;
    color: var(--text-secondary);
}
.hour-slot.slot-quarter {
    border-bottom: 1px dashed #E2E8F0;
}
.hour-slot:active {
    background: rgba(79, 110, 247, 0.1);
}
.day-column .hour-slot,
.week-col .hour-slot {
    min-height: 14px;
    border-bottom: 1px solid #E2E8F0;
    border-left: none;
}
.day-column .hour-slot:nth-child(4n),
.week-col .hour-slot:nth-child(4n) {
    border-bottom: 2px solid #D0D5DD;
}
.calendar-container {
    width: 100%;
    overflow-x: auto;
}

/* ========== MONTH VIEW ========== */
.month-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 10px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow);
}
.month-header > div {
    padding: 6px 0;
    border-right: 1px solid var(--border);
}
.month-header > div:last-child {
    border-right: none;
}
.month-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.month-day {
    min-height: 110px;
    padding: 6px 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
    background: #fff;
}
.month-day:nth-child(7n) {
    border-right: none;
}
.month-day:hover {
    background: #F8FAFC;
}
.month-day.muted {
    background: #FAFBFC;
    opacity: 0.5;
}
.month-day.today {
    background: #EEF2FF;
}
.month-day.today .day-number {
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.day-number {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--text);
    display: inline-block;
    padding: 2px;
}
.month-apt {
    padding: 3px 6px;
    border-radius: 4px;
    color: #fff;
    font-size: 0.68rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 500;
    border-left: 2px solid rgba(255,255,255,.3);
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.month-apt:hover {
    opacity: 0.85;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

/* ========== CONGÉS DANS LE PLANNING ========== */
.apt-card-absence { cursor: default; }
.apt-card-absence:hover { filter: brightness(1.05); }
.month-apt-absence { border-left-color: rgba(255,255,255,.5) !important; }

/* ========== ABSENCE CALENDAR ========== */
.absence-calendar .month-day {
    min-height: 48px;
    cursor: pointer;
}
.absence-calendar .month-day:hover {
    background: #F0F4FF !important;
}
.absence-label {
    font-size: 0.6rem;
    margin-top: 2px;
}
.calendar-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* ========== SEARCH RESULTS ========== */
.search-results {
    padding: 16px 20px;
    overflow-y: auto;
    max-height: calc(100vh - 160px);
}
.search-results-header {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.search-results-header strong {
    color: var(--text-primary);
}
.search-clear-hint {
    font-size: 0.75rem;
    opacity: 0.6;
}
.search-result-item {
    display: flex;
    gap: 0;
    align-items: stretch;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.search-result-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.search-result-color {
    width: 5px;
    flex-shrink: 0;
}
.search-result-body {
    flex: 1;
    padding: 10px 14px;
}
.search-result-date {
    font-size: 0.74rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
    text-transform: capitalize;
}
.search-result-title {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.search-result-metas {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.search-result-metas span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 180px;
    color: var(--text-secondary);
    gap: 10px;
    font-size: 0.88rem;
}
.search-empty i {
    font-size: 2rem;
    opacity: 0.35;
}

/* ========== APT CARD ========== */
.apt-card {
    position: absolute;
    border-radius: 6px;
    padding: 2px 5px;
    cursor: grab;
    overflow: hidden;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    transition: box-shadow 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
    border-left: 3px solid rgba(255,255,255,.35);
    z-index: 2;
    min-height: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.apt-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
    transform: scale(1.02);
    z-index: 10;
}
.apt-card.dragging {
    opacity: 0.4;
    cursor: grabbing !important;
    transform: none;
}
.apt-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    border-radius: 0 0 4px 4px;
    background: rgba(255,255,255,0.25);
    opacity: 0;
    transition: opacity 0.15s;
}
.apt-card:hover .apt-resize-handle {
    opacity: 1;
}
.apt-card.resizing {
    cursor: ns-resize !important;
    transform: none !important;
    z-index: 20;
    transition: none;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.apt-card.resizing .apt-resize-handle {
    opacity: 1;
}
.week-col.drag-over,
.day-column.drag-over {
    background: rgba(79,110,247,0.05);
}
.apt-line1 {
    font-size: 0.63rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.92;
    line-height: 1.4;
}
.apt-time {
    opacity: 0.8;
    font-weight: 700;
}
.apt-line2 {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.72rem;
    line-height: 1.3;
}
.apt-line3 {
    font-size: 0.6rem;
    opacity: 0.78;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
    line-height: 1.3;
}
.apt-card.status-cancelled {
    opacity: 0.45;
    text-decoration: line-through;
}
.apt-card.status-pending {
    opacity: 0.75;
    border-left-color: var(--warning);
}

/* RDV courts (≤ 30 min) : affichage condensé sur une seule ligne */
.apt-card-compact {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
}
.apt-card-compact .apt-time {
    font-size: 0.62rem;
    font-weight: 700;
    opacity: 0.9;
    flex-shrink: 0;
}
.apt-compact-title {
    font-size: 0.68rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.apt-card-compact .apt-status-icon {
    font-size: 0.55rem;
    flex-shrink: 0;
}
.distance-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.76rem;
    font-weight: 600;
    color: #1565c0;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 20px;
    padding: 2px 9px;
}
.apt-status-icon {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 0.58rem;
    line-height: 1;
    pointer-events: none;
    z-index: 3;
    text-shadow: 0 0 3px rgba(0,0,0,.4);
}
.apt-status-icon.pending   { color: #FFE082; }
.apt-status-icon.confirmed { color: #A5D6A7; }

/* ========== POPUP BULLE ========== */
.apt-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    background: #1E293B;
    color: #F1F5F9;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.5;
    box-shadow: 0 8px 30px rgba(0,0,0,.35);
    max-width: 340px;
    min-width: 180px;
    white-space: normal;
    pointer-events: auto;
    border: 1px solid #334155;
}
.apt-popup-time {
    font-size: 0.7rem;
    opacity: 0.65;
    margin-bottom: 4px;
}
.apt-popup-designation {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 7px;
    padding-bottom: 7px;
    border-bottom: 1px solid #334155;
}
.apt-popup-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.78rem;
    margin-bottom: 2px;
}
.apt-popup-row i {
    opacity: 0.55;
    width: 13px;
    text-align: center;
    flex-shrink: 0;
}
.apt-popup-desc {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid #334155;
    font-size: 0.76rem;
    opacity: 0.85;
    white-space: pre-wrap;
    word-break: break-word;
}
.apt-popup-files {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.apt-popup-files-label {
    font-size: 0.7rem;
    opacity: 0.55;
    margin-bottom: 2px;
}
.apt-popup-file {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #60A5FA;
    text-decoration: none;
    font-size: 0.76rem;
}
.apt-popup-file:hover {
    text-decoration: underline;
    color: #93C5FD;
}
.apt-popup-meta {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.72rem;
    opacity: 0.65;
}
.apt-popup-meta i {
    width: 13px;
    margin-right: 4px;
    opacity: 0.7;
}
#aptMetaInfo {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
#aptMetaInfo i {
    margin-right: 4px;
    opacity: 0.7;
}

/* ========== FILTER CHIP WITH COLOR ========== */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 6px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.filter-chip:hover {
    background: #F8FAFC;
    border-color: var(--primary-light);
}
.filter-chip input[type="checkbox"] {
    display: none;
}
.filter-chip:has(input:checked) {
    background: #EEF2FF;
    border-color: var(--primary);
}
.chip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.1);
}
.chip-dot-pick {
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.chip-dot-pick:hover {
    transform: scale(1.5);
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.25);
}

body.dark-mode .hour-slot.slot-hour {
    border-color: #475569;
}
body.dark-mode .hour-slot.slot-quarter {
    border-color: #334155;
}
body.dark-mode .hour-slot:hover {
    background: rgba(255,255,255,.03);
}
body.dark-mode .filter-chip {
    background: #1E293B;
    border-color: #475569;
}
body.dark-mode .filter-chip:hover {
    background: #334155;
}
body.dark-mode .filter-chip:has(input:checked) {
    background: #1E3A5F;
    border-color: var(--primary);
}
body.dark-mode .apt-popup {
    background: #0F172A;
    border-color: #334155;
}

/* ========== FORM DATE/TIME FIX ========== */
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}
.datetime-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
}
.datetime-row input[type="date"] {
    flex: 1;
    min-width: 110px;
    border: none;
    border-right: 1px solid var(--border);
    padding: 2px 8px 2px 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    outline: none;
}
.datetime-row .time-row {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}
.datetime-row .time-row select {
    width: 46px;
    padding: 2px 2px;
    border: none;
    background: transparent;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    text-align: center;
}
.datetime-row .time-row span {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.datetime-row:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}

/* ========== AUTOCOMPLETE FIX ========== */
.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 300;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
}
.autocomplete-dropdown.active {
    display: block;
}
.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.autocomplete-item:last-child {
    border-bottom: none;
}
.autocomplete-item:hover {
    background: #F1F5F9;
}
.autocomplete-item .main {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}
.autocomplete-item .secondary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1px;
}
.form-group {
    position: relative;
}

body.dark-mode .search-result-desc { background: var(--surface); border-color: #334155; color: #94A3B8; }
body.dark-mode .datetime-row {
    background: #334155;
    border-color: #475569;
}
body.dark-mode .datetime-row input[type="date"],
body.dark-mode .datetime-row select {
    color: #F1F5F9;
    background: transparent;
}
body.dark-mode .autocomplete-dropdown {
    background: #1E293B;
    border-color: #475569;
}
body.dark-mode .autocomplete-item:hover {
    background: #334155;
}

/* ---- Toast notifications ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    animation: toastIn .25s ease;
}
.toast-success { background: #1b8a4e; }
.toast-error   { background: #c0392b; }
@keyframes toastIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

/* ========== MODAL CARTE ========== */
.modal-with-map {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 0;
}
.modal-body { flex: 1; min-width: 0; overflow-y: auto; }
.modal-map-panel {
    width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: #f8faff;
    transition: width .25s ease;
    flex-shrink: 0;
}
.modal.map-open { max-width: 900px; }
.modal.map-open .modal-map-panel { width: 340px; min-height: 420px; }
.modal-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: .8rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

/* ========== RESPONSIVE MOBILE (≤ 768px) ========== */
@media (max-width: 768px) {
    .sidebar-collapse-btn { display: none; }

    /* Hamburger visible */
    .mobile-menu-btn {
        display: flex;
        align-items: center; justify-content: center;
        position: fixed;
        top: 12px; left: 12px;
        z-index: 150;
        width: 42px; height: 42px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: var(--shadow-md);
        font-size: 1.1rem;
    }

    /* Sidebar : masquée par défaut, overlay au clic */
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        width: min(280px, 85vw);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }

    /* Overlay derrière la sidebar */
    body.sidebar-open::after {
        content: '';
        position: fixed; inset: 0;
        background: rgba(15,23,42,.45);
        z-index: 190;
    }

    /* Contenu principal pleine largeur */
    .main-content {
        margin-left: 0;
        padding: 14px 12px 14px;
        padding-top: 64px; /* espace pour le hamburger */
    }

    /* En-tête planning */
    .planning-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    .planning-title h2 { font-size: .95rem; }
    .view-selector { display: flex; gap: 4px; }
    .view-btn { padding: 5px 9px; font-size: .72rem; }
    .planning-actions { display: flex; gap: 6px; }
    .planning-actions .btn { padding: 7px 10px; font-size: .78rem; }

    /* Barre navigation date */
    .calendar-toolbar { padding: 5px 8px; }
    .calendar-toolbar h3 { font-size: .82rem; min-width: 0; flex: 1; }

    /* Vue semaine → scrollable horizontalement */
    .week-view, .day-view { overflow-x: auto; }
    .week-header { min-width: 480px; }

    /* Cartes rendez-vous plus lisibles */
    .apt-card { font-size: .7rem; padding: 2px 4px; min-height: 24px; }
    .apt-line2, .apt-line3 { display: none; }

    /* Modal plein écran sur mobile */
    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius) var(--radius) 0 0;
        margin: 0;
    }

    /* Panneau carte masqué sur mobile (pas assez de place) */
    .modal.map-open { max-width: 100%; }
    .modal.map-open .modal-map-panel { display: none; }

    /* Formulaires : 2 colonnes → 1 colonne */
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .modal .form-row-2 { grid-template-columns: 1fr; gap: 6px; }

    /* Date + heure en colonne */
    .datetime-row { flex-direction: column; align-items: stretch; }
    .datetime-row input[type="date"] { width: 100%; }
    .datetime-row .time-row { justify-content: flex-start; }

    /* Cibles tactiles plus grandes */
    .btn, .view-btn, .btn-icon { min-height: 38px; }
    .sidebar-filter-chip { padding: 10px 8px; }
}

/* ========== TRÈS PETITS ÉCRANS (≤ 400px) ========== */
@media (max-width: 400px) {
    .planning-actions .btn span { display: none; }
    .view-btn i { margin-right: 0; }
    .view-btn span { display: none; }
}
