/* ============================================================
   LBC Tools — app.css
   Thème : Élégance champagne — dark, gold, responsive
   Police : Playfair Display + DM Sans
   ============================================================ */

/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --gold:          #C9A84C;
    --gold-light:    #E2C97E;
    --gold-dim:      rgba(201,168,76,0.15);
    --bg-primary:    #0F0F0F;
    --bg-surface:    #161616;
    --bg-elevated:   #1E1E1E;
    --bg-hover:      #242424;
    --border:        rgba(255,255,255,0.08);
    --border-gold:   rgba(201,168,76,0.3);
    --text-primary:  #F0EDE6;
    --text-secondary:#A8A49C;
    --text-muted:    #5A5650;
    --success:       #4CAF7D;
    --warning:       #E8A838;
    --danger:        #E05C5C;
    --radius-sm:     6px;
    --radius-md:     10px;
    --radius-lg:     16px;
    --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:     0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg:     0 24px 48px rgba(0,0,0,0.5);
    --transition:    0.2s ease;
    --navbar-h:      60px;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

h1,h2,h3,h4,h5 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    line-height: 1.25;
}

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 24px;
}

.main-content {
    padding-top: calc(var(--navbar-h) + 32px);
    padding-bottom: 64px;
    min-height: 100vh;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-h);
    z-index: 100;
    background: rgba(15,15,15,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.navbar-inner {
    height: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    white-space: nowrap;
}
.navbar-brand .brand-icon { font-size: 1.2rem; }
.navbar-brand .brand-text { font-weight: 300; letter-spacing: 0.05em; }
.navbar-brand .brand-text strong { font-weight: 500; color: var(--gold); }

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.nav-link:hover:not(.disabled) { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active { color: var(--gold); background: var(--gold-dim); }
.nav-link.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.user-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.btn-logout {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); background: rgba(224,92,92,0.1); }

/* ─── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--text-primary);
}

.page-subtitle {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ─── Sync badge ─────────────────────────────────────────────────────────────── */
.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    border: 1px solid;
}
.sync-ok    { color: var(--success); border-color: rgba(76,175,125,0.3); background: rgba(76,175,125,0.08); }
.sync-error { color: var(--danger);  border-color: rgba(224,92,92,0.3);  background: rgba(224,92,92,0.08); }
.sync-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--gold);
    color: #0F0F0F;
    border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); color: #0F0F0F; }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.w-100 { width: 100%; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase; }

.form-control {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    padding: 10px 14px;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}
.form-control:focus { border-color: var(--gold); }
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm { padding: 7px 10px; font-size: 0.85rem; }

select.form-control { cursor: pointer; }
option { background: var(--bg-elevated); }

/* ─── Filtres ────────────────────────────────────────────────────────────────── */
.filters-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    align-items: end;
}

/* Filtres sur 2 lignes */
.filters-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filters-row-period {
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.filters-row-period .filter-label {
    white-space: nowrap;
    margin: 0;
    line-height: 1;
}
.filters-row-period .btn-group {
    flex-wrap: nowrap;
}
.filters-row-detail {
    align-items: flex-end;
    gap: 10px;
}
.filters-row-detail .filter-group {
    min-width: 120px;
    flex: 1;
}
.filters-row-detail .filter-group-wide {
    min-width: 180px;
    flex: 2;
}
.filters-row-detail .filter-group-action {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-bottom: 0;
}

.filter-group-wide { grid-column: span 2; }
.filter-group-action { display: flex; flex-direction: row; gap: 8px; align-items: flex-end; }

/* Boutons de période */
.btn-group { display: flex; gap: 4px; }
.btn-period {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-period:hover { color: var(--text-primary); border-color: var(--border); background: var(--bg-hover); }
.btn-period.active { background: var(--gold-dim); border-color: var(--border-gold); color: var(--gold); }

/* ─── KPIs ───────────────────────────────────────────────────────────────────── */
.kpis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: border-color var(--transition);
}
.kpi-card:hover { border-color: var(--border-gold); }

.kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}
.kpi-value {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: var(--gold);
    line-height: 1.1;
}
.kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ─── Charts ─────────────────────────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.chart-wide { grid-column: span 2; }

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.chart-title {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.chart-body { position: relative; min-height: 260px; flex: 1; }
.chart-pie-body { max-height: 320px; }

/* Toggle métrique */
.chart-toggle {
    display: flex;
    gap: 4px;
}
.btn-toggle {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}
.btn-toggle.active {
    background: var(--gold-dim);
    border-color: var(--border-gold);
    color: var(--gold);
}

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.table-tabs { display: flex; gap: 4px; }
.tab-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}
.tab-btn.active { background: var(--gold-dim); border-color: var(--border-gold); color: var(--gold); }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-surface);
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-secondary);
    white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); color: var(--text-primary); }
