/* ==========================================================================
   DfLeads — admin.css
   Design system minimal, dark-friendly, lisible, sans framework.
   ========================================================================== */

:root {
    /* Couleurs DataFirefly */
    --bg:               #0f172a;
    --bg-2:             #1e293b;
    --bg-3:             #334155;
    --panel:            #1e293b;
    --panel-border:     #334155;
    --text:             #f1f5f9;
    --text-muted:       #94a3b8;
    --text-faint:       #64748b;
    --accent:           #f59e0b;
    --accent-hover:     #fbbf24;
    --primary:          #3b82f6;
    --primary-hover:    #60a5fa;
    --success:          #10b981;
    --warning:          #f59e0b;
    --danger:           #ef4444;
    --info:             #06b6d4;

    --radius:           6px;
    --radius-sm:        4px;
    --shadow:           0 1px 3px rgb(0 0 0 / 0.3);
    --shadow-lg:        0 8px 24px rgb(0 0 0 / 0.4);

    --sidebar-width:    220px;
    --font-mono:        'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    --font-sans:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Reset léger */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; color: var(--text); }
h3 { font-size: 1rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-3);
    color: var(--accent);
    padding: 0.1em 0.4em;
    border-radius: var(--radius-sm);
}

pre code { display: block; padding: 1em; overflow-x: auto; }

.muted { color: var(--text-muted); }
.muted.small { font-size: 0.875em; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
small { font-size: 0.875em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Layouts
   ========================================================================== */

.layout-admin {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.layout-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background:
        radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.08), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.08), transparent 40%),
        var(--bg);
}

.auth-wrap {
    width: 100%;
    max-width: 400px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-brand strong {
    display: block;
    font-size: 1.5rem;
    color: var(--accent);
}
.auth-brand small { color: var(--text-muted); }

.auth-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-faint);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 1rem;
}
.sidebar-brand strong {
    display: block;
    color: var(--accent);
    font-size: 1.15rem;
}
.sidebar-brand .version {
    color: var(--text-faint);
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.75rem;
}

.sidebar-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}
.sidebar-nav a:hover {
    background: var(--bg-3);
    color: var(--text);
}
.sidebar-nav a.active {
    background: var(--primary);
    color: white;
}

.sidebar-divider {
    height: 1px;
    background: var(--panel-border);
    margin: 0.75rem 0;
}

.sidebar-user {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--panel-border);
}
.sidebar-user .user-info { margin-bottom: 0.5rem; }
.sidebar-user strong { display: block; font-size: 0.875rem; }
.sidebar-user small { color: var(--text-faint); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }

.btn-logout {
    width: 100%;
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-logout:hover { background: var(--bg-3); color: var(--text); }

/* ==========================================================================
   Content
   ========================================================================== */

.content {
    padding: 1.5rem 2rem 4rem;
    max-width: 1400px;
}

.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 { margin-bottom: 0.25rem; }
.page-header.with-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.page-header .actions {
    display: flex;
    gap: 0.5rem;
}

/* ==========================================================================
   Stats
   ========================================================================== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.stat-card.highlight {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--panel), rgba(245, 158, 11, 0.05));
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-value {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.1;
    margin: 0.25rem 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 1rem; color: var(--text-muted); }
.stat-delta {
    color: var(--text-faint);
    font-size: 0.8rem;
}
.stat-delta:hover { color: var(--primary); }

/* ==========================================================================
   Grids
   ========================================================================== */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ==========================================================================
   Panel
   ========================================================================== */

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.panel h2 {
    margin-top: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--panel-border);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--panel-border);
}
.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--panel-border);
    vertical-align: top;
}
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.data-table.compact td, .data-table.compact th { padding: 0.4rem 0.6rem; }

.data-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1rem;
    margin: 0;
}
.data-list dt {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.data-list dd { margin: 0; }

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-block;
    padding: 0.15em 0.6em;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--text);
    text-transform: capitalize;
}

.badge-platform { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }

.badge-new        { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.badge-queued     { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-contacted  { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-opened     { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.badge-clicked    { background: rgba(168, 85, 247, 0.15); color: #c4b5fd; }
.badge-replied    { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge-qualified  { background: rgba(16, 185, 129, 0.25); color: #34d399; font-weight: 600; }
.badge-customer   { background: var(--success); color: white; font-weight: 600; }
.badge-bounced    { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge-unsubscribed, .badge-blacklisted, .badge-do_not_contact { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }

.badge-sent, .badge-delivered { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge-failed { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

.badge-interested       { background: var(--success); color: white; }
.badge-question         { background: rgba(59, 130, 246, 0.25); color: #93c5fd; }
.badge-not_interested   { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-auto_reply       { background: var(--bg-3); color: var(--text-muted); }
.badge-out_of_office    { background: var(--bg-3); color: var(--text-muted); }

/* Scores 0-100 (4 buckets) */
.score {
    font-weight: 600;
    padding: 0.1em 0.5em;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
}
.score-0 { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.score-1 { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.score-2 { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.score-3, .score-4 { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-stack label > span {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="tel"], input[type="number"],
select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font: inherit;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="url"]:focus, input[type="tel"]:focus, input[type="number"]:focus,
select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea { font-family: inherit; resize: vertical; }

label.inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
label.inline input[type="checkbox"] { width: auto; }

fieldset {
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1rem;
}
fieldset legend { padding: 0 0.5rem; color: var(--text-muted); font-size: 0.85rem; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--panel-border);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--bg-3);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: white; }
.btn-secondary { background: transparent; border-color: var(--panel-border); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-link {
    background: transparent;
    color: var(--text-muted);
    text-decoration: underline;
    padding: 0.5rem 0.5rem;
}
.btn-link:hover { color: var(--text); }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.85rem; }

/* ==========================================================================
   Flash messages
   ========================================================================== */

.flashes { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border-left: 3px solid;
}
.flash-success { background: rgba(16, 185, 129, 0.1); border-color: var(--success); color: #6ee7b7; }
.flash-error   { background: rgba(239, 68, 68, 0.1);  border-color: var(--danger);  color: #fca5a5; }
.flash-warning { background: rgba(245, 158, 11, 0.1); border-color: var(--warning); color: #fbbf24; }
.flash-info    { background: rgba(6, 182, 212, 0.1);  border-color: var(--info);    color: #67e8f9; }

/* ==========================================================================
   Filters bar
   ========================================================================== */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
}
.filters input, .filters select {
    width: auto;
    flex: 0 1 auto;
}
.filters input[type="text"]:first-child { flex: 1 1 200px; }

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
}

/* ==========================================================================
   Reply items
   ========================================================================== */

.reply-item {
    padding: 1rem;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    background: var(--bg);
}
.reply-item header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.reply-item h3 { margin: 0.5rem 0; }
.reply-body { white-space: pre-wrap; color: var(--text-muted); }

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Error details
   ========================================================================== */

.error-details {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    text-align: left;
}
.error-details pre {
    margin: 0.5rem 0;
    max-height: 300px;
    overflow: auto;
}

/* Responsive */
@media (max-width: 700px) {
    .layout-admin { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .content { padding: 1rem; }
    .page-header.with-actions { flex-direction: column; }
}
