/* --- CONFIGURATION GLOBALE --- */
:root {
    --primary: #ec6111;
    --primary-hover: #d4560f;
    --dark: #1e293b;
    --text-gray: #64748b;
    --light-bg: #f8fafc;
    --sidebar-width: 260px;
    --header-height: 65px;
    --border: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.06);
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; /* Optimisation App */
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--light-bg); 
    color: var(--dark); 
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- LAYOUT STRUCTURE --- */
.container { 
    display: flex; 
    min-height: 100vh; 
    flex-direction: column; /* Mobile par défaut */
}

/* Sidebar optimisée pour Mobile & App */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    left: -100%; /* Caché sur mobile */
    top: 0;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

.sidebar.active {
    transform: translateX(100%);
    left: 0;
}

.main {
    flex: 1;
    padding: 20px;
    width: 100%;
    margin-left: 0;
    margin-top: var(--header-height); /* Espace pour le header mobile */
    transition: 0.3s;
}

/* --- MOBILE HEADER (Barre App) --- */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 0 20px;
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1500;
    box-shadow: var(--shadow);
}

.logo-mobile { height: 35px; width: auto; }

/* --- COMPOSANTS UI UNIFIÉS --- */
.card {
    background: var(--white);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* Grille adaptative (1 col sur mobile, multi sur PC) */
.grid {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 16px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-primary { background: var(--primary); color: white; width: 100%; } /* Boutons larges sur mobile */
.btn-primary:active { transform: scale(0.98); } /* Effet tactile App */

/* Formulaires */
.input-field {
    width: 100%;
    padding: 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 16px; /* Évite le zoom auto sur iPhone */
    transition: 0.3s;
}

/* --- MEDIA QUERIES (TABLETTES & PC) --- */
@media (min-width: 992px) {
    .container { flex-direction: row; }
    
    .sidebar { 
        left: 0; 
        position: sticky; 
        top: 0;
    }
    
    .main { 
        margin-top: 0; 
        padding: 30px; 
    }
    
    .mobile-header { display: none; }
    
    .grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
    
    .btn-primary { width: auto; }
}

/* --- OPTIMISATION TABLES SUR MOBILE --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

/* 1. VARIABLES & RESET */
:root {
    --primary: #ec6111;        /* Orange PIBLAY */
    --primary-hover: #d4560f;
    --dark: #0f172a;           /* Bleu Foncé */
    --light: #f8fafc;
    --gray: #64748b;
    --border: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--light);
    color: var(--dark);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* 2. MISE EN PAGE RESPONSIVE */
.main-wrapper {
    width: 100%;
    max-width: 450px; /* Taille idéale pour desktop et mobile */
}

.header-welcome {
    text-align: center;
    margin-bottom: 30px;
}

.header-welcome h1 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.header-welcome p {
    color: var(--gray);
    font-size: 0.95rem;
}

/* 3. LA CARTE D'AUTHENTIFICATION */
.auth-card {
    background: var(--white);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.logo-area {
    text-align: center;
    margin-bottom: 25px;
}

.logo-img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    margin-bottom: 10px;
}

.logo-area p {
    font-size: 0.85rem;
    color: var(--gray);
}

/* 4. ONGLETS (TABS) */
.tabs {
    display: flex;
    gap: 10px;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--gray);
    transition: 0.3s;
    border-radius: 8px;
    font-size: 0.9rem;
}

.tab.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 5. FORMULAIRES */
.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--dark);
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: 0.2s;
    background: #fdfdfd;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(236, 97, 17, 0.1);
}

/* 6. BOUTONS */
.btn-auth {
    width: 100%;
    padding: 14px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}

.btn-auth:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* 7. LIENS SECONDAIRES */
.forgot-link, .back-to-login {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    color: var(--primary);
    cursor: pointer;
    margin-bottom: 15px;
    text-decoration: none;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* 8. BOX SÉCURITÉ & UTILS */
.privacy-box {
    margin-top: 25px;
    padding: 12px;
    background: #f0fdf4; /* Vert très clair pour rassurer */
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: #166534;
}

.privacy-box ion-icon {
    font-size: 1.2rem;
    color: #22c55e;
}

.hidden {
    display: none;
}

/* 9. ADAPTATION MOBILE (MEDIA QUERIES) */
@media (max-width: 480px) {
    body {
        padding: 15px;
        align-items: flex-start; /* Permet le scroll sur petits écrans */
    }
    
    .auth-card {
        padding: 20px;
    }

    .header-welcome h1 {
        font-size: 1.5rem;
    }
}

/* CONTAINER DES PLANS */
.plans-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Crée des colonnes automatiques */
    gap: 30px;
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
}

