/* ------------- PREMIUM GLOBAL STYLES ------------- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

.premium-container {
    font-family: 'Outfit', 'Inter', sans-serif;
    color: #1e293b;
    padding-bottom: 3rem;
}

/* Glassmorphism Cards */
.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 1);
    border-radius: 28px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    padding: 2.5rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.glass-panel:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

/* Gradients */
.gradient-text {
    background: linear-gradient(135deg, #10141a 0%, #475569 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* TomSelect : empêche le wrapper de déborder hors de sa cellule grid/flex */
.card-v2 form > div {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* V2 Components */
.card-v2 {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 1);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05); /* Softer shadow */
    padding: 2rem;
    transition: all 0.4s ease;
}

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

.card-title-v2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.stats-grid-v2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card-v2 {
    background: white;
    padding: 1.5rem;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    border: 1px solid #f1f5f9;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-val {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.stat-lab {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.2rem;
}

.badge-v2 {
    padding: 0.4rem 0.8rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.welcome-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.welcome-text h1 {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0;
    color: #0f172a;
}

.welcome-text p {
    color: #64748b;
    font-weight: 600;
    margin: 0.25rem 0 0;
}
.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.premium-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Premium Buttons */
.btn-premium {
    padding: 0.8rem 1.5rem;
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}
.btn-premium:hover {
    transform: translateY(-2px);
}
.btn-primary-gradient {
    background: linear-gradient(135deg, #10141a 0%, #334155 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 20, 26, 0.2);
}
.btn-primary-gradient:hover {
    box-shadow: 0 8px 25px rgba(16, 20, 26, 0.3);
    color: white;
}
.btn-success-gradient {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}
.btn-success-gradient:hover {
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
    color: white;
}
.btn-soft-primary {
    background: #e2e8f0;
    color: #0f172a;
}
.btn-soft-primary:hover {
    background: #cbd5e1;
}

/* ── Form Styles — alignés sur le style des champs de recherche ── */
.input-premium {
    width: 100%;
    min-height: 48px;
    padding: 0.72rem 1rem;
    border-radius: 12px;
    border: 1.5px solid rgba(203, 213, 225, 0.9);
    background: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-premium::placeholder {
    color: #94a3b8;
    font-weight: 500;
}
.input-premium:hover {
    border-color: rgba(148, 163, 184, 0.8);
    background: #fff;
}
.input-premium:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
    background: #fff;
}
.input-premium:disabled,
.input-premium[readonly] {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Select : même look que les inputs, chevron via le wrapper span/SVG */
select.input-premium,
select.form-control {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    height: 48px !important;
    padding: 0 2.5rem 0 1rem !important;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.85rem center !important;
    background-size: 1rem !important;
}

/* Label unifié */
.form-label-premium {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem !important;
    margin-top: 0.1rem;
}

/* Animations */
.slide-up-fade {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

@keyframes slideUpFade {
    to { opacity: 1; transform: translateY(0); }
}

/* Dynamic Grid */
.premium-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
@media (min-width: 900px) {
    .premium-grid {
        grid-template-columns: 2fr 1fr;
    }
}

/* Stats Cards */
.premium-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card-premium {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-value {
    font-weight: 800;
    font-size: 1.75rem;
    color: #0f172a;
    line-height:1.1;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.2rem;
}

/* Table Enhancements */
.table-row-hover {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s ease;
}
.table-row-hover:hover {
    background: #f8fafc;
}

.icon-btn-soft {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    text-decoration: none;
}
.icon-btn-soft:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: translateY(-2px);
}
.icon-btn-soft.hover-danger:hover {
    background: #fee2e2;
    color: #ef4444;
}
.icon-btn-soft.hover-success:hover {
    background: #dcfce7;
    color: #10b981;
}

/* =========================================================
   PREMIUM TABLE — base desktop (responsive override en bas)
========================================================= */
.premium-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    color: var(--text-main, #1e293b);
}

.premium-table thead {
    background: rgba(241, 245, 249, 0.6);
}

.premium-table thead th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #64748b);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.premium-table tbody td {
    padding: 1rem;
    border-bottom: 1px solid rgba(241, 245, 249, 0.8);
    font-size: 0.92rem;
    vertical-align: middle;
}

.premium-table tbody tr {
    transition: background 0.15s ease;
}

.premium-table tbody tr:hover {
    background: rgba(248, 250, 252, 0.7);
}

.premium-table tbody tr:last-child td {
    border-bottom: none;
}

.premium-table tfoot th,
.premium-table tfoot td {
    padding: 0.85rem 1rem;
    background: rgba(241, 245, 249, 0.5);
    font-weight: 700;
    font-size: 0.85rem;
}

/* =========================================================
   PREMIUM MOBILE RESPONSIVENESS
========================================================= */
@media (max-width: 768px) {
    /* Glass Panels */
    .glass-panel {
        padding: 1.25rem !important;
        border-radius: 20px !important;
    }
    
    .premium-container {
        padding-bottom: 2rem !important;
    }

    /* Page Headers */
    .page-header-flex, .header-glass {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
        padding: 1.25rem !important;
        border-radius: 16px !important;
    }
    
    .page-header-flex h1, .header-glass h1 {
        font-size: 1.75rem !important;
    }

    /* Actions */
    .premium-actions {
        width: 100% !important;
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
    }
    
    .premium-actions .btn-premium {
        flex: 1 1 100% !important;
        justify-content: center !important;
        text-align: center !important;
    }

    /* Buttons */
    .btn-premium {
        padding: 0.75rem 1.2rem !important;
        font-size: 0.9rem !important;
    }

    /* Table Responsiveness */
    .premium-table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .premium-table th, .premium-table td {
        white-space: nowrap !important;
        padding: 0.85rem 1rem !important;
    }
    
    /* Fixing border-radius issues on scrolling tables */
    .premium-table td:first-child { 
        border-radius: 12px 0 0 12px !important; 
    }
    .premium-table td:last-child { 
        border-radius: 0 12px 12px 0 !important; 
    }

    /* Fix all inline configured grids for mobile */
    .premium-stats-grid, div[style*="display: grid"], div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .stat-card-premium {
        padding: 1.25rem !important;
    }
    
    .stat-value {
        font-size: 1.5rem !important;
    }
    
    /* Disable sticky side panels on mobile so they don't block content */
    div[style*="position: sticky"], div[style*="position:sticky"] {
        position: relative !important;
        top: auto !important;
        z-index: 1 !important;
    }
    form[action*="GET"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    form[action*="GET"] > div {
        width: 100% !important;
    }
    
    .input-premium {
        font-size: 1rem !important; /* Prevents auto-zoom on iOS */
    }

    /* UI Elements */
    .client-avatar-premium {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.2rem !important;
    }
    
    .empty-state-card > div:first-child {
        width: 70px !important;
        height: 70px !important;
        font-size: 2.5rem !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .premium-actions .btn-premium {
        flex: 1 1 45% !important; /* Side-by-side on tablet/phablet */
    }
}

@media (max-width: 480px) {
    /* Very small devices */
    .premium-grid {
        gap: 1.25rem !important;
    }
    
    .status-pill, .status-badge-modern {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.6rem !important;
    }
}

/* ===== V2 Components — Mobile Responsive ===== */
@media (max-width: 768px) {
    .card-v2 {
        padding: 1.25rem !important;
        border-radius: 20px !important;
    }
    .card-header-v2 {
        flex-wrap: wrap;
        gap: 0.6rem;
        margin-bottom: 1.25rem !important;
    }
    .card-title-v2 {
        font-size: 1.05rem !important;
    }
    .stats-grid-v2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
    }
    .stat-card-v2 {
        padding: 1rem !important;
        border-radius: 16px !important;
        gap: 0.75rem !important;
    }
    .stat-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.05rem !important;
        border-radius: 11px !important;
    }
    .stat-val { font-size: 1.2rem !important; }
    .stat-lab { font-size: 0.62rem !important; }
    .badge-v2 {
        font-size: 0.65rem !important;
        padding: 0.3rem 0.55rem !important;
    }
    .welcome-section {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    .welcome-section .welcome-text h1 {
        font-size: 1.5rem !important;
    }
    .welcome-section .welcome-text p {
        font-size: 0.85rem !important;
    }
}

/* Filtres : 1 colonne garantie sur mobile strict ≤640px */
@media (max-width: 640px) {
    .card-v2 form[method="GET"],
    .card-v2 form[method="get"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.85rem !important;
        grid-template-columns: unset !important;
        align-items: stretch !important;
    }
    .card-v2 form[method="GET"] > div,
    .card-v2 form[method="get"] > div {
        width: 100% !important;
        min-width: 0 !important;
        grid-column: unset !important;
    }
    .card-v2 form[method="GET"] > div.fg-btns,
    .card-v2 form[method="get"] > div.fg-btns,
    .card-v2 form[method="GET"] > div.filter-btns,
    .card-v2 form[method="get"] > div.filter-btns {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
    }
    .card-v2 form[method="GET"] > div.fg-btns > *,
    .card-v2 form[method="get"] > div.fg-btns > *,
    .card-v2 form[method="GET"] > div.filter-btns > *,
    .card-v2 form[method="get"] > div.filter-btns > * {
        flex: 1 !important;
        height: 48px !important;
        min-width: 0 !important;
        justify-content: center !important;
    }
    /* Bouton direct enfant du form (sans wrapper div) — compatibilité prod */
    .card-v2 form[method="GET"] > button,
    .card-v2 form[method="get"] > button {
        width: 100% !important;
        height: 48px !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 480px) {
    .stats-grid-v2 {
        grid-template-columns: 1fr;
    }
    .card-v2 { padding: 1rem !important; }
    .stat-val { font-size: 1.4rem !important; }
}

/* Cache-bust: 2026-04-28 — receipt PDF redesign + stamp upload + login bypass */
