/* 
   ==========================================
   PREMIUM ANIMATIONS & EFFECTS
   Améliorations Premium pour un Design Attractif
   ==========================================
*/

/* ========================
   ANIMATIONS AVANCÉES
   ======================== */

/* Animation Glassmorphism des Cartes */
@keyframes glassAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation fluide des panels */
@keyframes panelSlideInSmooth {
    0% {
        opacity: 0;
        transform: translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation du chargement premium */
@keyframes loadingPulsePremium {
    0% {
        background: linear-gradient(90deg, var(--bg-card) 0%, rgba(40, 114, 161, 0.1) 50%, var(--bg-card) 100%);
        background-size: 200% 100%;
        background-position: 200% 0;
    }
    50% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Animation des boutons hover 3D */
@keyframes buttonPress {
    0% {
        transform: translateY(0) scale(1);
        box-shadow: 0 8px 20px rgba(40, 114, 161, 0.3);
    }
    50% {
        transform: translateY(-3px) scale(1.02);
        box-shadow: 0 12px 30px rgba(40, 114, 161, 0.5);
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 8px 20px rgba(40, 114, 161, 0.3);
    }
}

/* Effet de ripple au clic */
@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 0.8;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* Animation des badges */
@keyframes badgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Animation des cartes en hover */
@keyframes cardLift {
    0% {
        transform: translateY(0) rotateX(0);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    }
    100% {
        transform: translateY(-8px) rotateX(2deg);
        box-shadow: 0 16px 40px rgba(40, 114, 161, 0.3);
    }
}

/* Bounce délicat */
@keyframes subtleBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Glow effect */
@keyframes glowEffect {
    0%, 100% {
        box-shadow: 0 0 5px rgba(40, 114, 161, 0.3), 0 0 10px rgba(40, 114, 161, 0.1);
    }
    50% {
        box-shadow: 0 0 10px rgba(40, 114, 161, 0.6), 0 0 20px rgba(40, 114, 161, 0.3);
    }
}

/* Shimmer loading */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Rotation subtile */
@keyframes subtleRotate {
    0%, 100% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(1deg);
    }
}

/* ========================
   EFFETS PREMIUM SUR LES ÉLÉMENTS
   ======================== */

/* Amélioration des boutons */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.btn:hover {
    animation: buttonPress 0.6s ease-out;
    transform: translateY(-2px);
    letter-spacing: 0.5px;
}

.btn:active::before {
    animation: ripple 0.6s ease-out;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #1e5a82 100%);
    box-shadow: 0 8px 20px rgba(40, 114, 161, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e5a82 0%, var(--primary) 100%);
    box-shadow: 0 12px 30px rgba(40, 114, 161, 0.5);
}

/* Amélioration des cartes */
.panel,
.stat-card,
.leads-kpi-card,
.settings-card {
    animation: glassAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(22, 102, 215, 0.4);
}

.panel:hover,
.stat-card:hover,
.leads-kpi-card:hover,
.settings-card:hover {
    animation: cardLift 0.3s ease-out forwards;
    border-color: rgba(22, 102, 215, 0.65);
}

/* Cartes échelonnées */
.panel:nth-child(1) { animation-delay: 0.1s; }
.panel:nth-child(2) { animation-delay: 0.2s; }
.panel:nth-child(3) { animation-delay: 0.3s; }
.panel:nth-child(4) { animation-delay: 0.4s; }
.panel:nth-child(5) { animation-delay: 0.5s; }

/* Badges animés */
.badge {
    animation: badgePop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: inline-block;
}

/* Input/Select améliorés */
.form-control {
    background: rgba(16, 36, 52, 0.6);
    border: 2px solid rgba(22, 102, 215, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.form-control:focus {
    background: rgba(16, 36, 52, 0.8);
    border-color: rgba(22, 102, 215, 0.65);
    box-shadow: 0 0 0 3px rgba(22, 102, 215, 0.2), inset 0 0 0 2px rgba(22, 102, 215, 0.1);
    animation: subtleBounce 0.4s ease-out;
}

.form-control:hover:not(:focus) {
    border-color: rgba(22, 102, 215, 0.5);
    background: rgba(16, 36, 52, 0.7);
}

/* Tables fluides */
.leads-table {
    border-collapse: separate;
    border-spacing: 0 8px;
    animation: panelSlideInSmooth 0.5s ease-out;
}

.leads-table tbody tr {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.leads-table tbody tr:hover {
    background: rgba(40, 114, 161, 0.1);
    transform: translateX(4px);
    box-shadow: -4px 0 12px rgba(40, 114, 161, 0.2);
    border-radius: 8px;
}

/* Liens avec underline animé */
a {
    position: relative;
    text-decoration: none;
}

a:not(.sidebar-nav-link):not(.btn)::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), transparent);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:not(.sidebar-nav-link):not(.btn):hover::after {
    width: 100%;
}

/* Titres avec gradient */
h1, h2, h3, h4, h5, h6 {
    background: linear-gradient(135deg, var(--text-main) 0%, rgba(203, 221, 233, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: panelSlideInSmooth 0.5s ease-out;
}

/* ========================
   CHARGEMENT PREMIUM
   ======================== */

.loading-skeleton {
    background: linear-gradient(90deg, 
        var(--bg-card) 0%, 
        rgba(40, 114, 161, 0.1) 50%, 
        var(--bg-card) 100%);
    background-size: 200% 100%;
    animation: loadingPulsePremium 2s infinite;
    border-radius: 8px;
}

.spinner-premium {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(40, 114, 161, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.import-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

/* ========================
   AMÉLIORATIONS DES MODALITÉS
   ======================== */

.modal-overlay {
    backdrop-filter: blur(8px);
    background: rgba(11, 29, 42, 0.6);
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

.modal-content {
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ========================
   BARRE DE NAVIGATION
   ======================== */

.sidebar-nav-link {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, var(--primary), #5499C7);
    transform: translateY(-50%);
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 2px 2px 0;
}

.sidebar-nav-link.active::before {
    height: 24px;
}

.sidebar-nav-link:hover {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.08) 100%) !important;
    color: #ffffff !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 4px 14px rgba(0, 0, 0, 0.1) !important;
    transform: translateX(4px);
}

.sidebar-nav-link:hover .sidebar-nav-icon,
.sidebar-nav-link:hover [data-lucide] {
    color: #ffffff !important;
    transform: scale(1.12);
}

.sidebar-nav-link:hover .sidebar-nav-label {
    color: #ffffff !important;
}

/* ========================
   EFFET GLASSMORPHISM
   ======================== */

.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.glass-panel:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .glass-panel {
    background: #ffffff !important;
    border-color: rgba(226, 232, 240, 0.9) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .glass-panel:hover {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
}

/* ========================
   COULEURS DÉGRADÉES
   ======================== */

.gradient-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #5499C7 100%);
}

.gradient-success {
    background: linear-gradient(135deg, #27AE60 0%, #1E8449 100%);
}

.gradient-warning {
    background: linear-gradient(135deg, #F39C12 0%, #E67E22 100%);
}

.gradient-danger {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

/* ========================
   AMÉLIORATION DU SCROLL
   ======================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(40, 114, 161, 0.05);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), #5499C7);
    border-radius: 10px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5499C7, var(--primary));
    box-shadow: 0 0 10px rgba(40, 114, 161, 0.3);
}

/* ========================
   ANIMATIONS D'ICÔNES
   ======================== */

[data-lucide] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover [data-lucide],
.sidebar-nav-link:hover [data-lucide] {
    animation: subtleRotate 0.4s ease-out;
}

/* ========================
   RESPONSIVE PREMIUM
   ======================== */

@media (max-width: 768px) {
    .panel,
    .stat-card {
        animation-delay: 0s !important;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .form-control {
        padding: 10px 12px;
    }
}

/* ========================
   MODE SOMBRE AVANCÉ
   ======================== */

[data-theme="dark"] {
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-float: 0 20px 40px rgba(0, 0, 0, 0.7);
}

[data-theme="light"] {
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);
    --shadow-float: 0 20px 40px rgba(0, 0, 0, 0.25);
}

/* ========================
   ANIMATIONS DE STATISTIQUES
   ======================== */

.stat-value {
    animation: slideUpNumber 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ========================
   AMÉLIORATIONS D'ACCESSO RAPIDITÉ
   ======================== */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, a, input {
    -webkit-tap-highlight-color: transparent;
}

/* Réduction des animations pour utilisateurs préférant moins de mouvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===================================================
   ÉDITEUR ENRICHI DE SCRIPTS COMMERCIAUX (WYSIWYG)
   =================================================== */

.script-editor-wrapper {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 12px;
    background: var(--bg-card, #ffffff);
    overflow: visible;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.script-editor-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18), 0 8px 24px rgba(0, 0, 0, 0.08);
}

.script-editor-wrapper.fullscreen-mode {
    position: fixed !important;
    top: 15px !important;
    left: 15px !important;
    right: 15px !important;
    bottom: 15px !important;
    z-index: 99999 !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5) !important;
    border: 2px solid #6366f1 !important;
    border-radius: 16px !important;
    background: var(--bg-card, #1e293b) !important;
}

.script-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-card-alt, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    border-top-left-radius: 11px;
    border-top-right-radius: 11px;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.45rem;
    margin-right: 0.35rem;
    border-right: 1px solid var(--border-color, #e2e8f0);
}

.toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main, #334155);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.toolbar-btn:hover {
    background: var(--bg-hover, #e2e8f0);
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.2);
}

.toolbar-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
    border-color: #6366f1;
}

.toolbar-select {
    height: 32px;
    padding: 0 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--bg-card, #ffffff);
    color: var(--text-main, #334155);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.toolbar-select:focus {
    border-color: #6366f1;
}

/* Color & Highlight Picker Buttons */
.toolbar-color-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.toolbar-color-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--bg-card, #ffffff);
    color: var(--text-main, #334155);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toolbar-color-btn:hover {
    background: var(--bg-hover, #f1f5f9);
    border-color: #6366f1;
}

.color-bar-indicator {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: #2563eb;
}

.color-palette-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 10000;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 10px;
    padding: 0.6rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: none;
    min-width: 190px;
}

.color-palette-dropdown.show {
    display: block;
    animation: fadeInMenu 0.15s ease;
}

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

.palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 0.6rem;
}

.palette-swatch {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.palette-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    z-index: 2;
}

.palette-custom-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
}

.palette-custom-row input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: none;
}

/* Variable Chips Section */
.script-variables-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    background: rgba(99, 102, 241, 0.04);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    font-size: 0.8rem;
}

.script-variables-label {
    font-weight: 700;
    color: #6366f1;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 0.25rem;
}

.variable-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-card, #ffffff);
    border: 1px solid #6366f1;
    color: #6366f1;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.variable-chip:hover {
    background: #6366f1;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(99, 102, 241, 0.25);
}

/* Content Editable Area */
.script-editor-body {
    min-height: 250px;
    max-height: 520px;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-main, #1e293b);
    outline: none;
    background: var(--bg-card, #ffffff);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.script-editor-wrapper.fullscreen-mode .script-editor-body {
    max-height: calc(100vh - 220px);
    min-height: calc(100vh - 220px);
}

.script-editor-body:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted, #94a3b8);
    pointer-events: none;
    display: block;
}

.script-editor-body p {
    margin: 0 0 0.75rem 0;
}

.script-editor-body h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0.8rem 0 0.5rem 0;
    color: var(--text-main, #0f172a);
}

.script-editor-body h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0.7rem 0 0.4rem 0;
    color: var(--text-main, #0f172a);
}

.script-editor-body h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0.6rem 0 0.3rem 0;
    color: var(--text-main, #0f172a);
}

.script-editor-body blockquote {
    border-left: 4px solid #6366f1;
    margin: 0.75rem 0;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

.script-editor-body ul, .script-editor-body ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
    padding-left: 0;
}

.script-editor-body hr {
    border: none;
    border-top: 2px dashed var(--border-color, #cbd5e1);
    margin: 1.2rem 0;
}

/* Footer & Status Bar */
.script-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.85rem;
    background: var(--bg-card-alt, #f8fafc);
    border-top: 1px solid var(--border-color, #e2e8f0);
    border-bottom-left-radius: 11px;
    border-bottom-right-radius: 11px;
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
}

/* Live Preview Panel */
.script-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.script-preview-modal.show {
    display: flex;
    animation: fadeInModal 0.2s ease;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.script-preview-content {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.script-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card-alt, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.script-preview-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-main, #1e293b);
}

/* Reader Toolbar in lead_details */
.script-reader-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reader-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 30px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-card, #ffffff);
    color: var(--text-main, #475569);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reader-tool-btn:hover {
    background: #6366f1;
    color: #ffffff;
    border-color: #6366f1;
}

.reader-tool-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
    border-color: #6366f1;
}

.script-reader-fullscreen {
    position: fixed !important;
    top: 15px !important;
    left: 15px !important;
    right: 15px !important;
    bottom: 15px !important;
    z-index: 99999 !important;
    max-height: none !important;
    border: 2px solid #6366f1 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
}

.script-reader-fullscreen #script-content-details {
    max-height: calc(100vh - 120px) !important;
    overflow-y: auto !important;
}

/* =========================================================
   ÉDITEUR DE SCRIPT COMMERCIAL ENRICHI (WYSIWYG & TOOLBAR)
   ========================================================= */

.wysiwyg-wrapper {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 12px;
    background: var(--bg-card, #ffffff);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wysiwyg-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.wysiwyg-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-hover, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    user-select: none;
}

.wysiwyg-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.wysiwyg-toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--border-color, #cbd5e1);
    margin: 0 4px;
}

.wysiwyg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-main, #334155);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wysiwyg-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.wysiwyg-btn.active, .wysiwyg-btn:active {
    background: #6366f1;
    color: #ffffff;
}

.wysiwyg-select {
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    background: var(--bg-card, #ffffff);
    color: var(--text-main, #334155);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

.wysiwyg-select:focus, .wysiwyg-select:hover {
    border-color: #6366f1;
}

/* Palette & Menu Couleur */
.wysiwyg-dropdown {
    position: relative;
    display: inline-block;
}

.wysiwyg-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    margin-top: 4px;
    padding: 10px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
    min-width: 180px;
}

.wysiwyg-dropdown.open .wysiwyg-dropdown-content {
    display: block;
}

.color-swatch-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.color-swatch-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-swatch-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px #6366f1;
}

.wysiwyg-editor-area {
    min-height: 220px;
    max-height: 500px;
    padding: 1rem 1.25rem;
    overflow-y: auto;
    outline: none;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-main, #1e293b);
    background: var(--bg-card, #ffffff);
    font-family: 'Inter', system-ui, sans-serif;
}

.wysiwyg-editor-area[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted, #94a3b8);
    pointer-events: none;
    display: block;
}

/* Dynamic Variable Badges */
.variable-badges-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.04);
    border-bottom: 1px solid rgba(99, 102, 241, 0.12);
}

.variable-badge-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: #ffffff;
    color: #4f46e5;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.08);
}

.variable-badge-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

/* Modal Plein Écran Éditeur */
.wysiwyg-fullscreen-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.wysiwyg-fullscreen-container .wysiwyg-editor-area {
    flex: 1 !important;
    max-height: none !important;
    font-size: 1.1rem !important;
    padding: 2rem 3rem !important;
}

/* Modal Live Preview */
.script-preview-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease;
}

.script-preview-modal-box {
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    width: 100%;
    max-width: 840px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    border: 1px solid var(--border-color, #e2e8f0);
}

.script-preview-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-hover, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.script-preview-modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-main, #1e293b);
}

/* =========================================================
   CALL ANALYSIS STUDIO (AUDIT & CONFORMITÉ IA) - PREMIUM UI
   ========================================================= */

.ca-wrapper {
    padding: 0.5rem 0;
    max-width: 1440px;
    margin: 0 auto;
}

/* Hero Header Banner */
.ca-hero-card {
    background: linear-gradient(135deg, rgba(22, 102, 215, 0.08) 0%, rgba(40, 114, 161, 0.14) 100%), var(--bg-card);
    border: 1px solid var(--border-light, rgba(22, 102, 215, 0.2));
    border-radius: 20px;
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.ca-hero-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(22, 102, 215, 0.12) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

.ca-hero-left {
    flex: 1;
    min-width: 280px;
}

.ca-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(22, 102, 215, 0.12);
    color: var(--primary);
    border: 1px solid rgba(22, 102, 215, 0.25);
    margin-bottom: 0.6rem;
}

.ca-hero-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary, var(--text-main));
    margin: 0 0 0.35rem 0;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.ca-hero-desc {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 0;
    line-height: 1.5;
    max-width: 680px;
}

/* KPI Summary Cards Grid */
.ca-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ca-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s ease;
}

.ca-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.ca-kpi-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.ca-kpi-label {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.ca-kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary, var(--text-main));
    font-family: var(--font-heading, inherit);
}

