/* ═══════════════════════════════════════════════════════════════
   IB CARS 4.1 — Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables CSS ────────────────────────────────────────────── */
:root {
    /* Couleurs principales */
    --sidebar-bg:       #0f172a;
    --sidebar-border:   #1e293b;
    --sidebar-item-hover: #1e293b;
    --sidebar-item-active: #1d4ed8;
    --sidebar-text:     #94a3b8;
    --sidebar-text-muted: #475569;
    --sidebar-text-active: #f1f5f9;
    --sidebar-accent:   #3b82f6;
    --sidebar-width:    240px;

    /* Couleurs UI */
    --color-bg:         #f1f5f9;
    --color-surface:    #ffffff;
    --color-border:     #e2e8f0;
    --color-text:       #1e293b;
    --color-text-muted: #64748b;
    --color-primary:    #3b82f6;
    --color-primary-dark: #2563eb;
    --color-danger:     #ef4444;
    --color-success:    #22c55e;

    /* Espacements */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;

    /* Border-radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Ombres */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
}

/* ── Reset & base ─────────────────────────────────────────────── */
* {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.ibcars-app {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-bg);
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Layout global ────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 4px 0 16px rgba(0,0,0,0.25);
    z-index: 100;
}

/* Brand */
.sidebar-brand {
    padding: 1.25rem 1.125rem 1rem;
    font-size: 1.2rem;
    font-weight: 800;
    color: #f1f5f9;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand span {
    color: var(--sidebar-accent);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 2px;
}

/* Section labels */
.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    padding: 0.75rem 0.5rem 0.35rem;
    margin-top: 0.25rem;
}

/* Nav items */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none !important;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.sidebar-nav-item i {
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-nav-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav-item:hover i {
    opacity: 1;
}

.sidebar-nav-item.active {
    background: var(--sidebar-item-active);
    color: #ffffff;
    font-weight: 600;
}

.sidebar-nav-item.active i {
    opacity: 1;
}

/* User footer */
.sidebar-user-footer {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--sidebar-accent);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-username {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .badge-sm {
    font-size: 0.6rem;
    padding: 1px 5px;
}

.sidebar-user-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.sidebar-user-actions a {
    color: var(--sidebar-text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
}

.sidebar-user-actions a:hover {
    color: #e2e8f0;
}

.sidebar-user-actions a.text-danger:hover {
    color: #fca5a5 !important;
}

/* ── App main area ────────────────────────────────────────────── */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Flash messages */
.app-alerts {
    flex-shrink: 0;
    z-index: 50;
}

.app-alerts .alert {
    margin-bottom: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
}

/* Content area */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.page-content {
    padding: var(--space-lg);
}

/* ── Page title utilitaire ────────────────────────────────────── */
.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-lg);
}

.page-title .badge {
    font-size: 0.7em;
    vertical-align: middle;
}

/* ── Auth page (non authentifié) ──────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: var(--space-lg);
}

.auth-alerts {
    width: 100%;
    max-width: 420px;
    margin-bottom: var(--space-md);
}

/* ── Bootstrap overrides ──────────────────────────────────────── */

/* Cards */
.card {
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    border-bottom: 1px solid var(--color-border);
}

/* Boutons */
.btn {
    border-radius: var(--radius-md);
    padding: 0.45rem 1rem;
    font-weight: 500;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Tables */
.table {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table th {
    background-color: #f1f5f9;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

/* Formulaires */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    border-color: var(--color-border);
    text-transform: uppercase;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
}

/* Badges */
.badge {
    border-radius: var(--radius-sm);
}

/* ── Amélioration des éléments cliquables ─────────────────────── */
.fc-event, .btn, a, button {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.fc-event, .btn, button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ── FullCalendar overrides ───────────────────────────────────── */
.fc-event {
    cursor: pointer;
    border-radius: 4px;
}

.rdv-en-atelier {
    color: #28a745 !important;
    font-weight: bold !important;
}

.rdv-hors-atelier {
    color: #000000 !important;
    font-weight: normal !important;
}

.rdv-pret {
    color: #007bff !important;
    font-weight: bold;
    background-color: rgba(0, 123, 255, 0.1);
}

.fc-header-toolbar {
    margin-bottom: 1.5em !important;
}

.fc-timegrid-event-harness {
    width: 25% !important;
}

.fc-timegrid-col-events {
    display: flex !important;
    flex-wrap: wrap !important;
}

.fc-timegrid-event {
    margin-left: 0 !important;
    margin-right: 2px !important;
    width: calc(100% - 2px) !important;
    text-transform: none !important;
}

.fc-event-title {
    text-transform: none !important;
    font-size: 1.2rem !important;
}

.fc-event-title-container {
    text-transform: none !important;
}

.custom-event-content {
    font-size: 1.2rem;
    line-height: 1.5;
}

/* ── Styles impression ────────────────────────────────────────── */
@page {
    size: A4 landscape;
    margin: 10mm 12mm;
}

@media print {
    body {
        font-size: 12pt;
        background: white;
        color: black;
    }

    .app-sidebar,
    .app-alerts,
    .btn,
    .no-print {
        display: none !important;
    }

    .app-shell {
        display: block;
        height: auto;
        overflow: visible;
    }

    .app-main,
    .app-content {
        overflow: visible;
        height: auto;
    }

    .page-content {
        padding: 0;
    }

    .container {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .card {
        border: none;
        box-shadow: none;
    }

    .table {
        width: 100%;
        border-collapse: collapse;
    }

    .table th,
    .table td {
        border: 1px solid #ddd;
        padding: 8px;
    }

    .print-only {
        display: block;
    }

    h1 {
        font-size: 18pt;
        margin-bottom: 20px;
    }
}
