/* =============================================================================
 * assets/css/style.css
 * -----------------------------------------------------------------------------
 * Feuille de style personnalisée d'Automobile CRM.
 *
 * Elle se superpose à Bootstrap 5 pour offrir un rendu moderne et épuré
 * (inspirations : Linear, HubSpot, Monday) : palette sobre, cartes arrondies,
 * ombres douces, barre latérale fixe et interface responsive.
 *
 * Sommaire :
 *   1. Variables (couleurs, rayons, ombres)
 *   2. Base & typographie
 *   3. Mise en page (sidebar + contenu)
 *   4. Barre latérale
 *   5. Cartes & indicateurs (KPI)
 *   6. Listes, badges de statut, tableaux
 *   7. Composants de formulaire (notation, tags, pills)
 *   8. Boutons & divers
 *   9. Page de connexion
 *  10. Responsive
 * ========================================================================== */

/* =============================================================================
 * 1. VARIABLES
 * ========================================================================== */
:root {
    /* Couleur d'accent (indigo sobre, à la Linear). */
    --crm-primary:        #4f46e5;
    --crm-primary-rgb:    79, 70, 229;
    --crm-primary-dark:   #4338ca;
    --crm-primary-soft:   #eef2ff;

    /* Neutres (ardoise). */
    --crm-bg:             #f6f7fb;
    --crm-surface:        #ffffff;
    --crm-border:         #e8eaf1;
    --crm-text:           #1f2330;
    --crm-text-soft:      #6b7280;
    --crm-text-muted:     #9aa1b1;

    /* Accents secondaires pour les icônes d'indicateurs. */
    --crm-blue:           #3b82f6;
    --crm-blue-soft:      #e7f0ff;
    --crm-green:          #10b981;
    --crm-green-soft:     #e3f7ef;
    --crm-amber:          #f59e0b;
    --crm-amber-soft:     #fdf2dd;
    --crm-violet:         #8b5cf6;
    --crm-violet-soft:    #f1ebfe;

    /* Rayons & ombres. */
    --crm-radius:         16px;
    --crm-radius-sm:      10px;
    --crm-shadow:         0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
    --crm-shadow-sm:      0 1px 2px rgba(16, 24, 40, .06);

    --crm-sidebar-width:  264px;

    /* On aligne la couleur primaire de Bootstrap sur notre accent. */
    --bs-primary:         var(--crm-primary);
    --bs-primary-rgb:     var(--crm-primary-rgb);
    --bs-link-color:      var(--crm-primary);
    --bs-link-hover-color:var(--crm-primary-dark);
    --bs-body-color:      var(--crm-text);
    --bs-border-color:    var(--crm-border);
}

/* =============================================================================
 * 2. BASE & TYPOGRAPHIE
 * ========================================================================== */
body {
    background-color: var(--crm-bg);
    color: var(--crm-text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; }

::selection {
    background: rgba(var(--crm-primary-rgb), .18);
}

/* =============================================================================
 * 3. MISE EN PAGE
 * ========================================================================== */
.app-main {
    min-height: 100vh;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 1rem 1.5rem;
    background: rgba(246, 247, 251, .85);
    backdrop-filter: saturate(160%) blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--crm-border);
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0;
}

.app-content {
    padding: 1.5rem;
    max-width: 1240px;
}

/* Sur grand écran, la barre latérale est fixe : on décale le contenu. */
@media (min-width: 992px) {
    .app-main {
        margin-left: var(--crm-sidebar-width);
    }
}

/* =============================================================================
 * 4. BARRE LATERALE
 * ========================================================================== */
.app-sidebar {
    background: var(--crm-surface);
    border-right: 1px solid var(--crm-border);
    width: var(--crm-sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
}

/* En desktop, position fixe sur toute la hauteur. */
@media (min-width: 992px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        z-index: 1030;
    }
}

/* Marque / logo. */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .25rem .5rem 1rem;
    margin-bottom: .75rem;
    border-bottom: 1px solid var(--crm-border);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-violet));
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 6px 16px rgba(var(--crm-primary-rgb), .35);
    flex: none;
}

.brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    color: var(--crm-text);
}

/* Navigation. */
.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    flex: 1 1 auto;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    border-radius: var(--crm-radius-sm);
    color: var(--crm-text-soft);
    font-weight: 500;
    font-size: .95rem;
    transition: background-color .15s ease, color .15s ease;
}

.nav-link-item i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

.nav-link-item:hover {
    background: var(--crm-bg);
    color: var(--crm-text);
}

.nav-link-item.active {
    background: var(--crm-primary-soft);
    color: var(--crm-primary-dark);
    font-weight: 600;
}

/* Pied de la barre latérale (utilisateur + déconnexion). */
.sidebar-footer {
    border-top: 1px solid var(--crm-border);
    padding-top: .85rem;
    margin-top: .5rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .25rem .35rem .75rem;
    min-width: 0;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--crm-bg);
    color: var(--crm-text-soft);
    flex: none;
}

.user-email {
    font-size: .82rem;
    color: var(--crm-text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    color: var(--crm-text-soft);
    background: var(--crm-bg);
    border: 1px solid var(--crm-border);
    font-weight: 500;
    border-radius: var(--crm-radius-sm);
}

.btn-logout:hover {
    color: #dc2626;
    border-color: #f3c8c8;
    background: #fdeded;
}

/* =============================================================================
 * 5. CARTES & INDICATEURS (KPI)
 * ========================================================================== */
.surface-card,
.card.surface-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
}

.card.surface-card .card-body {
    padding: 1.25rem 1.35rem;
}

.card-title-sm {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin-bottom: 1rem;
    color: var(--crm-text);
}

/* Carte indicateur. */
.kpi-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
    padding: 1.15rem 1.25rem;
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(16, 24, 40, .05), 0 14px 32px rgba(16, 24, 40, .09);
}

.kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 1.4rem;
    flex: none;
}

.kpi-icon-blue   { background: var(--crm-blue-soft);   color: var(--crm-blue);   }
.kpi-icon-green  { background: var(--crm-green-soft);  color: var(--crm-green);  }
.kpi-icon-amber  { background: var(--crm-amber-soft);  color: var(--crm-amber);  }
.kpi-icon-violet { background: var(--crm-violet-soft); color: var(--crm-violet); }

.kpi-body { min-width: 0; }

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.02em;
}

.kpi-label {
    font-size: .82rem;
    color: var(--crm-text-soft);
    margin-top: .15rem;
}

/* Conteneur de graphique : hauteur maîtrisée. */
.chart-wrap {
    position: relative;
    height: 300px;
}

/* =============================================================================
 * 6. LISTES, BADGES DE STATUT, TABLEAUX
 * ========================================================================== */
.list-clean {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-clean li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--crm-border);
}

.list-clean li:last-child { border-bottom: 0; }

.list-main { min-width: 0; }

