/* === VARIABLES GLOBALES === */
:root {
    --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

    --bg-page: #f5f7fa;
    --bg-surface: #ffffff;
    --bg-navbar: #1a1a2e;

    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-inverse: #ffffff;

    --accent: #7C5CFC;
    --accent-hover: #6A4DE0;
    --accent-light: #a29bfe;

    /* Design System Pilote — violet dominant, vert positif, orange attention */
    --brand-700: #4B3FB0;
    --brand-600: #6C5CE7;
    --brand-500: #8B7DF0;
    --brand-100: #EFECFC;
    --brand-050: #F7F6FD;

    --success-700: #047857;
    --success-600: #0E9F6E;
    --success-050: #ECFDF5;

    --warning-700: #B45309;
    --warning-600: #EA7C16;
    --warning-050: #FFF7ED;

    --danger-600: #DC2626;
    --danger-050: #FEF2F2;

    --ink-900: #1A1A2E;
    --ink-600: #52586B;
    --ink-400: #9AA0AC;
    --surface: #FFFFFF;
    --design-border: #E7E4DE;
    --design-border-strong: #D8D4CC;

    --fs-h1: 1.375rem;
    --fs-h2: 1.05rem;
    --fs-body: 0.875rem;
    --fs-sm: 0.8125rem;
    --fs-xs: 0.6875rem;
    --fs-price: 0.9375rem;
    --ui-root-font-size: 16px;
    --ui-control-min-height: 40px;
    --ui-outline-width: 1px;

    --border: #e8e6e1;
    --border-hover: #d0cdc7;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --navbar-height: 52px;
    --page-padding: 24px;

    --transition-fast: 0.15s ease;

    /* Pilot Theme */
    --pilot-primary: #6B4FA0;
    --pilot-primary-light: #8B6FC0;
    --pilot-primary-bg: #F5F3FF;
    --pilot-text: #1A1A1A;
    --pilot-text-secondary: #666666;
    --pilot-text-muted: #999999;
    --pilot-bg: #FAFAFA;
    --pilot-bg-card: #FFFFFF;
    --pilot-bg-hover: #F5F5F5;
    --pilot-border: #E0E0E0;
    --pilot-border-light: #F0F0F0;
    --pilot-success: #1D9E75;
    --pilot-success-bg: #E8F8F2;
    --pilot-danger: #E74C3C;
    --pilot-danger-bg: #FDF0EF;
    --pilot-warning: #F39C12;
    --pilot-warning-bg: #FEF9E7;
    --pilot-info: #3498DB;
    --pilot-info-bg: #EBF5FB;
    --pilot-btn-radius: 8px;
    --pilot-btn-padding: 8px 16px;
    --pilot-btn-font: 13px;
    --pilot-btn-weight: 600;
    --pilot-modal-radius: 12px;
    --pilot-modal-shadow: 0 4px 24px rgba(0,0,0,0.12);
    --pilot-radius: 8px;
    --pilot-radius-lg: 12px;
    --pilot-transition: 0.15s ease;

    /* Navbar */
    --nav-bg: #1E1E2E;
    --nav-text: #E0E0E0;
    --nav-active: #FFFFFF;
    --nav-hover: #2D2D42;
    --nav-accent: #7C5CFC;

    /* Planning */
    --planning-bg: #F8F9FA;
    --planning-grid-line: #E9ECEF;
    --planning-hour-text: #868E96;
    --planning-header-bg: #FFFFFF;
    --planning-header-border: #DEE2E6;

    /* Blocs RDV */
    --rdv-bg: #FFFFFF;
    --rdv-border-radius: 6px;
    --rdv-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --rdv-hover-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

    /* Staff colors */
    --staff-color-1: #7C5CFC;
    --staff-color-2: #10B981;
    --staff-color-3: #F59E0B;
    --staff-color-4: #EC4899;
    --staff-color-5: #3B82F6;
    --staff-color-6: #EF4444;

    /* Action buttons */
    --btn-primary: #7C5CFC;
    --btn-primary-hover: #6A4DE0;
    --btn-danger: #EF4444;
    --btn-success: #10B981;

    /* Contrast-controlled variables (overridden by JS) */
    --row-alt-bg: #F5F5F8;
    --row-hover-bg: #EEEDF5;
    --row-selected-bg: #D5CEF5;
    --border-color: #E0E0E0;
    --border-strong: #D0D0D0;
    --header-bg: #F8F8FA;
}

