/* ============================================================
   CRM Golden Digital Media — Design system v2
   Sobre, clair, professionnel — un seul accent, une seule police
   ============================================================ */

:root {
    --bg:            #F5F6F8;
    --surface:       #FFFFFF;
    --border:        #E4E7EC;
    --border-strong: #D0D5DD;

    --text:          #101828;
    --text-secondary:#475467;
    --text-muted:    #98A2B3;

    --sidebar-bg:    #2B2B33;
    --sidebar-hover: #3A3A44;
    --sidebar-text:  #B0AEB8;

    --primary:       #7B17BC;
    --primary-hover: #611397;
    --primary-soft:  #F3E8FB;

    --success:       #12805C;
    --success-bg:    #E7F5EE;
    --danger:        #C0392B;
    --danger-bg:     #FBEAE8;
    --warning:       #B7791F;
    --warning-bg:    #FDF3E3;
    --info:          #7B17BC;
    --info-bg:       #F3E8FB;

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Roboto Mono', 'Courier New', monospace;

    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    overflow-x: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-body);
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---------- Titre de page ---------- */
main > h1.h3 {
    font-weight: 600;
    font-size: 1.375rem;
    padding-bottom: 14px;
    margin-bottom: 22px !important;
    border-bottom: 1px solid var(--border);
}

/* ================= TOPBAR ================= */
.navbar {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1.5rem;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text) !important;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.brand-mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
}

.brand-wordmark {
    height: 22px;
    object-fit: contain;
}

/* ---------- Badge Plan / durée d'abonnement (barre du haut) ---------- */
.plan-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.35em 0.7em;
    border-radius: 20px;
}
.plan-badge-sep { opacity: 0.6; margin: 0 2px; }

.lang-switch .btn {
    font-weight: 700;
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
}
.lang-switch .btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}
.plan-starter    { background: var(--border); color: var(--text-secondary); }
.plan-business   { background: var(--primary-soft, #F3E8FB); color: var(--primary, #7B17BC); }
.plan-enterprise { background: #FDF3E3; color: #B7791F; }

/* ---------- Bandeau d'alerte : abonnement bientôt expiré ---------- */
.plan-expiry-banner {
    background: #FBEAE8;
    color: #B3413B;
    font-size: 0.86rem;
    font-weight: 500;
    text-align: center;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid #F0C7C2;
}
.plan-expiry-link {
    color: #B3413B;
    font-weight: 700;
    text-decoration: underline;
    margin-left: 10px;
}
.plan-expiry-link:hover { color: #8a3128; }

.navbar .text-white { color: var(--text-secondary) !important; }

.navbar .btn-outline-light {
    border-color: var(--border-strong);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}
.navbar .btn-outline-light:hover {
    background: var(--bg);
    border-color: var(--border-strong);
    color: var(--text);
}

/* ================= SIDEBAR ================= */

/* La sidebar s'étire pour couvrir toute la hauteur du contenu de la page
   (pas seulement l'écran visible) grâce au flex "stretch" par défaut de .app-shell */
.app-shell {
    align-items: stretch;
    min-height: 100vh;
}

aside {
    background: var(--sidebar-bg) !important;
    border-right: none !important;
    overflow-y: auto;
    flex-shrink: 0;   /* la sidebar garde toujours sa largeur, même si le contenu est très large */
}

/* ---------- Groupes de menu repliables ---------- */
.sidebar-groups { display: flex; flex-direction: column; gap: 2px; }

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    background: transparent;
    border: none;
    color: #9A9CA8;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.55rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-group-toggle:hover { background: var(--sidebar-hover); color: #fff; }

.sidebar-group-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}
.sidebar-group-toggle.collapsed .sidebar-group-chevron { transform: rotate(-90deg); }

aside .nav-link {
    color: var(--sidebar-text);
    border-radius: 6px;
    font-size: 0.84rem;
    font-weight: 500;
    padding: 0.5rem 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s ease, color 0.12s ease;
}

aside .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

aside .nav-link.active,
.nav-pills .nav-link.active {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 600;
}

aside .nav-link i { font-size: 0.95rem; opacity: 0.9; }

/* ---------- Fil d'activité en temps réel (bas de la sidebar) ---------- */
.sidebar-activity {
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-activity-title {
    color: var(--sidebar-text);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3DCB6C;
    display: inline-block;
    animation: pulseDot 1.8s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.sidebar-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
}

.sidebar-activity-list li {
    color: #D8D9DE;
    font-size: 0.76rem;
    line-height: 1.35;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.06);
}

.sidebar-activity-list li:last-child { border-bottom: none; }
.sidebar-activity-list strong { color: #fff; font-weight: 600; }

.sidebar-activity-time {
    color: #8A8C99;
    font-size: 0.68rem;
    margin-top: 1px;
}

.sidebar-activity-empty {
    color: #8A8C99;
    font-size: 0.76rem;
    font-style: italic;
}

/* ================= CARDS ================= */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: none;
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* ---------- Stat cards (dashboard) ---------- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    height: 100%;
}

.stat-card .stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 0.65rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: 3px;
}

/* ================= BUTTONS ================= */
.btn {
    font-weight: 500;
    font-size: 0.86rem;
    border-radius: 6px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--border-strong);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-secondary { color: var(--text-secondary); border-color: var(--border-strong); }
.btn-outline-danger { border-color: var(--border-strong); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); }

/* focus visibility (accessibilité) */
.btn:focus-visible,
.form-control:focus-visible,
.nav-link:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem var(--primary-soft);
}
.form-control, .form-select {
    border-color: var(--border-strong);
    font-size: 0.88rem;
}
.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ================= BADGES ================= */
.badge { font-weight: 500; font-size: 0.72rem; padding: 0.4em 0.65em; }
.badge.bg-success { background-color: var(--success) !important; }
.badge.bg-danger  { background-color: var(--danger) !important; }
.badge.bg-warning { background-color: var(--warning) !important; color: #fff !important; }
.badge.bg-secondary { background-color: var(--text-muted) !important; }
.badge.bg-info { background-color: var(--info) !important; }

/* ================= ALERTS ================= */
.alert { border-radius: var(--radius); border: none; font-size: 0.88rem; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger); }