.ca-kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* Sub-Navigation Tabs */
.ca-nav-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 0.4rem;
    margin-bottom: 1.5rem;
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

.ca-nav-tab {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.ca-nav-tab:hover {
    color: var(--text-primary, var(--text-main));
    background: var(--bg-card-hover, rgba(0,0,0,0.03));
}

.ca-nav-tab.active {
    color: #ffffff;
    background: linear-gradient(135deg, #1666d7, #1b4e73);
    box-shadow: 0 4px 12px rgba(22, 102, 215, 0.3);
}

/* 2-Column Main Workspace Grid */
.ca-workspace-grid {
    display: grid;
    grid-template-columns: minmax(380px, 1.05fr) minmax(420px, 1.25fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .ca-workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* Studio Panels */
.ca-panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
}

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

.ca-panel-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary, var(--text-main));
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Step Badges */
.ca-step-item {
    margin-bottom: 1.35rem;
    position: relative;
}

.ca-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.ca-step-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.ca-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Selected Lead Pill / Card */
.ca-selected-lead-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(22, 102, 215, 0.08);
    border: 1px solid rgba(22, 102, 215, 0.25);
    border-radius: 12px;
    margin-top: 0.6rem;
    animation: fadeIn 0.2s ease;
}

.ca-lead-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ca-lead-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1666d7, #2872a1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
}

