/* =========================================================================
   SAS SÉVIGNÉ - GESION ENTRETIEN - PREMIUM STYLES
   ========================================================================= */

   :root {
    --primary: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --secondary: #ec4899; /* Pink */

    /* Dark Theme Core (par défaut) */
    --bg-base: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.6);
    --bg-panel-hover: rgba(30, 41, 59, 0.8);
    --bg-input: rgba(15, 23, 42, 0.6);
    --bg-soft: rgba(0, 0, 0, 0.2);
    --bg-soft-strong: rgba(0, 0, 0, 0.3);
    --surface-overlay-1: rgba(255, 255, 255, 0.04);
    --surface-overlay-2: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-medium: rgba(255, 255, 255, 0.2);
    --border-dashed: rgba(255, 255, 255, 0.15);
    --modal-backdrop: rgba(0, 0, 0, 0.7);
    --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.3);
    --shape-opacity: 0.5;

    /* Text */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-on-primary: #ffffff;

    /* Status Colors (inchangé entre les 2 thèmes) */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #3b82f6;

    /* Styling */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme — activé via data-theme="light" sur <html> */
[data-theme="light"] {
    --bg-base: #eef2f6;
    --bg-panel: rgba(255, 255, 255, 0.78);
    --bg-panel-hover: rgba(255, 255, 255, 0.92);
    --bg-input: rgba(255, 255, 255, 0.92);
    --bg-soft: rgba(15, 23, 42, 0.05);
    --bg-soft-strong: rgba(15, 23, 42, 0.08);
    --surface-overlay-1: rgba(15, 23, 42, 0.03);
    --surface-overlay-2: rgba(15, 23, 42, 0.06);
    --border-light: rgba(15, 23, 42, 0.1);
    --border-medium: rgba(15, 23, 42, 0.18);
    --border-dashed: rgba(15, 23, 42, 0.18);
    --modal-backdrop: rgba(15, 23, 42, 0.45);
    --shadow-card-hover: 0 8px 25px rgba(15, 23, 42, 0.1);
    --shadow-glass: 0 8px 32px 0 rgba(15, 23, 42, 0.08);
    --shape-opacity: 0.18;
    --text-main: #0f172a;
    --text-muted: #475569;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* ====================================================
   DECORATIVE BACKGROUND
   ==================================================== */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: var(--shape-opacity);
    animation: float 20s infinite alternate;
}

.shape-1 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -20%;
    left: -10%;
}

.shape-2 {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    bottom: -20%;
    right: -10%;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

/* ====================================================
   LAYOUT & CONTAINERS
   ==================================================== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 2rem;
}

.hidden {
    display: none !important;
}

.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

/* ====================================================
   HEADER
   ==================================================== */
header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo i {
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.badge {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

/* ====================================================
   BUTTONS
   ==================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.05rem; /* Typographie plus grande pour le tactile */
    padding: 0.85rem 1.5rem;
    min-height: 48px; /* Touch target minimum standard Apple/Google */
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent; /* Retire le flash bleu sur mobile */
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn:disabled {
    opacity: 0.72;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn.is-loading {
    pointer-events: none;
}

.btn-secondary {
    background: var(--surface-overlay-2);
    color: var(--text-main);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-soft-strong);
    border-color: var(--border-medium);
}

.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.btn .loading-spinner {
    border-color: rgba(255, 255, 255, 0.28);
    border-top-color: currentColor;
}

.form-status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.85rem;
    min-height: 1.25rem;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.form-status .loading-spinner {
    width: 0.95rem;
    height: 0.95rem;
    border-color: rgba(255, 255, 255, 0.16);
    border-top-color: currentColor;
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface-overlay-2);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: rotate(15deg) scale(1.1);
}

/* ====================================================
   LOGIN VIEW
   ==================================================== */
.login-card {
    max-width: 600px;
    margin: 4rem auto;
    text-align: center;
}

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

.logo-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.btn-role {
    background: var(--surface-overlay-1);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.btn-role i {
    font-size: 2.5rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-role span {
    font-weight: 600;
    font-size: 1.1rem;
}

.btn-role small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-role:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    transform: translateY(-5px);
}

.btn-role:hover i {
    color: var(--primary);
    transform: scale(1.1);
}

/* ====================================================
   FORM (DEMANDEUR)
   ==================================================== */
.form-panel {
    max-width: 700px;
    margin: 0 auto;
}

.form-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 1.5rem;
}

.form-header h2 {
    font-size: 1.8rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    min-height: 48px; /* Essentiel pour le tap confort sur smartphone */
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    transition: var(--transition);
    -webkit-appearance: none; /* Nettoie le style iOS par défaut */
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.upload-area i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-area.is-busy,
.upload-trigger.is-busy {
    opacity: 0.72;
    pointer-events: none;
    border-color: rgba(99, 102, 241, 0.45) !important;
    background: rgba(99, 102, 241, 0.08);
}

/* Boutons photo agent : caméra + galerie (côte à côte, wrap sur très petit écran) */
.agent-photo-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.agent-photo-btn {
    cursor: pointer;
    flex: 1 1 130px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.85rem 1rem;
    border: 1px dashed var(--border-dashed);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.3s, background 0.2s;
}

.agent-photo-btn:hover,
.agent-photo-btn:focus-within {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.agent-photo-btn i {
    font-size: 1.1rem;
    color: var(--primary);
    flex-shrink: 0;
}

.agent-photo-btn span {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
}

@media (max-width: 360px) {
    .agent-photo-controls {
        flex-direction: column;
    }
    .agent-photo-btn {
        flex: 1 1 auto;
    }
}

.btn-block {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

/* ====================================================
   DASHBOARDS (TICKETS & ADMIN)
   ==================================================== */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.tickets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Ticket Card */
.ticket-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: var(--transition);
    cursor: pointer;
}

.ticket-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-glass);
}

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

.ticket-id {
    font-weight: 700;
    color: var(--primary);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.status-nondem { background: rgba(245, 158, 11, 0.2); color: var(--status-warning); border: 1px solid var(--status-warning); }
.status-badge.status-encours { background: rgba(59, 130, 246, 0.2); color: var(--status-info); border: 1px solid var(--status-info); }
.status-badge.status-termine { background: rgba(16, 185, 129, 0.2); color: var(--status-success); border: 1px solid var(--status-success); }

.ticket-body h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.ticket-body p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ticket-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-light);
    padding-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Admin Table */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filters {
    display: flex;
    gap: 1rem;
}

.filters select {
    width: auto;
    padding: 0.5rem 1rem;
}

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

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

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.85rem;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--surface-overlay-1);
}