.data-table tfoot td {
    padding: 14px 16px;
    font-weight: 600;
    color: var(--gold);
    border-top: 1px solid var(--border-gold);
    background: var(--gold-dim);
}
.table-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 48px !important;
    font-style: italic;
}
.text-right { text-align: right !important; }

/* ─── Dashboard — Grille outils ──────────────────────────────────────────────── */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.tool-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}
.tool-card:not(.tool-coming):hover {
    border-color: var(--border-gold);
    background: var(--bg-elevated);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.tool-coming { opacity: 0.5; cursor: default; }

.tool-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.tool-body { flex: 1; }
.tool-name { font-size: 1rem; font-family: 'Playfair Display', serif; margin-bottom: 6px; }
.tool-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.tool-arrow { font-size: 1.2rem; color: var(--gold); margin-left: auto; align-self: center; opacity: 0; transition: opacity var(--transition); }
.tool-card:not(.tool-coming):hover .tool-arrow { opacity: 1; }
.tool-badge {
    position: absolute;
    top: 14px; right: 14px;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ─── Skeleton loader ────────────────────────────────────────────────────────── */
.skeleton {
    position: relative;
    overflow: hidden;
    min-height: 100px;
    background: var(--bg-elevated) !important;
    border-color: transparent !important;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ─── Responsive — Tablette ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
    .chart-wide { grid-column: span 1; }
    .kpis-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-group-wide { grid-column: span 1; }
}

/* ─── Responsive — Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .main-content { padding-top: calc(var(--navbar-h) + 20px); padding-bottom: 40px; }

    .navbar-inner { gap: 16px; padding: 0 16px; }
    .navbar-nav { display: none; }

    .page-header { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; justify-content: flex-between; }

    .kpis-grid { grid-template-columns: 1fr; }

    .filters-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .filter-group-wide  { grid-column: span 2; }
    .filter-group-action { grid-column: span 2; }

    .tools-grid { grid-template-columns: 1fr; }

    .data-table th, .data-table td { padding: 10px 12px; }

    .chart-body { min-height: 200px; }
    .kpi-value { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .filters-grid { grid-template-columns: 1fr; }
    .filter-group-wide { grid-column: span 1; }
    .filter-group-action { grid-column: span 1; }
    .btn-group { flex-wrap: wrap; }
}

/* ─── Composant num-spinner (champ numérique avec boutons −/+) ───────────────
   Usage HTML :
   <div class="num-spinner">
     <button class="ns-btn ns-minus">−</button>
     <input type="number" class="ns-input">
     <button class="ns-btn ns-plus">＋</button>
   </div>
────────────────────────────────────────────────────────────────────────────── */
.num-spinner {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-elevated);
    transition: border-color .15s;
}
.num-spinner:focus-within { border-color: var(--gold); }
.num-spinner.modified     { border-color: var(--warning); }

.ns-btn {
    width: 28px;
    min-width: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    user-select: none;
    padding: 0;
}
.ns-btn:hover  { background: var(--bg-hover); color: var(--text-primary); }
.ns-btn:active { background: var(--gold-dim); color: var(--gold); }

/* Séparateur entre bouton et champ */
.ns-minus { border-right: 1px solid var(--border); }
.ns-plus  { border-left:  1px solid var(--border); }

.ns-input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    outline: none;
    width: 56px;
    padding: 5px 4px;
    -moz-appearance: textfield;
}
.ns-input::-webkit-outer-spin-button,
.ns-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Variante large (pour les prix) */
.num-spinner.ns-wide .ns-input { width: 80px; text-align: right; }
