/* FlashCall v2 — Design System (clair, violet signature, aplats uniquement) */
:root {
    --primary: #7C3AED;
    --primary-dark: #5B21B6;
    --primary-light: #EDE9FE;
    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    --bg: #F8F7FC;
    --surface: #FFFFFF;
    --sidebar-bg: #FFFFFF;
    --text: #17142B;
    --muted: #6B6780;
    --text-muted: var(--muted);
    --text-dim: #9B96AB;
    --border: #E9E7F0;
    --border-light: #F3F1FA;
    --accent: var(--primary);
    --accent-2: var(--primary-dark);
    --navy: var(--text);
    --ok: #047857;
    --warn: #B45309;
    --err: #B91C1C;
    --shadow-sm: 0 1px 2px rgba(23,20,43,.06);
    --radius: 10px;
    --radius-sm: 8px;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
svg.icon, i[data-feather] { width: 16px; height: 16px; vertical-align: -3px; }

/* ================= Layout applicatif (sidebar) ================= */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex-shrink: 0; display: flex; flex-direction: column;
    background: var(--sidebar-bg); border-right: 1px solid var(--border);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo {
    padding: 20px; font-weight: 700; font-size: 17px; color: var(--text);
    border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px;
}
.sidebar .logo .mark {
    width: 30px; height: 30px; background: var(--primary); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px; font-weight: 800;
}
.sidebar .logo .sub { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-left: auto; text-transform: uppercase; letter-spacing: .6px; }
.sidebar .nav-section { padding: 14px 0; border-bottom: 1px solid var(--border-light); }
.sidebar .nav-label {
    padding: 0 20px 6px; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim);
}
.sidebar a {
    display: flex; align-items: center; gap: 10px; padding: 10px 20px;
    color: var(--muted); font-size: 14px; font-weight: 500;
    border-left: 2px solid transparent; transition: all .15s;
}
.sidebar a:hover { background: var(--bg); color: var(--text); }
.sidebar a.active { background: var(--primary-light); color: var(--primary-dark); border-left-color: var(--primary); font-weight: 600; }
.sidebar .user-box {
    margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.sidebar .user-box .avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 13px; flex-shrink: 0;
}
.sidebar .user-box .info { flex: 1; min-width: 0; }
.sidebar .user-box .info .name { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user-box .info .role { font-size: 11.5px; color: var(--text-dim); }
.sidebar .user-box a { padding: 0; border: none; color: var(--muted); }
.sidebar .user-box a:hover { background: none; color: var(--danger); }

.main-content { flex: 1; padding: 28px 34px; max-width: 100%; overflow-x: hidden; }

/* ================= Topbar ================= */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.topbar h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.topbar .subtitle { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.live-dot {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
    background: var(--success-light); border: 1px solid #A7F3D0; border-radius: 20px;
    font-size: 12.5px; font-weight: 600; color: #047857;
}
.live-dot::before { content: ''; width: 7px; height: 7px; background: var(--success); border-radius: 50%; }

/* ================= Cartes ================= */
.card, section.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 16px; font-size: 16.5px; font-weight: 700; color: var(--text); }
.card h3 { margin: 20px 0 10px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }

/* ================= KPI ================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.kpi-card .kpi-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-weight: 700; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.kpi-card .kpi-label { font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.kpi-card .kpi-trend { font-size: 11.5px; margin-top: 8px; font-weight: 600; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-dim); }
.kpi-icon.violet { background: var(--primary-light); color: var(--primary-dark); }
.kpi-icon.green { background: var(--success-light); color: #047857; }
.kpi-icon.amber { background: var(--warning-light); color: #B45309; }
.kpi-icon.red { background: var(--danger-light); color: #B91C1C; }
.kpi-icon.blue { background: var(--info-light); color: #1D4ED8; }

/* ================= Tableaux ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-light); font-size: 14px; }
th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; border-bottom-color: var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: var(--bg); }
table.kv td:first-child { color: var(--muted); width: 220px; font-weight: 500; }
table.kv td { border-bottom: none; padding: 7px 0; }

/* ================= Badges / tags ================= */
.badge, .tag {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
    border-radius: 6px; font-size: 12px; font-weight: 600;
    background: var(--border-light); color: var(--muted); text-decoration: none;
}
.badge-success, .tag.live, .tag.verified { background: var(--success-light); color: #047857; }
.badge-danger, .tag.failed, .tag.expired, .tag.suspended, .tag.banned { background: var(--danger-light); color: #B91C1C; }
.badge-warning, .tag.test, .tag.queued, .tag.pending_pairing { background: var(--warning-light); color: #B45309; }
.badge-info, .tag.pending { background: var(--info-light); color: #1D4ED8; }
.badge-violet, .tag.active { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted { background: var(--border-light); color: var(--muted); }
.tag { margin: 1px 2px; }

/* ================= Boutons ================= */
button, .btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--primary); color: #fff; border: 1px solid transparent;
    padding: 10px 18px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit;
    text-decoration: none; transition: all .15s;
}
button:hover, .btn:hover { background: var(--primary-dark); color: #fff; }
button.secondary, .btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
button.secondary:hover, .btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

/* ================= Formulaires ================= */
form.inline { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin: 12px 0; }
form.inline label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13.5px; color: var(--text); }
input, select, textarea {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    padding: 11px 13px; border-radius: var(--radius-sm); font-size: 14.5px; font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* ================= Alertes / états ================= */
.flash, .alert-success { background: var(--success-light); border: 1px solid #A7F3D0; color: #047857; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; }
.error, .alert-danger { background: var(--danger-light); border: 1px solid #FECACA; color: #B91C1C; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; }
.alert-warning, .warn { background: var(--warning-light); border: 1px solid #FDE68A; color: #B45309; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; }
.empty-state { text-align: center; padding: 38px 20px; color: var(--text-dim); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }

/* ================= Divers ================= */
code { font-family: 'SF Mono', 'Fira Code', Monaco, Consolas, monospace; background: var(--bg); padding: 2px 7px; border-radius: 5px; font-size: 13px; color: var(--primary-dark); border: 1px solid var(--border-light); }
pre { background: #1A1030; color: #D8D0EA; padding: 16px 18px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 13.5px; line-height: 1.65; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.dot.on { background: var(--success); }
.dot.off { background: var(--danger); }
.progress { height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.progress .fill { height: 100%; border-radius: 3px; background: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.mb-3 { margin-bottom: 24px; } .mt-2 { margin-top: 16px; }
.tok { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; margin: 14px 0; word-break: break-all; font-size: 14px; color: var(--primary); font-family: Menlo, Consolas, monospace; }

/* QR */
.qr-card { text-align: center; }
.qr-card img { border-radius: 10px; background: #fff; padding: 10px; border: 1px solid var(--border); }
.qr-pop { position: relative; }
.qr-pop summary { cursor: pointer; color: var(--primary); font-size: 14px; font-weight: 600; list-style: none; }
.qr-pop[open] { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; z-index: 10; box-shadow: 0 8px 24px rgba(23,20,43,.12); }
details.client { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 12px; background: var(--surface); }
details.client summary { cursor: pointer; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-weight: 600; }
details.client[open] summary { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

/* ================= Auth ================= */
body.login, .auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--bg); }
.auth-card, body.login main.card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow-sm); }
.auth-card .brand, body.login .brand { text-align: center; margin-bottom: 26px; }
.brand .mark {
    width: 46px; height: 46px; background: var(--primary); border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 19px; margin-bottom: 14px;
}
body.login h1 { color: var(--text); margin: 0 0 4px; font-size: 24px; text-align: center; }
body.login h1 b { color: var(--primary); }
body.login .muted { text-align: center; display: block; }
body.login form { display: flex; flex-direction: column; gap: 16px; margin-top: 22px; }
body.login label { display: flex; flex-direction: column; gap: 7px; font-size: 14px; color: var(--text); font-weight: 600; }
.links { margin-top: 20px; font-size: 14px; text-align: center; }

@media (max-width: 900px) {
    .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main-content { padding: 20px; }
}