/* ================= TABLES ================= */
.table thead.table-light th {
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.table td, .table th { border-color: var(--border); vertical-align: middle; font-size: 0.87rem; }
.table-hover tbody tr:hover { background: var(--bg); }

.ref-number { font-family: var(--font-mono); font-size: 0.83rem; }

/* ================= LOGIN PAGE ================= */
.login-page { background: var(--bg); }
.login-shell { min-height: 100vh; }

.login-aside {
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-aside .brand-mark-lg {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.login-aside h1 {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 600;
}

.login-aside .tagline {
    color: var(--sidebar-text);
    font-size: 0.9rem;
}

.login-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: none;
}

/* ================= BOUTON HAMBURGER ================= */
.btn-icon {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1.1rem;
    padding: 0;
}
.btn-icon:hover { background: var(--bg); }

/* ---------- Responsive ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
main { min-width: 0; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.55);
    z-index: 1040;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    /* Le menu devient un tiroir qui glisse depuis la gauche, au-dessus du contenu */
    aside {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: 260px !important;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    aside.open { transform: translateX(0); }

    aside .nav-link {
        padding: 0.72rem 0.85rem;
        font-size: 0.92rem;
    }

    main { padding: 16px !important; }

    body { font-size: 13.5px; }

    .card { margin-bottom: 15px; }

    /* Zones tactiles plus généreuses */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; padding: 0.35rem 0.65rem; }
    .form-control, .form-select { min-height: 42px; font-size: 0.92rem; }

    .table td, .table th { font-size: 0.84rem; padding: 0.6rem 0.5rem; }

    /* Cartes statistiques : 2 par ligne sur mobile plutôt qu'empilées */
    .stat-card { padding: 0.9rem 1rem; }
    .stat-card .stat-value { font-size: 1.25rem; }

    .login-shell { flex-direction: column; }
    .login-aside { display: none !important; }
}

@media (max-width: 575.98px) {
    .navbar-brand { font-size: 0.9rem; }
    .navbar-brand span:not(.brand-mark) { display: none; }
    main { padding: 12px !important; }
    .btn:not(.btn-icon):not(.btn-sm) { width: 100%; }
    .table-responsive { margin-bottom: 1rem; }
    .card-body { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