/* Modern Dropzone */
.ca-dropzone {
    border: 2px dashed var(--border-light);
    border-radius: 16px;
    padding: 1.5rem 1rem;
    text-align: center;
    background: var(--bg-body);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.ca-dropzone:hover, .ca-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(22, 102, 215, 0.04);
    transform: scale(1.005);
}

.ca-dropzone-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(22, 102, 215, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

/* Audio File Queue Item */
.ca-queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    margin-top: 0.45rem;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.ca-queue-item:hover {
    border-color: var(--primary);
}

/* Result Radial Score Card */
.ca-score-card {
    background: linear-gradient(135deg, rgba(22, 102, 215, 0.05) 0%, rgba(22, 102, 215, 0.12) 100%), var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.ca-radial-score {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    font-family: var(--font-heading, inherit);
    position: relative;
    flex-shrink: 0;
}

/* Evaluation Checklist Phases */
.ca-phase-grid {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-bottom: 1.25rem;
}

.ca-phase-card {
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.ca-phase-card:hover {
    border-color: rgba(22, 102, 215, 0.35);
    background: var(--bg-card-hover, var(--bg-body));
}

.ca-phase-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ca-phase-name {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-primary, var(--text-main));
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ca-phase-progress-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.2rem;
}

.ca-phase-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Feedback & Coaching Box */
.ca-coaching-box {
    background: rgba(22, 102, 215, 0.05);
    border: 1px solid rgba(22, 102, 215, 0.2);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.ca-transcript-viewer {
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.65;
    white-space: pre-wrap;
    color: var(--text-primary, var(--text-main));
    font-family: var(--font-sans, inherit);
}

/* Print Stylesheet */
@media print {
    .ca-nav-tabs,
    .ca-hero-card .btn,
    .ca-panel-card:first-child,
    .sidebar,
    .header,
    .sidebar-toggle,
    .sidebar-overlay {
        display: none !important;
    }
    .ca-workspace-grid {
        display: block !important;
    }
    .ca-panel-card {
        border: none !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   UNIVERSAL RESPONSIVE ENGINE (MOBILE, TABLET, LAPTOP, DESKTOP, ULTRA-WIDE)
   Optimisé pour toutes les résolutions d'écran
   ========================================================================== */

/* Base Viewport & Touch Optimization */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Smooth Horizontal Scroll for Data Tables & Pills */
.table-responsive,
.leads-table-container,
.stats-table-wrapper,
.lead-type-pills,
.status-filter-pills,
.stats-type-selector-bar {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Custom Sleek Scrollbar */
.table-responsive::-webkit-scrollbar,
.leads-table-container::-webkit-scrollbar,
.stats-table-wrapper::-webkit-scrollbar,
.lead-type-pills::-webkit-scrollbar,
.status-filter-pills::-webkit-scrollbar,
.stats-type-selector-bar::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-responsive::-webkit-scrollbar-track,
.leads-table-container::-webkit-scrollbar-track,
.stats-table-wrapper::-webkit-scrollbar-track,
.lead-type-pills::-webkit-scrollbar-track,
.status-filter-pills::-webkit-scrollbar-track,
.stats-type-selector-bar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 999px;
}

.table-responsive::-webkit-scrollbar-thumb,
.leads-table-container::-webkit-scrollbar-thumb,
.stats-table-wrapper::-webkit-scrollbar-thumb,
.lead-type-pills::-webkit-scrollbar-thumb,
.status-filter-pills::-webkit-scrollbar-thumb,
.stats-type-selector-bar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 999px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.leads-table-container::-webkit-scrollbar-thumb:hover,
.stats-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #2E86DE);
}

/* --------------------------------------------------------------------------
   1. ULTRA-WIDE & 4K SCREENS (min-width: 1600px)
   -------------------------------------------------------------------------- */
@media (min-width: 1600px) {
    .leads-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
        gap: 1.25rem !important;
    }
    #stats-lead-types-grid,
    #stats-clients-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
    }
    .main-content {
        margin-left: var(--sidebar-width, 260px) !important;
        width: calc(100vw - var(--sidebar-width, 260px)) !important;
        max-width: calc(100vw - var(--sidebar-width, 260px)) !important;
        box-sizing: border-box !important;
        padding: 2rem 2.75rem !important;
    }
}

/* --------------------------------------------------------------------------
   2. DESKTOP & LAPTOPS (1025px to 1599px)
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) and (max-width: 1599px) {
    .leads-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    }
    #stats-lead-types-grid,
    #stats-clients-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    }
    .main-content {
        margin-left: var(--sidebar-width, 260px) !important;
        width: calc(100vw - var(--sidebar-width, 260px)) !important;
        max-width: calc(100vw - var(--sidebar-width, 260px)) !important;
        box-sizing: border-box !important;
        padding: 1.75rem 2.25rem !important;
    }
}

/* --------------------------------------------------------------------------
   3. TABLETS & COMPACT LAPTOPS (993px to 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 993px) and (max-width: 1024px) {
    .main-content {
        margin-left: var(--sidebar-width, 260px) !important;
        width: calc(100vw - var(--sidebar-width, 260px)) !important;
        max-width: calc(100vw - var(--sidebar-width, 260px)) !important;
        box-sizing: border-box !important;
        padding: 1.5rem 1.75rem !important;
    }
    .leads-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    #stats-lead-types-grid,
    #stats-clients-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    .agents-grid-layout {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
    .chat-container-layout.has-sidebar {
        grid-template-columns: 240px 1fr !important;
    }
}

/* --------------------------------------------------------------------------
   4. TABLETS (PORTRAIT) & MOBILE DEVICES (max-width: 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
    /* Mobile Toggle Button */
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 0.85rem;
        left: 0.85rem;
        z-index: 10010;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: var(--bg-card-solid, #ffffff);
        border: 1px solid var(--border-light, #e2e8f0);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
        cursor: pointer;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .sidebar-toggle:hover {
        transform: scale(1.05);
    }
    .sidebar-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--text-main, #0f172a);
        margin: 4px auto;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    /* Off-Canvas Sidebar */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 285px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 10005 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: none !important;
        overflow-y: auto !important;
        background: var(--bg-card-solid, #ffffff) !important;
    }
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 0 0 45px rgba(0, 0, 0, 0.35) !important;
    }

    /* Backdrop Overlay */
    .sidebar-overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.55) !important;
        backdrop-filter: blur(6px) !important;
        -webkit-backdrop-filter: blur(6px) !important;
        z-index: 10000 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
        pointer-events: none;
    }
    .sidebar-overlay.active {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* Main Content Full Width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 4.5rem 1.25rem 2rem 1.25rem !important;
        overflow-x: hidden !important;
    }

    /* Filter & Controls Wrap */
    .leads-controls-bar,
    .filters-bar,
    .date-filter-group {
        flex-wrap: wrap !important;
        gap: 0.75rem !important;
    }

    /* Stats Grids */
    #stats-lead-types-grid,
    #stats-clients-grid {
        grid-template-columns: 1fr !important;
    }

    /* Chat Layout on Tablets */
    .chat-container-layout,
    .chat-container-layout.has-sidebar {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }
    .chat-sidebar {
        height: 240px !important;
        margin-bottom: 1rem !important;
    }
    .chat-window-panel {
        height: 480px !important;
    }

    /* Lead Drawer on Tablets */
    .lead-drawer,
    #lead-drawer {
        width: 480px !important;
        max-width: 90vw !important;
    }
}

