/* ============================================================
   PIPELET CRM – Feuille de style principale
   Palette : Navy #1B2B5E | Yellow #F5C400 | Light BG #F7F5EF
   ============================================================ */

:root {
  --navy:     #1B2B5E;
  --yellow:   #F5C400;
  --bg:       #F7F5EF;
  --card-bg:  #FFFFFF;
  --sidebar-w: 140px;
  --radius:   12px;
  --shadow:   0 2px 12px rgba(0,0,0,.08);
  --font:     'Inter', sans-serif;
  --danger:   #E03E3E;
  --success:  #2D9E6B;
  --muted:    #6B7280;
}

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

body { font-family: var(--font); background: var(--bg); color: var(--navy); font-size: 15px; }

/* ── Impersonate Bar ── */
.impersonate-bar {
  background: var(--yellow); color: var(--navy);
  text-align: center; padding: 8px 16px; font-size: 14px; font-weight: 600;
}
.btn-stop { background: var(--navy); color: #fff; border-radius: 6px; padding: 2px 10px; text-decoration: none; margin-left: 12px; }

/* ── Layout ── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); background: var(--card-bg);
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 0; gap: 4px;
  box-shadow: 2px 0 8px rgba(0,0,0,.06); position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo { margin-bottom: 24px; }
.logo-img { max-width: 100px; height: auto; }

.nav-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px; border-radius: var(--radius); width: 110px;
  text-decoration: none; color: var(--navy); font-size: 13px; font-weight: 500;
  transition: background .15s;
}
.nav-item:hover, .nav-item.active { background: var(--bg); }
.nav-icon { font-size: 22px; margin-bottom: 4px; }
.nav-cta .nav-plus {
  background: var(--yellow); color: var(--navy);
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; margin-bottom: 4px;
}

/* ── Main content ── */
.main-content { flex: 1; padding: 24px; max-width: 960px; }

/* ── Cards ── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.sub-card { background: var(--bg); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; color: var(--navy); display: flex; align-items: center; gap: 10px; }

/* ── Auth ── */
.auth-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg); }
.auth-card  { background: var(--card-bg); border-radius: var(--radius); padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-logo  { text-align: center; margin-bottom: 28px; }
.auth-logo img { max-height: 50px; }
.auth-logo h1   { font-size: 28px; font-weight: 700; color: var(--navy); margin-top: 8px; }
.auth-subtitle  { font-size: 18px; margin-bottom: 20px; text-align: center; }
.auth-form      { display: flex; flex-direction: column; gap: 16px; }
.auth-link      { display: block; text-align: center; margin-top: 16px; color: var(--navy); font-size: 14px; text-decoration: underline; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--navy); }
.input-field, .textarea-field, select.input-field {
  width: 100%; padding: 10px 14px; border: 1.5px solid #E5E7EB;
  border-radius: 8px; font-size: 15px; font-family: var(--font);
  background: #fff; color: var(--navy); margin-bottom: 12px;
  transition: border-color .15s;
}
.input-field:focus, .textarea-field:focus { outline: none; border-color: var(--navy); }
.textarea-field { resize: vertical; min-height: 100px; }
.row-inputs { display: flex; gap: 12px; }
.row-inputs .input-field { margin-bottom: 12px; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 8px; font-weight: 600;
  font-size: 15px; cursor: pointer; border: none; text-decoration: none;
  transition: opacity .15s, transform .1s; font-family: var(--font);
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary  { background: var(--navy);    color: #fff; }
.btn-yellow   { background: var(--yellow);  color: var(--navy); }
.btn-outline  { background: transparent; border: 2px solid var(--navy); color: var(--navy); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-full     { width: 100%; }
.btn-sm       { padding: 6px 12px; font-size: 13px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-yellow  { background: var(--yellow); color: var(--navy); }
.badge-admin   { background: var(--navy);   color: #fff; }
.badge-user    { background: #E5E7EB;       color: var(--navy); }
.badge-prospect_chaud  { background: #FECDD3; color: #9F1239; }
.badge-prospect_tiede  { background: #FEF3C7; color: #92400E; }
.badge-prospect_froid  { background: #DBEAFE; color: #1E40AF; }
.badge-client          { background: #D1FAE5; color: #065F46; }
.badge-ancien_client   { background: #E5E7EB; color: #4B5563; }
.badge-perdu           { background: #FEE2E2; color: #991B1B; }
.badge-canal           { background: #EDE9FE; color: #4C1D95; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error   { background: #FEE2E2; color: #991B1B; }

/* ── Relances ── */
.relance-card {
  display: flex; justify-content: space-between; align-items: flex-start;
  background: #E8ECF7; border-radius: var(--radius); padding: 16px 20px;
  margin-bottom: 12px; gap: 16px;
}
.relance-info { display: flex; flex-direction: column; gap: 4px; }
.relance-info strong { font-size: 16px; }
.relance-info span   { font-size: 13px; color: #374151; }
.retard  { color: var(--danger); font-weight: 700; font-size: 13px; }
.relance-note { text-align: right; }
.note-label   { font-weight: 600; font-size: 13px; }
.relance-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Stats ── */
.stats-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-box {
  flex: 1; min-width: 140px; background: #E8ECF7; border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.stat-label { font-size: 14px; font-weight: 600; color: var(--navy); }
.stat-value { font-size: 36px; font-weight: 800; color: var(--navy); }

/* ── Tables ── */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 700; border-bottom: 2px solid #E5E7EB; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #F3F4F6; }
.data-table tr:hover td { background: #F9FAFB; }
.row-alert td { background: #FFF7ED; }

/* ── History ── */
.history-item { background: #F3F4F6; border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.history-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.history-vente { border-left: 4px solid var(--yellow); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.modal-box {
  background: #EEF2FF; border-radius: var(--radius); padding: 28px;
  width: 90%; max-width: 480px; position: relative; box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--navy);
}
.modal-box h3 { font-size: 18px; margin-bottom: 16px; }

/* ── Misc ── */
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.text-muted   { color: var(--muted); font-size: 14px; }
.text-danger  { color: var(--danger); font-weight: 600; }
.text-center  { text-align: center; }
.dashboard    { display: flex; flex-direction: column; gap: 20px; }
.contact-header { }
.contact-title-row { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.contact-title-row h2 { font-size: 22px; font-weight: 800; }
.ca-row { font-size: 18px; font-weight: 700; margin: 16px 0; }
.contact-edit-form .row-inputs { flex-wrap: wrap; }
.input-label { font-size: 12px; font-weight: 600; display: block; margin-bottom: 4px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-form .input-field { margin-bottom: 0; flex: 1; min-width: 160px; }
.filter-tabs { display: flex; gap: 10px; margin-bottom: 16px; }
.tab { padding: 7px 16px; border-radius: 20px; text-decoration: none; color: var(--navy); background: var(--bg); font-weight: 600; font-size: 13px; }
.tab.active { background: var(--navy); color: #fff; }
.logout-link { display: block; text-align: center; margin-top: 24px; color: var(--navy); font-weight: 700; text-decoration: underline; cursor: pointer; }
.divider { border: none; border-top: 1px solid #E5E7EB; margin: 16px 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 70px; }
  .nav-label { display: none; }
  .nav-item  { width: 56px; padding: 10px 6px; }
  .main-content { padding: 14px; }
  .row-inputs { flex-direction: column; gap: 0; }
  .stats-grid { flex-direction: column; }
  .relance-card { flex-direction: column; }
  .relance-note { text-align: left; }
  .contact-title-row { flex-direction: column; }
  .filter-form { flex-direction: column; }
  .list-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .filter-tabs { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .sidebar { width: 56px; }
  .auth-card { padding: 24px 16px; }
  .stat-value { font-size: 28px; }
}

/* ── Menu toggle (mobile) ─────────────────────── */
.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    padding: 0;
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #374151;
    border-radius: 2px;
    transition: transform .25s, opacity .25s;
}
/* Croix quand ouvert */
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

@media (max-width: 768px) {
    .menu-toggle        { display: flex; }
    .sidebar-overlay.open { display: block; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .28s ease;
    }
    .sidebar.open       { transform: translateX(0); }

    .main-content       { margin-left: 0; padding-top: 60px; }
}

/* ══════════════════════════════════════════════
   MOBILE — bloc unique consolidé (override tout)
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Layout global ── */
    /* PAS de overflow-x:hidden sur app-wrapper car ça casse position:fixed */
    body { overflow-x: hidden; }

    .main-content {
        width: 100%;
        max-width: 100%;
        margin-left: 0 !important;
        padding: 64px 12px 16px !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* ── Inputs ne débordent pas ── */
    .input-field, .textarea-field, select.input-field,
    .contact-edit-form input, .contact-edit-form select,
    .relance-form input, .relance-form select {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    /* ── Cards ── */
    .card { padding: 16px 12px; }
    .row-inputs > * { width: 100% !important; }
    .modal-box { width: 95%; padding: 20px 16px; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* ── Hamburger ── */
    .menu-toggle { display: flex; }
    .sidebar-overlay.open { display: block; }

    /* ── Sidebar drawer ── */
    .sidebar {
        position: fixed !important;
        top: 0; left: 0;
        width: 220px !important;
        height: 100% !important;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .28s ease;
        align-items: flex-start !important;
        padding: 24px 12px !important;
    }
    .sidebar.open { transform: translateX(0) !important; }

    /* Logo dans le drawer */
    .sidebar-logo {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 0 20px;
        border-bottom: 1px solid #E5E7EB;
        margin-bottom: 12px;
    }
    .logo-img { max-width: 130px; max-height: 60px; object-fit: contain; }

    /* Items nav en ligne */
    .nav-item {
        flex-direction: row !important;
        width: 100% !important;
        justify-content: flex-start !important;
        gap: 12px;
        padding: 12px 14px !important;
    }
    .nav-label { display: block !important; font-size: 15px; }
    .nav-icon  { font-size: 20px; margin-bottom: 0 !important; }
    .nav-cta .nav-plus {
        width: 32px; height: 32px;
        font-size: 20px;
        margin-bottom: 0 !important;
    }
}