/**
 * Espace Client V2 - Experts & Entreprendre
 * Design moderne avec dark/light mode
 */

/* ==================== Variables CSS ==================== */
:root {
    /* Light Mode (default) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: rgba(16, 185, 129, 0.1);
    --accent-glow: rgba(16, 185, 129, 0.3);
    
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.2);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 30px var(--accent-glow);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
    
    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0a0f1a;
    --bg-secondary: rgba(15, 23, 42, 0.8);
    --bg-tertiary: #1e293b;
    --bg-hover: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border-color: #1e293b;
    --border-light: #334155;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* Background effects */
body::before {
    content: '';
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
    pointer-events: none;
    transform: translate(20%, -20%);
    z-index: -1;
}

body::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    width: 40%;
    height: 40%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.05) 0%, transparent 70%);
    pointer-events: none;
    transform: translate(-20%, 20%);
    z-index: -1;
}

/* ==================== Typography ==================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

/* ==================== Layout ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
}

/* ==================== Header ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    width: 48px;
    height: 48px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.header-logo svg {
    width: 24px;
    height: 24px;
    color: white;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.header-last-connect {
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.btn-icon {
    padding: 0.75rem;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-danger {
    background: var(--danger-light);
    border-color: transparent;
    color: var(--danger);
}

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

.btn svg {
    width: 20px;
    height: 20px;
}

/* ==================== Cards ==================== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ==================== Stats Grid ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    padding: 1.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.stat-value.success {
    color: var(--success);
}

.stat-value.warning {
    color: var(--warning);
}

/* ==================== Search & Filters ==================== */
.filters-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    background: var(--bg-hover);
}

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ==================== Table ==================== */
.table-card {
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
}

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

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

th.text-right {
    text-align: right;
}

th.text-center {
    text-align: center;
}

td {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}

tr {
    transition: background-color var(--transition-fast);
}

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

.cell-numero {
    font-family: var(--font-mono);
    font-weight: 500;
}

.cell-date {
    color: var(--text-muted);
}

.cell-montant {
    font-family: var(--font-mono);
    text-align: right;
}

.cell-montant-ttc {
    font-weight: 600;
}

/* ==================== Badges ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-famille {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-paye {
    background: var(--success-light);
    color: var(--success);
}

.badge-attente {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-inconnu {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-style: italic;
}

/* Badge Factur-X (facture électronique) */
.badge-facturx {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    cursor: help;
}

.badge-facturx svg {
    width: 14px;
    height: 14px;
}

.cell-numero {
    display: flex;
    align-items: center;
}

/* ==================== Empty State ==================== */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-muted);
    font-weight: 500;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
}

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

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

.modal-title {
    font-size: 1.25rem;
}

.modal-close {
    padding: 0.5rem;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.modal-body {
    margin-bottom: 2rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
}

.modal-footer .btn {
    flex: 1;
}

/* ==================== Form Elements ==================== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.toggle-label h4 {
    font-size: 0.875rem;
    font-weight: 500;
}

.toggle-label p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toggle {
    width: 52px;
    height: 28px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.toggle.active {
    background: var(--accent);
}

.toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

.toggle.active .toggle-knob {
    transform: translateX(24px);
}

/* ==================== Footer ==================== */
.footer {
    margin-top: 4rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer p {
    margin-bottom: 0.5rem;
}

/* ==================== Login Page ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: var(--shadow-glow);
}

.login-logo svg {
    width: 32px;
    height: 32px;
    color: white;
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-muted);
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .btn {
    width: 100%;
    padding: 1rem;
    margin-top: 0.5rem;
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}

.login-error.show {
    display: block;
}

/* ==================== Theme Toggle ==================== */
.theme-toggle {
    position: relative;
}

.theme-toggle .icon-theme {
    width: 22px;
    height: 22px;
    transition: transform 0.5s ease;
}

/* Éléments de l'icône */
.theme-toggle .sun-rays,
.theme-toggle .sun-circle,
.theme-toggle .moon-shadow {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Mode Dark: montrer le soleil (on clique pour passer en light) */
[data-theme="dark"] .theme-toggle .sun-rays {
    opacity: 1;
}

[data-theme="dark"] .theme-toggle .sun-circle {
    opacity: 1;
}

[data-theme="dark"] .theme-toggle .moon-shadow {
    opacity: 0.3;
}

[data-theme="dark"] .theme-toggle .icon-theme {
    transform: rotate(0deg);
}

/* Mode Light: montrer la lune (on clique pour passer en dark) */
[data-theme="light"] .theme-toggle .sun-rays {
    opacity: 0.3;
}

[data-theme="light"] .theme-toggle .sun-circle {
    opacity: 0.4;
}

[data-theme="light"] .theme-toggle .moon-shadow {
    opacity: 1;
}

[data-theme="light"] .theme-toggle .icon-theme {
    transform: rotate(-20deg);
}

/* Hover effect */
.theme-toggle:hover .icon-theme {
    transform: rotate(15deg) scale(1.1);
}

/* ==================== Notification Dot ==================== */
.notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

/* ==================== Loading ==================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

.fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
    }
    
    .filter-group {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }
    
    th, td {
        padding: 0.75rem 1rem;
    }
    
    .btn span {
        display: none;
    }
}

/* ==================== Dev Credit Footer ==================== */
.dev-credit-footer {
    margin-top: 1rem !important;
}

.dev-credit-footer a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    background: var(--bg-tertiary);
}

.dev-credit-footer a:hover {
    color: #0a66c2;
    background: rgba(10, 102, 194, 0.1);
}

.dev-credit-footer svg {
    flex-shrink: 0;
}

/* ==================== Suggestion Modal ==================== */
.suggestion-intro {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

#suggestion-send {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

#suggestion-send svg {
    flex-shrink: 0;
}

/* ==================== Print ==================== */
@media print {
    body::before,
    body::after,
    .header-actions,
    .filters-card,
    .btn-danger {
        display: none !important;
    }
    
    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}