/* --------------------------------------------------------------------------
   5. STANDARD MOBILE PHONES (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .main-content {
        padding: 4.25rem 0.85rem 1.75rem 0.85rem !important;
    }

    /* KPI Cards Single Column */
    .leads-kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .leads-kpi-card {
        padding: 1rem !important;
    }

    /* Horizontal Pills Bar for Types & Statuses */
    .lead-type-pills,
    .status-filter-pills,
    .stats-type-selector-bar {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding-bottom: 0.5rem !important;
        gap: 0.4rem !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .lead-type-pill,
    .status-filter-pill,
    .stats-type-btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 0.45rem 0.85rem !important;
        font-size: 0.82rem !important;
    }

    /* Action Toolbar & Filters */
    .leads-filter-container,
    .leads-search-row,
    .stats-filter-form {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.6rem !important;
    }

    .search-input-wrapper,
    .filter-select,
    .date-input,
    .form-control,
    .btn-filter,
    .btn-reset {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Data Tables Responsiveness */
    .table-responsive,
    .leads-table-container,
    .stats-table-wrapper {
        border-radius: 12px !important;
        border: 1px solid var(--border-light, #e2e8f0) !important;
        background: var(--bg-card-solid, #ffffff) !important;
        margin-top: 0.75rem !important;
        box-shadow: var(--shadow-sm) !important;
    }

    .leads-table,
    .stats-table,
    .agents-table {
        min-width: 720px !important;
        font-size: 0.82rem !important;
    }

    .leads-table th,
    .leads-table td,
    .stats-table th,
    .stats-table td {
        padding: 0.6rem 0.65rem !important;
    }

    /* Modals to Full Screen on Mobile */
    .modal-content,
    .modal-dialog {
        width: 95% !important;
        max-width: 95vw !important;
        margin: 0.75rem auto !important;
        padding: 1.25rem 1rem !important;
        border-radius: 16px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    /* Full-Screen Lead Detail Drawer on Mobile */
    .lead-drawer,
    #lead-drawer,
    .drawer-panel {
        width: 100% !important;
        max-width: 100vw !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        border-radius: 0 !important;
    }

    /* Pagination Mobile */
    .pagination-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.75rem !important;
        text-align: center !important;
    }

    .pagination-pages {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }

    /* Audio Call Evaluation & AI Coach on Mobile */
    .ca-hero-card,
    .ca-summary-card,
    .ca-score-breakdown-card {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    .ca-stats-summary-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .ca-player-box {
        padding: 0.85rem !important;
    }

    .ca-player-controls {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    /* Ringover Floating Widget */
    .ringover-floating-container,
    #ringover-widget-btn {
        bottom: 1rem !important;
        right: 1rem !important;
        transform: scale(0.95);
    }
}

/* --------------------------------------------------------------------------
   6. EXTRA-SMALL PHONES & FOLDABLES (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .main-content {
        padding: 4rem 0.6rem 1.5rem 0.6rem !important;
    }

    /* Prevent auto-zoom on iOS inputs */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Minimum touch target 44px */
    .btn,
    .btn-action,
    .nav-link,
    .lead-type-pill,
    .status-filter-pill {
        min-height: 40px !important;
    }

    .sidebar-avatar {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.95rem !important;
    }

    .sidebar-logo img {
        max-height: 44px !important;
    }

    /* Card Metrics inside Lead Type & Client cards */
    .stat-card div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    /* Header Title */
    .header-title,
    .panel-title {
        font-size: 1.2rem !important;
    }
}

/* ==========================================================================
   7. ANIMATED MULTI-TYPE BENEFICIARY STYLES & REALTIME UPDATES
   ========================================================================== */

/* Flash pulse animation when beneficiary changes in real-time */
@keyframes pulseBeneficiaryFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
        border-color: #10b981;
    }
    40% {
        box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
        border-color: #10b981;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.kpi-card-pulse-updated {
    animation: pulseBeneficiaryFlash 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 3D Flip transition for Rotator */
@keyframes cardFlip3D {
    0% {
        opacity: 0;
        transform: translateY(-8px) rotateX(-15deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0deg);
    }
}

.animate-rotator-flip {
    animation: cardFlip3D 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Progress bar countdown for rotator */
.rotator-progress-line {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.6;
    border-radius: 0 4px 4px 0;
    transition: width 3s linear;
}

/* Dots pagination for Rotator Card */
.rotator-dots-container {
    display: flex;
    align-items: center;
    gap: 4px;
}
.rotator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.4);
    cursor: pointer;
    transition: all 0.25s ease;
}
.rotator-dot.active {
    width: 14px;
    border-radius: 4px;
    background: var(--primary, #6366f1);
}

/* Admin Multi-Type Grid Section */
.admin-beneficiary-section {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--bg-card-solid, #ffffff);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
}

.admin-beneficiary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.admin-beneficiary-card {
    position: relative;
    background: var(--bg-surface, #f8fafc);
    border: 1.5px solid var(--border-light, #e2e8f0);
    border-radius: 12px;
    padding: 0.9rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    cursor: pointer;
}

.admin-beneficiary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.admin-beneficiary-card.active-type {
    border-color: var(--type-color, #6366f1) !important;
    box-shadow: 0 0 16px var(--type-glow, rgba(99, 102, 241, 0.25));
    background: var(--type-bg, rgba(99, 102, 241, 0.04));
}

.admin-beneficiary-card.is-me {
    border-color: #10b981 !important;
    background: rgba(16, 185, 129, 0.05);
}

.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.admin-card-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.admin-card-agent-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0.4rem;
}

.admin-card-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: white;
    flex-shrink: 0;
}

.admin-card-agent-name {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text-heading, #0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Theme & Performance Buttons */
button.sidebar-theme-toggle,
.sidebar-theme-toggle {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.65rem !important;
    padding: 0.75rem 1rem !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    font-weight: 700 !important;
    font-size: 0.88rem !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    margin-bottom: 0.5rem !important;
    outline: none !important;
    box-shadow: none !important;
}

button.sidebar-theme-toggle:hover,
.sidebar-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
    transform: translateY(-1px) !important;
}

button.sidebar-theme-toggle.is-active-perf,
.sidebar-theme-toggle.is-active-perf {
    background: rgba(16, 185, 129, 0.22) !important;
    border-color: rgba(16, 185, 129, 0.6) !important;
    color: #10b981 !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.25) !important;
}

button.sidebar-theme-toggle.is-active-perf:hover,
.sidebar-theme-toggle.is-active-perf:hover {
    background: rgba(16, 185, 129, 0.32) !important;
    border-color: #10b981 !important;
}




