/* ============================================================
   NetLinko Admin Dashboard
   Design System
   ============================================================ */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #eef0f4;
    --bg-dark: #0a0e1a;
    --bg-card: #ffffff;
    
    --text-primary: #0a0e1a;
    --text-secondary: #5a6478;
    --text-tertiary: #8b94a7;
    --text-inverse: #ffffff;
    
    --border-color: #e3e6ec;
    --border-strong: #c8cdd6;
    
    --accent: #0a0e1a;
    --accent-hover: #1a1f2e;
    
    --success: #00875a;
    --success-bg: #e6f4ee;
    --warning: #c4860a;
    --warning-bg: #fff4e0;
    --error: #c91c1c;
    --error-bg: #fdecec;
    --info: #0066cc;
    --info-bg: #e6f0ff;
    
    --shadow-sm: 0 1px 2px rgba(10, 14, 26, 0.05);
    --shadow-md: 0 4px 12px rgba(10, 14, 26, 0.08);
    --shadow-lg: 0 12px 32px rgba(10, 14, 26, 0.12);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --sidebar-width: 240px;
    --header-height: 64px;
    
    --font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand-name {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.login-brand-tagline {
    color: var(--text-tertiary);
    font-size: 13px;
    margin-top: 4px;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-input.error {
    border-color: var(--error);
    background: var(--error-bg);
}

.btn {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--text-tertiary); cursor: not-allowed; }

.btn-danger {
    background: var(--error);
    color: var(--text-inverse);
}
.btn-danger:hover { background: #a01616; }

.btn-success {
    background: var(--success);
    color: var(--text-inverse);
}
.btn-success:hover { background: #006e48; }

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #f5b5b5; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a8d8c2; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #f0d878; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #a8c8f0; }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard-body {
    background: var(--bg-secondary);
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-dark);
    color: var(--text-inverse);
    padding: 24px 0;
    z-index: 100;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-inverse);
    letter-spacing: -0.3px;
}

.sidebar-brand-tag {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.sidebar-section {
    padding: 16px 0;
}

.sidebar-section-title {
    padding: 0 24px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

.sidebar-link {
    display: block;
    padding: 10px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-inverse);
}

.sidebar-link.active {
    background: rgba(255,255,255,0.08);
    color: var(--text-inverse);
    border-left-color: var(--text-inverse);
    font-weight: 500;
}


.main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ============================================================
   HEADER — Style console professionnelle
   ============================================================ */
.main-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--header-height);
}

.main-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.main-title-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.main-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.main-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.main-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.icon-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-strong);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.icon-btn:active {
    transform: translateY(1px);
}

.icon-refresh {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.account-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 7px 10px 7px 10px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(10, 14, 26, 0.04), 0 8px 20px rgba(10, 14, 26, 0.06);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.account-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 2px 6px rgba(10, 14, 26, 0.08), 0 14px 28px rgba(10, 14, 26, 0.10);
}

.account-status,
.account-status-online {
    position: absolute;
    top: 9px;
    left: 39px;
    width: 12px;
    height: 12px;
    background: #16a34a !important;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
    z-index: 3;
}

.account-avatar {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-transform: uppercase;
    text-align: center;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

.account-details {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 140px;
    line-height: 1.12;
}

.account-kicker {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.account-name {
    margin-top: 3px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.account-role {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.account-logout {
    height: 32px;
    padding: 0 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.account-logout:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.main-content {
    padding: 32px;
}

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.stat-card.highlight {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

.stat-card.highlight .stat-card-label,
.stat-card.highlight .stat-card-value,
.stat-card.highlight .stat-card-sub {
    color: var(--text-inverse);
}

.stat-card.highlight .stat-card-label {
    color: rgba(255,255,255,0.7);
}

/* ============================================================
   PANELS / CARDS
   ============================================================ */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.panel-body {
    padding: 20px;
}

.panel-body.no-padding { padding: 0; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-primary);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: var(--bg-secondary);
}

.table-mono {
    font-family: "SF Mono", Monaco, "Courier New", monospace;
    font-size: 12px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.filters .form-input,
.filters select {
    max-width: 220px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 26, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ============================================================
   VOUCHER GENERATOR (AGENT)
   ============================================================ */
.profile-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.profile-option {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.profile-option:hover {
    border-color: var(--accent);
}

.profile-option.selected {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.profile-option-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-option-duration {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.profile-option-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.voucher-display {
    background: var(--bg-tertiary);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    margin: 20px 0;
}

.voucher-code-big {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 12px;
    color: var(--accent);
    margin-bottom: 8px;
    user-select: all;
}

.voucher-meta {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================================================
   LIVE INDICATOR
   ============================================================ */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-primary);
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 640px) {
    .main-header {
        padding: 12px 16px;
        align-items: flex-start;
        gap: 12px;
    }
    .main-header-left {
        align-items: flex-start;
    }
    .main-title {
        font-size: 16px;
    }
    .main-subtitle {
        display: none;
    }
    .main-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 8px;
    }
    .account-card {
        max-width: 100%;
        gap: 10px;
    }
    .account-details {
        min-width: 92px;
    }
    .account-kicker {
        display: none;
    }
    .account-name {
        max-width: 110px;
    }
    .account-logout {
        padding: 0 9px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .table th, .table td {
        padding: 10px 12px;
        font-size: 12px;
    }
    .filters .form-input {
        max-width: 100%;
        width: 100%;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-mono { font-family: "SF Mono", Monaco, "Courier New", monospace; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-tertiary); }
.text-sm { font-size: 12px; }
.text-bold { font-weight: 600; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
}

.empty-state-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state-text {
    font-size: 13px;
}

.loading {
    text-align: center;
    padding: 32px;
    color: var(--text-tertiary);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   CHARTS — Dimensions explicites
   ============================================================ */
.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-container-tall {
    height: 220px;
}

.chart-container canvas {
    max-width: 100% !important;
}

@media (max-width: 768px) {
    .chart-container {
        height: 240px;
    }
}

/* ============================================================
   ACCOUNT HEADER OVERRIDES
   Garder ces règles en bas du fichier pour éviter les anciens styles cachés en cache.
   ============================================================ */
.account-status,
.account-status-online {
    background: #16a34a !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18) !important;
}

.account-avatar {
    color: #ffffff !important;
    font-weight: 900 !important;
}


/* ============================================================
   KELPAY ADMIN MODULE
   ============================================================ */
.panel-subtitle {
    margin-top: 4px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group-grow {
    flex: 1 1 260px;
}

.btn-fixed {
    width: auto;
    min-width: 140px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kelpay-result {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
}

.kelpay-result-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.kelpay-balance-value {
    font-size: 34px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.8px;
    color: var(--text-primary);
}

.key-value-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.key-value-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.key-value-label {
    color: var(--text-tertiary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    margin-bottom: 4px;
}

.key-value-value {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.raw-json {
    margin-top: 14px;
    background: #0a0e1a;
    color: #ffffff;
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .form-grid.two-columns {
        grid-template-columns: 1fr;
    }

    .key-value-grid {
        grid-template-columns: 1fr;
    }

    .btn-fixed {
        width: 100%;
    }
}


/* ============================================================
   TRANSACTIONS KELPAY
   ============================================================ */
.table-transactions .transaction-id-cell {
    min-width: 190px;
    max-width: 260px;
}

.transaction-id {
    display: inline-block;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    user-select: all;
}

.text-select {
    user-select: all;
}