/* ====================================================
   MODAL
   ==================================================== */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--modal-backdrop);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

/* ====================================================
   RESPONSIVE & MOBILE OPTIMIZATIONS
   ==================================================== */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem; /* Réduit le padding global sur petit écran */
    }

    .glass-panel {
        padding: 1.5rem; /* Plus d'espace pour le contenu */
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem; /* Réduit l'espace vertical entre champs empilés */
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filters {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .filters select {
        width: 100%;
    }

    .role-grid {
        grid-template-columns: 1fr; /* Une seule colonne verticale sur mobile */
    }

    /* Le tableau HTML n'est pas bon sur mobile, on force le défilement horizontal ou le display block */
    .data-table th, .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Le modal prend tout l'écran */
    .modal-content {
        max-height: 95vh;
        border-radius: var(--radius-md) var(--radius-md) 0 0; /* Tiroir du bas style iOS */
        position: absolute;
        bottom: 0;
        width: 100%;
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-actions button {
        width: 100%;
        margin: 0 !important;
    }
}
/* ====================================================
   ADMIN DASHBOARD - PREMIUM
   ==================================================== */

.admin-kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.admin-kpi-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.admin-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

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

.kpi-total::before { background: linear-gradient(to bottom, #6366f1, #818cf8); }
.kpi-pending::before { background: linear-gradient(to bottom, #f59e0b, #fbbf24); }
.kpi-progress::before { background: linear-gradient(to bottom, #3b82f6, #60a5fa); }
.kpi-done::before { background: linear-gradient(to bottom, #10b981, #34d399); }
.kpi-rate::before { background: linear-gradient(to bottom, #8b5cf6, #a78bfa); }

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.kpi-total .kpi-icon { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.kpi-pending .kpi-icon { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.kpi-progress .kpi-icon { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.kpi-done .kpi-icon { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.kpi-rate .kpi-icon { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

.kpi-data {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.admin-charts-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-chart-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.admin-chart-panel h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
}

.admin-chart-panel h4 i {
    color: var(--primary);
    font-size: 0.8rem;
}

.chart-container {
    position: relative;
    height: 140px;
    width: 100%;
}

.admin-filters-bar {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
}

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

.filter-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 350px;
}

.filter-search-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.filter-search-wrap input {
    padding-left: 38px;
    width: 100%;
}

.filter-select {
    width: auto;
    min-width: 140px;
    font-size: 0.88rem;
}

.filter-date-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-date-group input {
    width: 125px;
    font-size: 0.85rem;
}

.filter-date-sep {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0 2px;
}

.admin-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-list-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.admin-list-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 1024px) {
    .admin-kpi-row { grid-template-columns: repeat(3, 1fr); }
    .admin-charts-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .admin-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .admin-kpi-card:last-child { grid-column: 1 / -1; }
    .admin-charts-row { grid-template-columns: 1fr; }
    .filter-search-wrap { min-width: 100%; }
    .admin-filters-row { gap: 0.5rem; }
    .filter-select { min-width: 0; flex: 1; font-size: 0.82rem; }
}

/* ====================================================
   AGENT MOBILE EXPERIENCE - PREMIUM
   ==================================================== */

/* Agent Greeting */
.agent-greeting {
    margin-bottom: 1.25rem;
    padding: 0 0.25rem;
}

.agent-greeting h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    display: flex;
    align-items: center;
}

.agent-greeting p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* Stats Bar */
.agent-stats-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.agent-stat {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.4rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.agent-stat::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    opacity: 0.3;
    transition: var(--transition);
}

.agent-stat.urgent::after { background: var(--status-warning); }
.agent-stat.active::after { background: var(--status-info); }
.agent-stat.done::after { background: var(--status-success); }

.agent-stat.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
    transform: scale(1.03);
}

.agent-stat.selected::after {
    opacity: 1;
    height: 4px;
}

/* Chip BTC — clin d'œil agent, n'est pas un filtre cliquable */
.agent-stat-btc {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.agent-stat-btc::after {
    background: linear-gradient(90deg, #f7931a 0%, #ffaa3b 100%);
    opacity: 0.7;
}
.agent-stat-btc .agent-stat-count {
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}
.agent-stat-btc .agent-stat-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-variant-numeric: tabular-nums;
}
.agent-stat-btc .fa-bitcoin {
    color: #f7931a;
}
.agent-stat-btc.up #agent-stat-btc-change { color: #10b981; }
.agent-stat-btc.down #agent-stat-btc-change { color: #ef4444; }
.agent-stat-btc.stale { opacity: 0.55; }
/* Flash discret sur changement de prix */
.agent-stat-btc.flash-up { animation: btcFlashUp 800ms ease-out; }
.agent-stat-btc.flash-down { animation: btcFlashDown 800ms ease-out; }
@keyframes btcFlashUp {
    0% { background: rgba(16, 185, 129, 0.18); }
    100% { background: var(--bg-panel); }
}
@keyframes btcFlashDown {
    0% { background: rgba(239, 68, 68, 0.18); }
    100% { background: var(--bg-panel); }
}

.agent-stat:active {
    transform: scale(0.96);
}

.agent-stat-count {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 0.2rem;
}

.agent-stat.urgent .agent-stat-count { color: var(--status-warning); }
.agent-stat.active .agent-stat-count { color: var(--status-info); }
.agent-stat.done .agent-stat-count { color: var(--status-success); }

.agent-stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Building Color Bands */
.ticket-card.building-saint-louis { border-left: 4px solid #6366f1 !important; }
.ticket-card.building-place-espagne { border-left: 4px solid #ec4899 !important; }
.ticket-card.building-sup { border-left: 4px solid #06b6d4 !important; }

/* Agent Quick Actions */
.agent-quick-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    margin-top: 0.75rem;
}

.agent-quick-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--surface-overlay-1);
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.agent-quick-btn:active {
    transform: scale(0.95);
}

.agent-quick-btn.btn-start {
    color: var(--status-info);
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.08);
}

.agent-quick-btn.btn-done {
    color: var(--status-success);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

.agent-quick-btn.btn-details {
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.08);
}

/* Agent Photo Upload Enhanced */
.agent-photo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.06);
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.agent-photo-section:active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
}

.agent-photo-section i {
    font-size: 2.2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.agent-photo-section .photo-label-text {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
}

.agent-photo-section .photo-label-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.6;
    margin-top: 0.3rem;
}

/* Agent Action Bar */
.agent-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.agent-action-bar .btn {
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
}

/* Collapsible filters animation */
.agent-filters-panel {
    animation: slideDown 0.3s ease;
}

/* =========================================================================
   GRILLE DE PRÉVISUALISATION MULTI-PHOTOS
   ========================================================================= */

.photo-previews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.photo-preview-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-preview-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-tile > i {
    font-size: 1.8rem;
    color: var(--primary);
}

.photo-preview-tile > span.filename {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 0.65rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.2rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s;
}

.photo-preview-remove:hover,
.photo-preview-remove:active {
    background: var(--status-danger);
}

/* =========================================================================
   BANDEAU NOUVELLE VERSION DISPONIBLE (Service Worker update)
   ========================================================================= */

.sw-update-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    width: 520px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(79, 70, 229, 0.95));
    color: white;
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    z-index: 10000;
    animation: swBannerSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes swBannerSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.sw-update-text {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.3;
}

.sw-update-text i {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sw-update-btn {
    background: white;
    color: var(--primary);
    border: none;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.sw-update-close {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.sw-update-close:hover,
.sw-update-close:active {
    background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 600px) {
    .sw-update-banner {
        bottom: 8px;
        padding: 10px 12px;
    }
    .sw-update-text {
        font-size: 0.82rem;
    }
    .sw-update-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

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

/* Building legend */
.building-legend {
    display: flex;
    gap: 1rem;
    padding: 0.25rem 0;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.building-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.building-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .agent-stats-bar {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.4rem;
    }
    /* Sur mobile : les 4 stats tickets sur une ligne, BTC sur la suivante en pleine largeur */
    .agent-stat-btc {
        grid-column: 1 / -1;
        flex-direction: row;
        gap: 12px;
        padding: 0.55rem 0.8rem;
    }
    .agent-stat-btc .agent-stat-count {
        font-size: 1rem;
    }

    .agent-stat {
        padding: 0.65rem 0.2rem;
    }

    .agent-stat-count {
        font-size: 1.35rem;
    }

    .agent-greeting h2 {
        font-size: 1.2rem;
    }

    .building-legend {
        gap: 0.6rem;
    }
}

/* ====================================================
   TOAST NOTIFICATIONS & ANIMATIONS ULTIMES
   ==================================================== */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'Outfit', sans-serif;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success { border-left-color: var(--status-success); }
.toast.error { border-left-color: var(--status-danger); }
.toast.warning { border-left-color: var(--status-warning); }

.toast i { font-size: 1.25rem; }

/* Table Row Animation */
@keyframes fadeRowIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.data-table tbody tr {
    animation: fadeRowIn 0.3s ease-out forwards;
}

/* Empty State Illustration */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}
.empty-state h3 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

/* =========================================================================
   MODALE NOUVEAU TICKET (Agent + Admin)
   Mobile-first, optimisée pour usage tactile par l'agent d'entretien.
   ========================================================================= */
.new-ticket-modal-content {
    max-width: 560px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.new-ticket-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}
.nt-section {
    margin-bottom: 1.25rem;
}
.nt-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.nt-label i {
    color: var(--primary);
}
.nt-required {
    color: var(--status-danger, #ef4444);
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}
.nt-optional {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
}

/* --- Section "Pour qui ?" --- */
.nt-requester-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-md);
}
.nt-requester-chip > span:first-child {
    font-weight: 600;
    color: var(--text-main);
}
.nt-requester-status-tag {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.nt-requester-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.nt-requester-chip-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: var(--text-main);
    cursor: pointer;
    transition: all 150ms ease;
    font-family: inherit;
}
.nt-requester-chip-btn i {
    font-size: 1.2rem;
    color: var(--primary);
}
.nt-requester-chip-btn span {
    font-size: 0.9rem;
    font-weight: 600;
}
.nt-requester-chip-btn small {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.nt-requester-chip-btn.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
}
.nt-requester-chip-btn:hover {
    transform: translateY(-1px);
}
.nt-other-fields {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

/* --- Tuiles bâtiment (grosses, tactiles) --- */
.nt-building-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.nt-building-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 90px;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
    -webkit-tap-highlight-color: transparent;
}
.nt-building-tile:active {
    transform: scale(0.96);
}
.nt-building-tile.selected {
    border-color: var(--building-color, var(--primary));
    background: color-mix(in srgb, var(--building-color, var(--primary)) 14%, transparent);
    transform: scale(1.02);
}
.nt-building-tile.selected::after {
    content: "✓";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--building-color, var(--primary));
}
.nt-building-tile {
    position: relative;
}
.nt-building-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.nt-building-name {
    text-align: center;
    line-height: 1.15;
}

/* --- Entreprise extérieure : lien + mini-form inline --- */
.nt-link-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.nt-link-btn:hover {
    text-decoration: underline;
}
.nt-add-company-inline {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    align-items: center;
}
.nt-add-company-inline .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* --- Actions modale --- */
.new-ticket-actions {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 12px;
    gap: 10px;
}
.new-ticket-actions .btn-primary {
    flex: 1;
    font-weight: 700;
}
.new-ticket-actions .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-muted);
    transform: none;
}

/* --- Photo deletion (bouton sur vignette) --- */
.photo-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: background 150ms ease;
    z-index: 2;
}
.photo-delete-btn:hover {
    background: var(--status-danger, #ef4444);
}

/* --- Adaptation mobile : modale en plein écran --- */
@media (max-width: 640px) {
    .new-ticket-modal-content {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    .nt-building-grid {
        grid-template-columns: 1fr;
    }
    .nt-building-tile {
        flex-direction: row;
        justify-content: flex-start;
        min-height: 64px;
        padding: 14px 16px;
    }
    .nt-building-name {
        text-align: left;
        font-size: 1rem;
    }
    .nt-add-company-inline {
        grid-template-columns: 1fr;
    }
    .new-ticket-actions {
        position: sticky;
        bottom: 0;
        background: var(--bg-elevated, rgba(20, 20, 30, 0.95));
        backdrop-filter: blur(8px);
        margin: 0 -16px -16px;
        padding: 12px 16px;
    }
}