.list-title {
    display: block;
    font-weight: 600;
    color: var(--crm-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.list-title:hover { color: var(--crm-primary); }

.list-sub {
    font-size: .82rem;
    color: var(--crm-text-soft);
}

/* Badges d'état (pastilles colorées). */
.status-badge {
    display: inline-block;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.status-attente      { background: #fef6e0; color: #b7791f; border-color: #f6e3b4; }
.status-reponse      { background: var(--crm-blue-soft);  color: #1d4ed8; border-color: #cfe0fd; }
.status-sans-reponse { background: #f1f3f7; color: #5b6373; border-color: #e2e6ee; }
.status-interessante { background: var(--crm-green-soft); color: #047857; border-color: #c5ecdc; }
.status-terminee     { background: var(--crm-violet-soft);color: #6d28d9; border-color: #e1d5fb; }

/* Tableaux de données. */
.data-table thead th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--crm-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--crm-border);
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    padding: .7rem .75rem;
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: color .15s ease;
}

.sortable:hover { color: var(--crm-primary); }

.sortable i {
    font-size: .7rem;
    opacity: .45;
    margin-left: .15rem;
}

.sortable.sort-asc i,
.sortable.sort-desc i { opacity: 1; color: var(--crm-primary); }

.cell-rating { color: var(--crm-amber); letter-spacing: .06em; white-space: nowrap; }
.cell-empty  { color: var(--crm-text-muted); }

.cell-comment {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--crm-text-soft);
}

.search-group { width: 240px; max-width: 60vw; }

/* =============================================================================
 * 7. COMPOSANTS DE FORMULAIRE
 * ========================================================================== */

/* Notation par étoiles (saisie). */
.rating-input {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: 1.45rem;
    color: var(--crm-amber);
}

.rating-input i {
    cursor: pointer;
    transition: transform .1s ease;
}

.rating-input i:hover { transform: scale(1.12); }

.rating-reset {
    font-size: .8rem;
    margin-left: .5rem;
    text-decoration: none;
    color: var(--crm-text-muted);
}

.rating-reset:hover { color: #dc2626; }

/* Grille de tags (cases à cocher). */
.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .35rem .75rem;
}

/* Pastilles d'information. */
.usage-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--crm-primary-soft);
    color: var(--crm-primary-dark);
    font-size: .8rem;
    font-weight: 600;
}

.rate-pill {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    background: var(--crm-green-soft);
    color: #047857;
    font-size: .8rem;
    font-weight: 600;
}

/* =============================================================================
 * 8. BOUTONS & DIVERS
 * ========================================================================== */
.btn {
    border-radius: var(--crm-radius-sm);
    font-weight: 500;
}

.btn-primary {
    --bs-btn-bg: var(--crm-primary);
    --bs-btn-border-color: var(--crm-primary);
    --bs-btn-hover-bg: var(--crm-primary-dark);
    --bs-btn-hover-border-color: var(--crm-primary-dark);
    --bs-btn-active-bg: var(--crm-primary-dark);
    --bs-btn-active-border-color: var(--crm-primary-dark);
    --bs-btn-disabled-bg: var(--crm-primary);
    --bs-btn-disabled-border-color: var(--crm-primary);
    box-shadow: 0 6px 16px rgba(var(--crm-primary-rgb), .25);
}

.btn-outline-primary {
    --bs-btn-color: var(--crm-primary);
    --bs-btn-border-color: var(--crm-primary);
    --bs-btn-hover-bg: var(--crm-primary);
    --bs-btn-hover-border-color: var(--crm-primary);
    --bs-btn-active-bg: var(--crm-primary-dark);
    --bs-btn-active-border-color: var(--crm-primary-dark);
}

.form-control, .form-select {
    border-radius: var(--crm-radius-sm);
    border-color: var(--crm-border);
}

.form-control:focus, .form-select:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--crm-primary-rgb), .15);
}

.input-group-text {
    background: var(--crm-bg);
    border-color: var(--crm-border);
    color: var(--crm-text-soft);
}

.modal-content {
    border: 0;
    border-radius: var(--crm-radius);
    box-shadow: 0 24px 60px rgba(16, 24, 40, .22);
}

.modal-header, .modal-footer { border-color: var(--crm-border); }

.form-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--crm-text-soft);
    margin-bottom: .3rem;
}

/* =============================================================================
 * 9. PAGE DE CONNEXION
 * ========================================================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(var(--crm-primary-rgb), .12), transparent 60%),
        var(--crm-bg);
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 20px;
    box-shadow: var(--crm-shadow);
    padding: 2.25rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.brand-mark-lg {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    font-size: 1.8rem;
    margin: 0 auto .9rem;
}

.auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0;
}

.auth-subtitle {
    color: var(--crm-text-soft);
    font-size: .9rem;
    margin: .25rem 0 0;
}

/* =============================================================================
 * 10. RESPONSIVE
 * ========================================================================== */
@media (max-width: 991.98px) {
    .app-content { padding: 1.1rem; }
    .search-group { width: 180px; }
}

@media (max-width: 575.98px) {
    .kpi-card { padding: 1rem; gap: .75rem; }
    .kpi-icon { width: 42px; height: 42px; font-size: 1.2rem; }
    .kpi-value { font-size: 1.35rem; }
    .chart-wrap { height: 240px; }
}
