/* ============================================
   Chiffrex Ads — Design System (Minimalist B&W)
   Black and White, clean, premium aesthetics
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #111111;
    --bg-card-hover: #1a1a1a;
    --bg-input: #111111;

    --border-subtle: #222222;
    --border-glow: #444444;

    --text-primary: #ffffff;
    --text-secondary: #999999;
    --text-muted: #666666;

    --accent-primary: #ffffff;
    --accent-secondary: #e5e5e5;
    --accent-gradient: linear-gradient(135deg, #ffffff, #cccccc);
    --accent-glow: rgba(255, 255, 255, 0.1);

    /* Keep semantic colors but muted/monochrome where appropriate */
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #ffffff;
    /* Blue replaced with white for links */

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(255, 255, 255, 0.05);

    --transition: 0.2s ease;

    --sidebar-width: 260px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Subtle grain or noise could be added, but user asked for "épuré" */
body::before {
    display: none;
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: opacity var(--transition);
}

a:hover {
    opacity: 0.8;
}

/* --- App Layout --- */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-logo h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 32px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 0 12px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-item.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-left: 2px solid var(--text-primary);
}

.nav-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    filter: grayscale(100%);
}

.sidebar-user {
    padding: 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-user .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-user .logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}

.sidebar-user .logout-btn:hover {
    color: var(--text-primary);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    background: var(--bg-secondary);
}

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

.main-header h2 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.main-header .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* --- Cards --- */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

/* --- Stats --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-card:hover {
    border-color: var(--text-muted);
}

.stat-card .stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* All icons monochrome */
.stat-card .stat-icon.purple,
.stat-card .stat-icon.blue,
.stat-card .stat-icon.green,
.stat-card .stat-icon.yellow,
.stat-card .stat-icon.red {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -1px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background: #cccccc;
    border-color: #cccccc;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
}

.btn-danger,
.btn-success {
    background: transparent;
    border-color: var(--border-subtle);
}

.btn-danger {
    color: var(--danger);
}

.btn-success {
    color: var(--success);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--danger);
}

.btn-success:hover {
    background: rgba(52, 211, 153, 0.1);
    border-color: var(--success);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.btn-icon {
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* --- Tables --- */
.table-container {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

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

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

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

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

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

table tbody td strong,
table tbody td a {
    color: var(--text-primary);
    font-weight: 500;
}

/* --- Badges --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-active,
.status-approved {
    color: var(--text-primary);
    border-color: var(--success);
}

.status-active::before,
.status-approved::before {
    background: var(--success);
}

.status-pending,
.status-draft,
.status-exhausted {
    color: var(--text-primary);
    border-color: var(--warning);
}

.status-pending::before,
.status-draft::before,
.status-exhausted::before {
    background: var(--warning);
}

.status-rejected,
.status-suspended,
.status-failed {
    color: var(--text-primary);
    border-color: var(--danger);
}

.status-rejected::before,
.status-suspended::before,
.status-failed::before {
    background: var(--danger);
}

.status-paused,
.status-completed,
.status-refunded {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.status-paused::before,
.status-completed::before,
.status-refunded::before {
    background: var(--text-muted);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(10px);
    transition: transform var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* --- Login Screen --- */
.login-screen {
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-card .logo-big {
    width: 64px;
    height: 64px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 32px;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.login-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 60px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 40px;
}

.login-feature {
    text-align: center;
}

.login-feature .feature-icon {
    font-size: 24px;
    margin-bottom: 8px;
    filter: grayscale(100%);
}

.login-feature .feature-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-feature .feature-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Misc --- */
.code-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    position: relative;
    border-radius: var(--radius-sm);
}

.code-box .copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    padding: 2px 8px;
    font-size: 10px;
    cursor: pointer;
    color: var(--text-primary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

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

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* --- Refined Table Styles --- */
.table-container table {
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Adds space between rows */
}

.table-container th {
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.table-container td {
    background: var(--bg-secondary);
    /* Row background */
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    padding: 16px;
    /* More padding */
}

.table-container td:first-child {
    border-left: 1px solid var(--border-subtle);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.table-container td:last-child {
    border-right: 1px solid var(--border-subtle);
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.table-container tr:hover td {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

/* --- Card Hover Lift --- */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--border-subtle);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: rgba(120, 100, 200, 0.3);
}

/* --- Empty State Enhancement --- */
.empty-state {
    padding: 60px 20px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.8;
}

/* --- Premium Buttons --- */
.btn {
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* --- Dashboard Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
}

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

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Icon Colors --- */
.stat-icon.purple {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.stat-icon.yellow {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* --- Icon Buttons --- */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* --- Standard Form Styles --- */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}