/* === ACCESSIBILITÉ VISUELLE GLOBALE === */
html { font-size: var(--ui-root-font-size); }
html[data-ui-relief="strong"] {
    --ui-outline-width: 2px;
    --border: #C8C3BA;
    --border-hover: #989188;
    --design-border: #C8C3BA;
    --design-border-strong: #989188;
    --shadow-sm: 0 2px 6px rgba(26, 26, 46, 0.12);
    --shadow-md: 0 6px 18px rgba(26, 26, 46, 0.16);
    --shadow-lg: 0 10px 32px rgba(26, 26, 46, 0.2);
}
html[data-ui-relief="strong"] .module-frame,
html[data-ui-relief="strong"] .modal-panel,
html[data-ui-relief="strong"] .card,
html[data-ui-relief="strong"] .btn,
html[data-ui-relief="strong"] input,
html[data-ui-relief="strong"] select,
html[data-ui-relief="strong"] textarea {
    border-width: 2px;
}
html[data-ui-contrast="high"] {
    --text-primary: #11111F;
    --text-secondary: #3F4554;
    --text-muted: #626977;
}
html[data-ui-contrast="maximum"] {
    --text-primary: #080812;
    --text-secondary: #262B36;
    --text-muted: #444B58;
    --border: #AAA49A;
    --design-border: #AAA49A;
    --design-border-strong: #746E66;
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-size: max(0.875rem, 14px); }
a { text-decoration: none; color: inherit; }

/* === LAYOUT === */
.app-content {
    margin-top: calc(var(--navbar-height) + 16px);
    padding: 0 var(--page-padding) var(--page-padding);
}

.module-frame {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 24px;
    min-height: calc(100vh - var(--navbar-height) - 56px);
}

/* === NAVBAR === */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-height);
    background: var(--nav-bg);
    z-index: 1100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.navbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 2px;
}

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.5px;
    margin-right: 32px;
    flex-shrink: 0;
}

.navbar-logo .logo-dot {
    width: 10px; height: 10px;
    background: var(--nav-accent);
    border-radius: 50%;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.navbar-links::-webkit-scrollbar { display: none; }

.navbar-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    color: var(--nav-text);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition-fast);
    position: relative;
}

.navbar-link:hover {
    color: #FFFFFF;
    background: var(--nav-hover);
}

.navbar-link.active {
    color: #FFFFFF;
    background: var(--nav-accent);
}

.navbar-link.active::after {
    display: none;
}

.navbar-link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}
.navbar-link-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Profil dropdown */
.navbar-profile {
    margin-left: auto;
    flex-shrink: 0;
    position: relative;
}

.profile-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.profile-btn:hover {
    transform: scale(1.05);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    overflow: hidden;
    z-index: 1001;
}

.profile-dropdown.hidden { display: none; }

.profile-dropdown .dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-primary);
}

.profile-dropdown .dropdown-role {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 2px;
}

.profile-dropdown a {
    display: block;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.profile-dropdown a:hover {
    background: var(--bg-page);
}

/* === NOTIFICATION BELL === */
.notif-bell-btn:hover svg { stroke: rgba(255,255,255,1); }
.notif-badge {
    position: absolute;
    top: 2px; right: 0;
    background: #FF6B6B;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: var(--pds-radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1001;
}
.notif-dropdown.hidden { display: none; }

/* === MODAL HTMX === */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1095;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
#modal-container:empty {
    display: none;
}
#modal-container > * {
    pointer-events: auto;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 1090;
}
.modal-backdrop.hidden { display: none; }

#modal-container:empty + .modal-backdrop { display: none; }

