/* assets/css/style.css - Version SaaS Excellence (Nettoyée & Optimisée) */

/* =========================================
   1. VARIABLES & RESET (DESIGN TOKENS)
   ========================================= */
:root {
    /* Couleurs Principales */
    --primary: #2563eb;          /* Bleu Royal */
    --primary-hover: #1d4ed8;    /* Bleu Foncé */
    --primary-light: #eff6ff;    /* Bleu très pâle */
    
    /* Textes (Palette Slate) */
    --text-main: #1e293b;        /* Noir doux */
    --text-muted: #64748b;       /* Gris texte */
    --text-light: #94a3b8;       /* Gris clair */
    
    /* Structure */
    --bg-body: #f8fafc;          /* Fond de page */
    --bg-card: #ffffff;          /* Fond blanc */
    --border: #e2e8f0;           /* Bordure structurelle (légère) */
    --border-input: #cbd5e1;     /* Bordure inputs (plus visible) */
    
    /* Effets */
    --shadow-sm: 0 1px 2px 0 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);
    --radius: 8px;               /* Arrondi standard */
    --radius-lg: 12px;           /* Arrondi cartes */
}

* { box-sizing: border-box; }

html {
    font-size: 14px; /* C'est ÇA le secret : forcer la base à 14px pour tout le site */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 1rem; /* Hérite des 14px de html */
}
a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; padding: 0; margin: 0; }

/* Conteneur Global */
.container, .list-container, .view-container, .dashboard-container, .form-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* =========================================
   2. NAVBAR & HEADER
   ========================================= */
.navbar {
    background: var(--primary);
    color: white;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky; top: 0; z-index: 1000;
}

.nav-brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; color: white; }
.nav-links { display: flex; gap: 15px; align-items: center; }
.nav-link { color: rgba(255,255,255,0.9); font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.nav-link:hover { color: white; opacity: 1; }

.nav-btn { background: rgba(255,255,255,0.2); padding: 6px 12px; border-radius: 6px; font-weight: 600; }
.nav-btn:hover { background: rgba(255,255,255,0.3); }
.btn-new { background: white; color: var(--primary); }
.btn-new:hover { background: #f1f5f9; }

/* =========================================
   3. FORMULAIRES & INPUTS (SaaS Style)
   ========================================= */
/* Conteneur de formulaire centré */
.form-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 40px;
    box-shadow: var(--shadow-md);
    max-width: 900px;
    margin: 0 auto;
}

.form-group { margin-bottom: 20px; }
label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }

/* Champs de saisie - Design unifié */
.input-control, input[type="text"], input[type="email"], input[type="password"], select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-input); /* Gris plus visible */
    border-radius: var(--radius);
    background-color: white;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    color: var(--text-main);
}

.input-control:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* Champ Lecture Seule (Grisé) */
.input-readonly {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
    border-color: var(--border);
}

/* Zone Upload (Dropzone) */
.file-upload-wrapper { position: relative; width: 100%; }
.file-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    background-color: #f8fafc;
    transition: all 0.2s;
    cursor: pointer;
}
.file-dropzone:hover { border-color: var(--primary); background-color: #eff6ff; }
.dropzone-icon { font-size: 2rem; color: var(--primary); margin-bottom: 10px; }
.dropzone-text { font-weight: 500; color: var(--text-main); }
.dropzone-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 5px; }

/* Grilles Formulaire */
.form-grid, .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-1-3 { display: grid; grid-template-columns: 1fr 3fr; gap: 20px; }

/* =========================================
   4. BOUTONS & ACTIONS
   ========================================= */
.btn-submit, .btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%; padding: 14px;
    background-color: var(--primary);
    color: white;
    font-weight: 600; font-size: 1rem;
    border: none; border-radius: var(--radius);
    cursor: pointer; transition: 0.2s;
    box-shadow: var(--shadow-sm);
}
.btn-submit:hover, .btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); }

.action-btn { display: inline-flex; align-items: center; justify-content: center; padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; text-decoration: none; height: 34px; transition: 0.2s; }
.btn-view { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }
.btn-view:hover { background: #dbeafe; }
.btn-del { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; margin-left: 8px; cursor: pointer; }
.btn-del:hover { background: #ffe4e6; }

/* =========================================
   5. LISTES, TABLEAUX & DASHBOARD
   ========================================= */
/* Hero Header (Accueil) */
.hero-section {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    padding: 60px 0 90px;
    margin-bottom: -50px;
    text-align: center;
}
.hero-title { font-size: 2rem; font-weight: 700; margin-bottom: 10px; }
.hero-subtitle { font-size: 1.1rem; opacity: 0.9; font-weight: 300; }

/* Cartes Stats & Actions */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px; position: relative; z-index: 10; }
.stat-card { background: white; padding: 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 15px; transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-3px); }
.stat-icon { width: 50px; height: 50px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }

.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 40px; }
.action-card { background: white; border-radius: var(--radius-lg); padding: 25px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: all 0.3s; display: flex; align-items: center; gap: 20px; }
.action-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: #bfdbfe; }
.ac-icon { width: 60px; height: 60px; background: var(--primary-light); color: var(--primary); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; flex-shrink: 0; }
.action-card:hover .ac-icon { background: var(--primary); color: white; }

/* Filtres & Tableaux */
.page-header { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 25px 0; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }

.filter-bar { background: white; padding: 15px; border-radius: var(--radius-lg); border: 1px solid var(--border); margin-bottom: 25px; display: flex; gap: 15px; flex-wrap: wrap; }

.tickets-card, .recent-section { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm); }
.tickets-table, .custom-table { width: 100%; border-collapse: collapse; }
.tickets-table th, .custom-table th { background: #f8fafc; padding: 16px; text-align: left; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--border); }
.tickets-table td, .custom-table td { padding: 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 0.95rem; }
.tickets-table tr:hover { background-color: #f8fafc; }

/* Badges */
.badge, .status-badge, .badge-status { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; display: inline-block; white-space: nowrap; }
.st-nouveau, .status-nouveau { background: #dbeafe; color: #1e40af; }
.st-en_cours, .status-en_cours { background: #ffedd5; color: #9a3412; }
.st-attente, .status-attente_validation { background: #f3e8ff; color: #6b21a8; }
.st-resolu, .status-resolu { background: #dcfce7; color: #166534; }
.st-annule, .status-annule { background: #f1f5f9; color: #475569; }

/* =========================================
   6. VUE TICKET (CHAT / CONVERSATION)
   ========================================= */
.ticket-grid { display: grid; grid-template-columns: 1fr 350px; gap: 30px; align-items: start; }
.main-card, .side-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm); }
.card-header, .side-title { padding: 25px; border-bottom: 1px solid var(--border); }
.side-card { padding: 20px; }

.conversation-area { background: #f8fafc; padding: 25px; display: flex; flex-direction: column; gap: 20px; }
.msg-group { display: flex; gap: 15px; max-width: 90%; }
.msg-group.me { align-self: flex-end; flex-direction: row-reverse; } /* Inverse pour mettre l'avatar à droite */
.msg-group.internal { align-self: center; width: 100%; justify-content: center; }

.bubble { background: white; padding: 15px 20px; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); position: relative; }
.msg-group.me .bubble { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; border-bottom-right-radius: 2px; }
.msg-group:not(.me):not(.internal) .bubble { border-bottom-left-radius: 2px; }
.msg-group.internal .bubble { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; text-align: center; width: 100%; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: #cbd5e1; color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.8rem; flex-shrink: 0; }
.msg-group.me .avatar { background: var(--primary); }

.info-row { margin-bottom: 15px; }
.info-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; display: block; margin-bottom: 4px; }
.info-val { font-size: 0.95rem; font-weight: 500; display: block; }

/* =========================================
   7. PAGE LOGIN
   ========================================= */
.login-body { background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: white; width: 100%; max-width: 420px; padding: 40px; border-radius: 16px; box-shadow: var(--shadow-lg); text-align: center; }

/* =========================================
   8. RESPONSIVE MOBILE
   ========================================= */
@media (max-width: 900px) {
    /* Navbar compacte */
    .nav-brand span, .nav-link span { display: none; }
    
    /* Layouts en colonne unique */
    .ticket-grid, .form-grid, .grid-2, .grid-1-3, .stats-grid, .actions-grid { grid-template-columns: 1fr !important; gap: 20px; }
    .sidebar { order: 2; }
    
    /* Tableaux Scrollables */
    .tickets-card, .recent-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tickets-table, .custom-table { min-width: 600px; }
    
    /* Masquer colonnes secondaires */
    .tickets-table th:nth-child(3), .tickets-table td:nth-child(3),
    .tickets-table th:nth-child(4), .tickets-table td:nth-child(4) { display: none; }
    
    .form-card { padding: 20px; }
}
/* 3. TABLEAU RÉCENTS ÉPURÉ */
    .recent-section {
        background: white;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
        overflow: hidden;
        box-shadow: var(--shadow-sm);
    }
    .section-header {
        padding: 15px 25px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: white;
    }
    .custom-table { width: 100%; border-collapse: collapse; }
    .custom-table th { padding: 12px 25px; font-size: 0.75rem; text-align: left; background: #f8fafc; border-bottom: 1px solid #e2e8f0; color: var(--text-gray); text-transform: uppercase; }
    
    /* Correction du curseur et du survol */
    .custom-table tr { cursor: pointer; transition: background 0.1s ease; }
    .custom-table tr:hover td { background: #f8fafc; }
    
    .custom-table td { padding: 12px 25px; font-size: 0.9rem; border-bottom: 1px solid #f1f5f9; }
    .custom-table tr:last-child td { border-bottom: none; }