/* ==========================================================================
   WariGest - Feuille de Style Globale & Thèmes d'Impression
   ========================================================================== */

/* --- Polices & Variables --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,500&display=swap');

:root {
    --bg-dark: #090d16;
    --card-bg: rgba(22, 30, 49, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    
    --primary: #10b981;       /* Émeraude */
    --primary-rgb: 16, 185, 129;
    --primary-dark: #059669;
    
    --expense: #ef4444;       /* Rouge */
    --expense-rgb: 239, 68, 68;
    
    --revenue: #10b981;       /* Vert identique à Primary */
    --revenue-rgb: 16, 185, 129;

    --warning: #f59e0b;       /* Ambre */
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;
    
    --font-sans: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
}

/* --- Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(245, 158, 11, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
}

input, select, textarea, button {
    font-family: var(--font-sans);
    user-select: auto;
}

/* Eviter le zoom natif sur iPhone avec les inputs plus petits */
@media screen and (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* --- Structure Application (Single Page App) --- */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 62px; /* Espace pour la barre de navigation basse */
}

/* Vues dans #app-layout */
.app-view {
    display: none;
    padding: 20px 16px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeView 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-view.active {
    display: block;
}



@keyframes fadeView {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* En-tête de l'application */
.app-header {
    background: rgba(9, 13, 22, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-section {
    display: flex;
    flex-direction: column;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 40%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.company-selector-wrap {
    position: relative;
}

.company-badge-select {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barre de navigation du bas (Mobile First) — 7 onglets scrollables */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: rgba(15, 22, 38, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 100;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    /* Masquer la scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 600;
    gap: 3px;
    cursor: pointer;
    transition: color 0.2s;
    flex: 1;
    min-width: 16.66%; /* 100% / 6 */
    flex-shrink: 0;
    height: 100%;
    padding: 4px 2px;
    scroll-snap-align: start;
    position: relative;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s;
    z-index: 2;
    margin-bottom: 2px;
}

.nav-item span.nav-text {
    z-index: 2;
    transition: transform 0.3s, font-weight 0.3s, opacity 0.3s;
    opacity: 0.8;
}

/* Bulle d'arrière-plan */
.nav-item::before {
    content: '';
    position: absolute;
    width: 44px;
    height: 44px;
    background: rgba(22, 115, 255, 0.15); /* Couleur subtile de la bulle */
    border-radius: 50%;
    top: 2px;
    opacity: 0;
    transform: scale(0.5) translateY(10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.nav-item.active svg {
    transform: translateY(-4px) scale(1.15);
    color: var(--primary);
    filter: drop-shadow(0 4px 6px rgba(22, 115, 255, 0.3));
}

.nav-item.active span.nav-text {
    transform: scale(1.05);
    font-weight: 700;
    opacity: 1;
}

/* --- Cartes & Composants Graphiques --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:active {
    transform: scale(0.98);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tableau de bord - Métriques */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 800;
    word-break: break-all;
}

.metric-value.income { color: var(--revenue); }
.metric-value.expense { color: var(--expense); }

.balance-card {
    background: linear-gradient(135deg, rgba(22, 30, 49, 0.8) 0%, rgba(16, 185, 129, 0.08) 100%);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.balance-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.margin-badge {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Actions rapides */
.quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-quick {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 8px;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-quick:hover {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

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

/* --- Formulaires & Inputs --- */
.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.input-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    background: rgba(15, 23, 42, 0.8);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
}

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

/* Écran d'activation / Setup */
.lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lock-card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 30px 24px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.install-code-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--warning);
    letter-spacing: 1px;
    margin: 16px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
    user-select: all;
}

/* Sélecteur d'entreprise actif dropdown */
.company-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #141c2f;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 200;
    min-width: 180px;
    padding: 8px 0;
    margin-top: 6px;
    animation: slideDown 0.2s ease-out;
}

.company-dropdown-content.show {
    display: block;
}

.company-option {
    padding: 10px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.company-option:hover {
    background: rgba(255,255,255,0.05);
}

.company-option.active {
    color: var(--primary);
    font-weight: 600;
}

.divider {
    height: 1px;
    background: var(--card-border);
    margin: 6px 0;
}

/* Liste des transactions (Ledger) / Factures */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.list-item:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
}

.item-title {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.item-amount {
    font-weight: 800;
    font-size: 0.95rem;
}

.item-amount.income { color: var(--revenue); }
.item-amount.expense { color: var(--expense); }

.badge-status {
    padding: 3px 8px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-status.paye { background: rgba(16, 185, 129, 0.15); color: var(--primary); }
.badge-status.partiel { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-status.impaye { background: rgba(239, 68, 68, 0.15); color: var(--expense); }
.badge-status.brouillon { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }

/* --- Tableau d'Items de Facture --- */
.items-table-container {
    margin-bottom: 20px;
}

.invoice-item-row {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.5fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

/* Cache les flèches (spinners) des inputs number pour la facturation */
.invoice-item-row .input-control[type="number"]::-webkit-inner-spin-button, 
.invoice-item-row .input-control[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
.invoice-item-row .input-control[type="number"] {
    -moz-appearance: textfield;
}

.btn-remove-item {
    background: transparent;
    border: none;
    color: var(--expense);
    cursor: pointer;
    padding: 6px;
}

/* Modale de prévisualisation et plein écran */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(9, 13, 22, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 500;
    display: none;
    flex-direction: column;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

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

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.modal-footer {
    background: rgba(15, 22, 38, 0.95);
    border-top: 1px solid var(--card-border);
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
}

.template-selector-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
}

.btn-tab-template,
.btn-tab-template-inv {
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--card-border);
    background: rgba(255,255,255,0.03);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: all 0.15s ease;
}

.btn-tab-template.active,
.btn-tab-template-inv.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tpl-default-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f59e0b;
    color: #fff;
    font-size: 0.55rem;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: 900;
}

/* Graphique en CSS Simple */
.chart-container {
    height: 140px;
    margin-top: 15px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding-top: 10px;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    width: 14%;
}

.chart-bar-wrap {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 80px;
    width: 100%;
    justify-content: center;
}

.chart-bar {
    width: 8px;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.5s ease-out;
}

.chart-bar.income { background: var(--revenue); }
.chart-bar.expense { background: var(--expense); }

.chart-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 500;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50px;
}

.legend-color.income { background: var(--revenue); }
.legend-color.expense { background: var(--expense); }

/* Message vide */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.empty-state svg {
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.1);
}

/* Upload de Logo */
.logo-upload-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-preview-box {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    border: 1px dashed var(--card-border);
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-upload-btn-wrap {
    position: relative;
    overflow: hidden;
}

.logo-upload-btn-wrap input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 100%;
    min-height: 100%;
    font-size: 100px;
    text-align: right;
    filter: alpha(opacity=0);
    opacity: 0;
    outline: none;
    cursor: inherit;
    display: block;
}

/* ==========================================================================
   TEMPLATES D'IMPRESSION DE FACTURES (WIDGETS HAUTE FIDÉLITÉ)
   ========================================================================== */

.invoice-preview-container {
    background: #fff;
    color: var(--text-dark);
    padding: 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    line-height: 1.4;
    user-select: text;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
}

.invoice-preview-container * {
    user-select: text;
}

/* En-tête Commun */
.inv-header-flex {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
}

.inv-company-logo {
    max-height: 60px;
    max-width: 150px;
    object-fit: contain;
}

.inv-company-details h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
}

.inv-company-details p, .inv-client-details p, .inv-meta-list p {
    font-size: 0.8rem;
    color: #475569;
    margin-bottom: 2px;
}

.inv-meta-list strong {
    color: #1e293b;
}

.inv-title-section {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.inv-doc-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inv-number {
    font-size: 1.1rem;
    font-weight: 700;
}

.inv-people-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.inv-people-box h4 {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 4px;
}

.inv-people-box h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
}

/* Tableau d'items d'impression */
.inv-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    font-size: 0.8rem;
}

.inv-table th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    padding: 8px 10px;
    text-align: left;
}

.inv-table td {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.inv-totals-flex {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 30px;
}

.inv-totals-table {
    width: 240px;
    border-collapse: collapse;
}

.inv-totals-table td {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.inv-totals-table tr.grand-total td {
    font-size: 1.05rem;
    font-weight: 800;
    border-top: 2px solid #e2e8f0;
}

.inv-footer-note {
    font-size: 0.75rem;
    color: #64748b;
    border-top: 1px dashed #e2e8f0;
    padding-top: 12px;
    text-align: center;
}

/* --- STYLE UNIQUE 1 : MODERNE / TECH (Accents sombres, épuré) --- */
.invoice-template-modern {
    border-top: 8px solid var(--template-accent-color, #1e293b);
}
.invoice-template-modern .inv-doc-title {
    color: var(--template-accent-color, #1e293b);
}
.invoice-template-modern .inv-table th {
    background: var(--template-accent-color, #1e293b);
    color: #fff;
}
.invoice-template-modern .inv-totals-table tr.grand-total td {
    color: var(--template-accent-color, #1e293b);
    border-bottom: 2px double var(--template-accent-color, #1e293b);
}

/* --- STYLE UNIQUE 2 : CLASSIQUE / CORPORATE (Bleu Pro, structures formelles) --- */
.invoice-template-classic {
    border: 1px solid #cbd5e1;
}
.invoice-template-classic .inv-title-section {
    background: #f8fafc;
    padding: 12px;
    border-bottom: 2px solid var(--template-accent-color, #0f766e);
    margin: 0 -24px 20px -24px;
}
.invoice-template-classic .inv-doc-title {
    color: var(--template-accent-color, #0f766e);
}
.invoice-template-classic .inv-number {
    color: var(--template-accent-color, #0f766e);
}
.invoice-template-classic .inv-table th {
    background: #f1f5f9;
    color: var(--template-accent-color, #0f766e);
    border-bottom: 2px solid #cbd5e1;
}
.invoice-template-classic .inv-totals-table tr.grand-total td {
    color: var(--template-accent-color, #0f766e);
}

/* --- STYLE UNIQUE 3 : MINIMALISTE / ÉLÉGANT (Vert Émeraude, fin, aéré) --- */
.invoice-template-minimalist {
    padding: 30px;
}
.invoice-template-minimalist .inv-title-section {
    border-bottom: 1px solid var(--template-accent-color, #10b981);
}
.invoice-template-minimalist .inv-doc-title {
    color: var(--template-accent-color, #10b981);
    font-weight: 300;
}
.invoice-template-minimalist .inv-table th {
    border-bottom: 1px solid #e2e8f0;
    color: var(--template-accent-color, #10b981);
}
.invoice-template-minimalist .inv-table td {
    border-bottom: 1px solid #f8fafc;
}
.invoice-template-minimalist .inv-totals-table tr.grand-total td {
    color: var(--template-accent-color, #10b981);
}

/* --- STYLE UNIQUE 4 : CRÉATIF / COLORÉ (Ambre/Orange, bandeau latéral) --- */
.invoice-template-creative {
    position: relative;
    border-left: 12px solid var(--template-accent-color, #f59e0b);
}
.invoice-template-creative .inv-doc-title {
    color: var(--template-accent-color, #f59e0b);
}
.invoice-template-creative .inv-table th {
    background: rgba(245, 158, 11, 0.12);
    color: var(--template-accent-color, #d97706);
}
.invoice-template-creative .inv-table tr:nth-child(even) td {
    background: #fdfaf2;
}
.invoice-template-creative .inv-totals-table tr.grand-total td {
    color: var(--template-accent-color, #d97706);
}

/* --- STYLE UNIQUE 5 : BANDEAU / STRIPE (Indigo par défaut, bandeau en-tête coloré) --- */
.invoice-template-stripe {
    padding: 24px;
    border: 1px solid #e2e8f0;
}
.invoice-template-stripe .inv-totals-table tr.grand-total td {
    color: var(--template-accent-color, #4f46e5);
    border-bottom: 2px double var(--template-accent-color, #4f46e5);
}

/* --- STYLE UNIQUE 6 : PREMIUM / CORPORATE DELUXE (Rose/Carmin, double filet) --- */
.invoice-template-premium {
    padding: 30px;
    border-top: 8px solid var(--template-accent-color, #be123c);
    border-bottom: 8px solid var(--template-accent-color, #be123c);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}
.invoice-template-premium .inv-table th {
    background: #0f172a;
    color: #ffffff;
}
.invoice-template-premium .inv-table tr:nth-child(even) td {
    background: #f8fafc;
}
.invoice-template-premium .inv-totals-table tr.grand-total td {
    color: var(--template-accent-color, #be123c);
    border-bottom: 3px double var(--template-accent-color, #be123c);
}

/* ==========================================================================
   DIRECTIVES D'IMPRESSION (CRITIQUE POUR LA GÉNÉRATION DE PDF HORS-LIGNE)
   ========================================================================== */
@media print {
    /* Cacher tous les éléments de l'interface de l'application */
    body {
        background: #fff !important;
        color: #000 !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: auto !important;
    }
    
    .app-header, 
    .bottom-nav, 
    .app-view, 
    .modal-header,
    .template-selector-bar,
    .quick-actions,
    .fab-btn {
        display: none !important;
    }

    /* Afficher uniquement la modale active */
    .modal {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        background: #fff !important;
        display: block !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .modal-body {
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .invoice-preview-container {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        background: #fff !important;
        color: #000 !important;
    }

    /* Forcer le rendu couleur de fond et bordures pour les navigateurs */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Animation chargement PDF */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   THÈME CLAIR PREMIUM (LIGHT THEME OVERRIDES)
   ========================================================================== */
body.light-theme {
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    background-image: 
        radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.04) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(245, 158, 11, 0.02) 0px, transparent 50%);
}

body.light-theme .app-header {
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--card-border);
}

body.light-theme .app-title {
    background: linear-gradient(135deg, #0f172a 40%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .theme-toggle-btn {
    background: rgba(15, 23, 42, 0.04) !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    color: var(--text-muted) !important;
}

body.light-theme .theme-toggle-btn:hover {
    background: rgba(15, 23, 42, 0.08) !important;
    color: var(--text-main) !important;
}

body.light-theme .company-badge-select {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

body.light-theme .company-dropdown-content {
    background: #ffffff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    border-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .company-option {
    color: var(--text-main);
}

body.light-theme .company-option:hover {
    background: rgba(15, 23, 42, 0.04);
}

body.light-theme .bottom-nav {
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .nav-item {
    color: #64748b;
}

body.light-theme .nav-item.active {
    color: var(--primary);
}

body.light-theme .input-control {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
    color: var(--text-main) !important;
}

body.light-theme .input-control:focus {
    background: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

body.light-theme .modal {
    background: #f8fafc;
}

body.light-theme .modal-header {
    background: #ffffff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .modal-footer {
    background: #ffffff;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .btn-tab-template,
body.light-theme .btn-tab-template-inv {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.08);
    color: #64748b;
}

body.light-theme .btn-tab-template.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

body.light-theme .list-item {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.06);
}

body.light-theme .list-item:hover {
    background: rgba(16, 185, 129, 0.03);
}

body.light-theme .recent-title {
    color: var(--text-main);
}

body.light-theme .balance-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.2) !important;
}

body.light-theme .balance-card .balance-title {
    color: rgba(255, 255, 255, 0.8) !important;
}

body.light-theme .balance-card .balance-value {
    color: #ffffff !important;
}

body.light-theme .balance-card .margin-badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

body.light-theme .install-code-box {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
    color: var(--warning);
}

body.light-theme .dashboard-grid .metric-card {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .activity-list .activity-item {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.06);
}

body.light-theme .activity-list .activity-item:hover {
    background: rgba(16, 185, 129, 0.02);
}

/* Privacy eye toggle and Search bar enhancements */
#btn-privacy-toggle:hover {
    color: #ffffff !important;
    transform: scale(1.1);
}

body.light-theme #dash-search-input {
    background: rgba(15, 23, 42, 0.04) !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    color: var(--text-main) !important;
}

body.light-theme #dash-search-input:focus {
    background: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* ==========================================================================
   MODULE CLIENTS — Styles
   ========================================================================== */

.client-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.client-stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.client-stat {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 12px 10px;
    text-align: center;
}

.client-stat-value {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
}

.client-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
    display: block;
}

.client-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.85rem;
}

.client-info-row:last-child { border-bottom: none; }
.client-info-icon { color: var(--text-muted); flex-shrink: 0; }

/* ==========================================================================
   MODULE PROJETS / IDÉES / TÂCHES — Styles
   ========================================================================== */

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.project-card:hover { border-color: rgba(255,255,255,0.15); }

.project-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 16px 0 0 16px;
}

.project-card.en_cours::before { background: #3b82f6; }
.project-card.en_attente::before { background: var(--warning); }
.project-card.termine::before { background: var(--primary); }

.project-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 50px;
    margin-top: 10px;
    overflow: hidden;
}

.project-progress-fill {
    height: 100%;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    transition: width 0.4s ease;
}

.step-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.project-step-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.85rem;
}

.project-step-row:last-child { border-bottom: none; }

.step-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    background: transparent;
    padding: 0;
}

.step-checkbox.done {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.idea-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
}

.idea-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.idea-tag.Business { background: rgba(59,130,246,0.15); color: #60a5fa; }
.idea-tag.Marketing { background: rgba(245,158,11,0.15); color: var(--warning); }
.idea-tag.Produit { background: rgba(139,92,246,0.15); color: #a78bfa; }
.idea-tag.Technologie { background: rgba(16,185,129,0.15); color: var(--primary); }
.idea-tag.Autre { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.task-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.2s;
}

.task-item.done-task { opacity: 0.6; }

.task-checkbox-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--card-border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
    margin-top: 1px;
}

.task-checkbox-btn.checked {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.task-content { flex: 1; min-width: 0; }

.task-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.task-title.done-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.priority-badge {
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.priority-badge.high { background: rgba(239,68,68,0.15); color: var(--expense); }
.priority-badge.medium { background: rgba(245,158,11,0.15); color: var(--warning); }
.priority-badge.low { background: rgba(16,185,129,0.15); color: var(--primary); }

.task-due { font-size: 0.72rem; color: var(--text-muted); }
.task-due.overdue { color: var(--expense); font-weight: 700; }

.card-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.card-action-btn:hover { color: var(--expense); }

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
    border-color: var(--expense) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2) !important;
}

.switch-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Styles pour le clavier de verrouillage premium */
.pin-key {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 600;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
    margin: 0 auto;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.pin-key:active {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    transform: scale(0.92);
}

.pin-key.special-key {
    background: transparent;
    border: none;
    font-size: 1rem;
}

.pin-key.special-key:active {
    background: rgba(255, 255, 255, 0.05);
}

.pin-dot {
    background-color: transparent;
    box-shadow: none;
}

.pin-dot.filled {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 10px var(--primary);
}

.pin-dots-container.shake {
    animation: lockShake 0.4s ease-in-out;
}

@keyframes lockShake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-10px); }
    30%, 60%, 90% { transform: translateX(10px); }
}

/* --- BOTTOM SHEET TEMPLATES --- */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bottom-sheet-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.bottom-sheet-content {
    background: var(--bg-app);
    width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}
.bottom-sheet-overlay.open .bottom-sheet-content {
    transform: translateY(0);
}
.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
}
.template-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.template-card:active {
    transform: scale(0.95);
}
.template-card span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
}
.tpl-thumb {
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