.modal-panel {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

/* === UTILITAIRES === */
.hidden { display: none !important; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 6px rgba(108,92,231,0.3);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(108,92,231,0.4); }

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-page); }

.btn-danger {
    background: #FF6B6B;
    color: white;
}
.btn-danger:hover { background: #e55a5a; }

/* === FORMULAIRES === */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: border var(--transition-fast);
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
}

.form-errors {
    background: #fff0f0;
    color: #e55a5a;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* === HTMX loading === */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* === UTILITY CLASSES === */
/* Layout */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { display: flex; flex-wrap: wrap; }
.flex-gap-xs { display: flex; gap: 4px; }
.flex-gap-sm { display: flex; gap: 8px; }
.flex-gap-md { display: flex; gap: 12px; }
.flex-gap-lg { display: flex; gap: 16px; }
.flex-gap-xl { display: flex; gap: 24px; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

/* Spacing */
.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: 4px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 32px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.p-sm { padding: 8px; }
.p-md { padding: 12px; }
.p-lg { padding: 16px; }
.p-xl { padding: 24px; }
.px-md { padding-left: 12px; padding-right: 12px; }
.py-sm { padding-top: 8px; padding-bottom: 8px; }

/* Typography */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.82rem; }
.text-base { font-size: 0.9rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.3rem; }
.text-bold { font-weight: 600; }
.text-bolder { font-weight: 700; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: #00B894; }
.text-danger { color: #E55A5A; }
.text-warning { color: #E17055; }
.font-display { font-family: var(--font-display); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Borders & radius */
.border { border: 1px solid var(--border); }
.border-top { border-top: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 50%; }

/* Hide number input spinners globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* === PILOT BUTTONS === */
.btn-pilot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--pilot-btn-padding);
    font-size: var(--pilot-btn-font);
    font-weight: var(--pilot-btn-weight);
    border-radius: var(--pilot-btn-radius);
    cursor: pointer;
    transition: all var(--pilot-transition);
    border: 1px solid transparent;
    text-decoration: none;
    font-family: var(--font-body);
    line-height: 1.4;
}
.btn-pilot-primary {
    background: var(--pilot-success);
    color: white;
    border-color: var(--pilot-success);
}
.btn-pilot-primary:hover { background: #178C66; }
.btn-pilot-secondary {
    background: white;
    color: var(--pilot-primary);
    border-color: var(--pilot-primary);
}
.btn-pilot-secondary:hover { background: var(--pilot-primary-bg); }
.btn-pilot-danger {
    background: white;
    color: var(--pilot-danger);
    border-color: var(--pilot-danger);
}
.btn-pilot-danger:hover { background: var(--pilot-danger-bg); }
.btn-pilot-ghost {
    background: transparent;
    color: var(--pilot-text-secondary);
    border-color: var(--pilot-border);
}
.btn-pilot-ghost:hover { background: var(--pilot-bg-hover); }

/* === PILOT MODAL === */
.pilot-modal {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    position: relative;
    z-index: 1001;
}
.pilot-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--pilot-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pilot-modal-header h3,
.pilot-modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--pilot-text);
    margin: 0;
}
.pilot-modal-body {
    padding: 20px;
}
.pilot-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--pilot-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ─── Override prix ligne inline — friction #8 (caisse + encaissement) ───
   Classe partagée : caisse POS (sale_detail_panel) + encaissement RDV
   (encaissement_cart). JS associé : static/js/editable_price.js. */
.editable-price {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    transition: background-color 0.15s;
}
.editable-price:hover,
.editable-price:focus {
    background-color: rgba(124, 92, 252, 0.10);
    border-radius: 3px;
    outline: none;
}
.editable-price-input {
    width: 84px;
    padding: 1px 5px;
    border: 1.5px solid var(--accent, #7C5CFC);
    border-radius: 4px;
    font: inherit;
    text-align: right;
    background: #fff;
}
.editable-price-input::-webkit-outer-spin-button,
.editable-price-input::-webkit-inner-spin-button { margin: 0; }