/* CARTE DE PLAN */
.plan-card {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    border: 1px solid #e2e8f0;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.plan-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* PLAN MIS EN AVANT (BUSINESS PRO) */
.plan-card.featured {
    border: 2px solid var(--primary);
    transform: scale(1.05);
}

.badge-popular {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* RESPONSIVE SMARTPHONE */
@media (max-width: 768px) {
    .plans-container {
        grid-template-columns: 1fr; /* Une seule colonne sur mobile */
    }
    
    .plan-card.featured {
        transform: scale(1); /* On retire le zoom sur mobile pour éviter les bugs d'affichage */
        margin: 10px 0;
    }
    
    .header-section h1 {
        font-size: 1.5rem;
    }
}







/* --- WIDGET D'AIDE FLOTTANT --- */
.chat-floating {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background-color: var(--primary);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    transition: transform 0.3s ease, background 0.3s;
}

.chat-floating:hover {
    transform: scale(1.05);
    background-color: var(--primary-hover);
}

/* --- MENU CENTRE D'AIDE --- */
.chat-menu {
    position: fixed;
    bottom: 85px; /* Juste au-dessus du bouton */
    right: 25px;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: none; /* Caché par défaut */
    flex-direction: column;
    overflow: hidden;
    z-index: 3001;
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease-out;
}

.chat-menu.active {
    display: flex;
}

.chat-menu-header {
    background: var(--primary);
    color: white;
    padding: 18px;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
}

.chat-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    text-decoration: none;
    color: var(--dark);
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.chat-option:last-child {
    border-bottom: none;
}

.chat-option:hover {
    background-color: #f8fafc;
}

.chat-option ion-icon {
    font-size: 24px;
    min-width: 24px;
}

.chat-option strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.chat-option small {
    color: var(--gray);
    font-size: 0.8rem;
}

/* Animation d'apparition */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adaptation Mobile */
@media (max-width: 480px) {
    .chat-menu {
        width: calc(100% - 50px);
        right: 25px;
    }
}




.button-group {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    color: white;
    transition: opacity 0.3s;
}

.btn-test { background-color: #ec6111; } /* Couleur de marque orange */
.btn-factur { background-color: #2c3e50; }
.btn-analytics { background-color: #3498db; }

.btn:hover {
    opacity: 0.9;
}

.auto-save:focus {
    border-color: #ec6111;
    outline: none;
}





/** --- FONCTIONS DE BASE pou client  --- */
:root {
    --primary: #ec6111;
    --secondary: #1e293b;
    --bg: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
}

/* Layout de base */
.container { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--white); border-right: 1px solid var(--border); transition: 0.3s; }
.main { flex: 1; padding: 30px; background: var(--bg); overflow-x: hidden; }

/* Grilles responsives */
.grid-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px; margin-bottom: 25px;
}

.grid-charts {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Graphique de revenus plus large */
    gap: 20px; margin-bottom: 25px;
}

.card { background: var(--white); border-radius: 12px; padding: 20px; border: 1px solid var(--border); }

/* Table et filtres */
.filter-bar { display: flex; gap: 15px; flex-wrap: wrap; align-items: flex-end; }
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }

/* Navigation Mobile */
.mobile-nav-toggle { display: none; position: fixed; bottom: 20px; right: 20px; background: var(--primary); color: white; border: none; border-radius: 50%; width: 60px; height: 60px; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* --- MEDIA QUERIES --- */
@media (max-width: 1024px) {
    .grid-charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; height: 100%; z-index: 999; }
    .sidebar.active { left: 0; }
    .mobile-nav-toggle { display: flex; align-items: center; justify-content: center; }
    .main { padding: 15px; }
    .header { flex-direction: column; align-items: flex-start; gap: 15px; }
}







/* --- PIBLAY COPILOT WIDGET --- */

/* Le bouton flottant (Le Logo de l'Agence) */
.ai-widget-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%); /* Dégradé Violet/Bleu IA */
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(124, 58, 237, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 30px;
    z-index: 1000;
    transition: all 0.3s ease;
    border: 4px solid white;
}

.ai-widget-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 30px rgba(124, 58, 237, 0.5);
}

/* La fenêtre de chat (L'Agence IA) */
.ai-widget-window {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
    z-index: 999;
    display: none; /* Caché par défaut */
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.ai-widget-window.active {
    display: flex;
    animation: slideIn 0.4s ease;
}

/* Header de la fenêtre */
.ai-widget-header {
    background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-widget-header h3 { margin: 0; font-size: 1.2rem; }
.ai-widget-header p { margin: 5px 0 0 0; opacity: 0.8; font-size: 0.85rem; }

/* Zone de conversation */
.ai-widget-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Bulles de message */
.ai-message { padding: 12px 16px; border-radius: 12px; max-width: 80%; font-size: 0.9rem; line-height: 1.5; }
.ai-message.ai { background: white; color: #1e293b; align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.ai-message.user { background: #2563eb; color: white; align-self: flex-end; border-bottom-right-radius: 4px; }

/* Zone d'input */
.ai-widget-input {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
}

.ai-widget-input input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
}

/* Animations */
@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(124, 58, 237, 0); }
    100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

.ai-widget-bubble.pulse {
    animation: pulse-border 2s infinite;
}








