/* === VARIABLES (Colores de WhatsApp / Modernos) === */
:root {
    --primary-color: #008069;
    /* Verde WhatsApp */
    --primary-dark: #006a57;
    --bg-chat: #efe7dd;
    /* Beige fondo chat */
    --bg-gray: #f0f2f5;
    /* Gris fondo general */
    --white: #ffffff;
    --bubble-sent: #d9fdd3;
    /* Burbuja verde (nuestra) */
    --bubble-received: #ffffff;
    /* Burbuja blanca (cliente) */
    --text-primary: #111b21;
    --text-secondary: #667781;
    --danger: #ef4444;
    /* Rojo para errores/salir */
    --border-color: #e9edef;

    /* === SISTEMA DE DISEÑO (Sprint 3) === */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --focus-ring: 0 0 0 3px rgba(0, 128, 105, 0.15);
}

/* === RESET BÁSICO === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100vh;
    scroll-behavior: smooth;
    overflow-x: hidden;
    /* Blindaje táctil: sin flash gris al tocar y sin zoom por doble toque */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Texto más nítido en pantallas de alta densidad */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* === SCROLLBARS MODERNOS Y DELGADOS === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 119, 129, 0.2);
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 119, 129, 0.35);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 119, 129, 0.2) transparent;
}

body {
    /* 100dvh es "Dynamic Viewport Height": se adapta a si la barra de Safari está visible u oculta */
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-gray);
    overflow: hidden;
    /* Evita el scroll global de la página */
    overscroll-behavior: none;
    /* Evita el rebote elástico en Mac/iOS */
}

/* Fix Anti-Zoom iPhone: Si la letra es menor a 16px, iPhone hace zoom al escribir */
input,
select,
textarea {
    font-size: 16px !important;
}

/* === UTILIDADES === */
.hidden {
    display: none !important;
}

/* === LOGIN (Centrado) === */
.login-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.login-box {
    background: var(--white);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box .logo {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: bold;
    color: var(--primary-color);
}

.input-group {
    position: relative;
    margin-bottom: 1rem;
    text-align: left;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.error-msg {
    color: var(--danger);
    margin-top: 10px;
    font-size: 0.9rem;
}

/* === DASHBOARD LAYOUT & SIDEBAR GLOBAL === */
.dashboard-wrapper {
    display: flex;
    flex-direction: row;
    /* Diseño de Panel Moderno */
    height: 100dvh;
    position: relative;
    top: 0;
}

.sidebar-global {
    width: 260px;
    background: #111b21;
    /* Tema oscuro muy elegante */
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 100;
}

.sidebar-logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn {
    background: transparent;
    border: none;
    color: #aebac1;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.2s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.menu-btn.active {
    background: var(--primary-color);
    color: white;
    font-weight: bold;
}

.logout-btn {
    color: #ef4444;
    /* Rojo para salir */
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Salir dentro de Configuración: oculto en escritorio, donde ya está en el sidebar */
.mobile-logout {
    display: none;
}

.btn-logout-mobile {
    width: 100%;
    padding: 14px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-logout-mobile:active {
    background: rgba(239, 68, 68, 0.16);
}

/* ÁREA DE CONTENIDO (Derecha) */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-gray);
}

.top-header {
    display: none;
}

/* Oculto en PC porque usamos Sidebar */

/* Contenedor Principal (Split Screen Chat) */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: white;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* === COLUMNA IZQUIERDA (Sidebar) === */
.sidebar {
    width: 350px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.search-bar {
    padding: 10px;
    background: var(--bg-gray);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 8px 10px 8px 35px;
    border-radius: 8px;
    border: none;
    background: white;
    outline: none;
    font-size: 0.9rem;
}

.search-bar i {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Elemento Usuario (Item de la lista) */
.user-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover {
    background-color: var(--bg-gray);
}

.user-item.active {
    background-color: #f0f2f5;
    border-left: 4px solid var(--primary-color);
}

.avatar-circle {
    width: 45px;
    height: 45px;
    background: #dfe1e5;
    color: var(--text-secondary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-last-msg {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === COLUMNA DERECHA (Chat) === */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-chat);
    background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
    /* Patrón sutil estilo WhatsApp */
    background-blend-mode: overlay;
    position: relative;
}

/* Estado Vacío */
.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Interfaz Chat Activo */
.chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    background: var(--bg-gray);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Botón "Atrás" (Solo visible en móvil) */
#btn-back {
    display: none;
    margin-right: 10px;
    color: var(--text-secondary);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.phone-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#ai-status-text {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--primary-color);
}

.btn-toggle {
    background: white;
    border: 1px solid #ccc;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    transition: 0.2s;
}

.btn-toggle:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-toggle.paused {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Mensajes */
/* Píldora divisoria de fechas en el chat (Estilo WhatsApp) */
.chat-date-separator {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px 0;
    width: 100%;
}

.chat-date-separator span {
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(11, 20, 26, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-transform: capitalize;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Chats cortos: evita que el rebote elástico arrastre la ventana entera en iOS/Android.
   Va en regla propia y con una sola propiedad para no elevar la especificidad
   del resto de estilos del contenedor a nivel de ID. */
#chat-messages {
    overscroll-behavior-y: contain;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.user-message {
    align-self: flex-start;
    background: var(--white);
    border-top-left-radius: 0;
}

.my-message {
    align-self: flex-end;
    background: var(--bubble-sent);
    border-top-right-radius: 0;
}

.msg-time {
    font-size: 0.7rem;
    color: #999;
    text-align: right;
    margin-top: 4px;
    float: right;
    margin-left: 10px;
}

/* Input Área */
.chat-input-area {
    background: var(--bg-gray);
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    /* Zona segura inferior para iPhone X/11/12+ */
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.chat-input-area input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    outline: none;
}

.chat-input-area button {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--primary-color);
    cursor: pointer;
}

.chat-input-area button:disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* ============================================================
   SPRINT 3 · MICROINTERACCIONES Y ESTILIZADO PRÉMIUM
   Va antes del bloque responsive para que los overrides
   móviles de más abajo sigan teniendo la última palabra.
   ============================================================ */

/* --- Elevación de tarjetas: solo en dispositivos con puntero real --- */
@media (hover: hover) {

    .kpi-card:hover,
    .chart-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    }
}

/* --- Botones: transición y respuesta física al pulsar --- */
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-primary-action,
.btn-icon,
.menu-btn,
.modal-footer button {
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary:active,
.btn-secondary:active,
.btn-outline:active,
.btn-primary-action:active,
.btn-icon:active,
.menu-btn:active,
.modal-footer button:active {
    transform: scale(0.98);
}

/* --- Campos de formulario: borde suave y anillo de foco --- */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus,
.svc-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

/* === RESPONSIVE MÓVIL AVANZADO === */
@media (max-width: 768px) {

    /* El Sidebar pasa a ser un Menú Inferior (Bottom Bar) */
    .dashboard-wrapper {
        flex-direction: column;
    }

    /* Barra inferior fija tipo app nativa, con cristal esmerilado */
    .sidebar-global {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding: 6px 8px env(safe-area-inset-bottom, 10px) 8px;
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        z-index: 999;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        box-sizing: border-box;
    }

    .sidebar-logo {
        display: none;
    }

    /* El botón Salir no cabe en la barra: se reubicará en Configuración */
    .sidebar-footer,
    .logout-btn {
        display: none;
    }

    .sidebar-menu {
        display: flex;
        width: 100%;
        justify-content: space-around;
        gap: 2px;
        flex-direction: row;
    }

    .menu-btn {
        flex: 1;
        min-width: 0;
        /* Permite que la etiqueta se recorte en vez de desbordar la barra */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        padding: 6px 4px;
        text-align: center;
        font-size: 0.72rem;
        font-weight: 500;
        white-space: nowrap;
        border-radius: 10px;
        /* El gris claro heredado del sidebar oscuro sería ilegible sobre el cristal blanco */
        color: var(--text-secondary);
        background: transparent;
    }

    .menu-btn i {
        font-size: 1.15rem;
        margin-bottom: 2px;
    }

    .menu-btn .menu-text {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Anulamos el hover del escritorio: en táctil se queda "pegado" tras el toque */
    .menu-btn:hover {
        background: transparent;
        color: var(--text-secondary);
    }

    .menu-btn.active,
    .menu-btn.active:hover {
        color: var(--primary-color);
        background: rgba(0, 128, 105, 0.1);
        font-weight: 600;
    }

    /* Reserva de espacio para que la barra flotante no tape el final del contenido */
    .content-area {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Sustituto del botón Salir del sidebar, que no cabe en la barra inferior */
    .mobile-logout {
        display: block;
        margin: 24px 0 8px;
    }

    /* Mostrar top header (solo la barrita verde si la necesitas) */
    .top-header.mobile-only {
        display: block;
        height: max(15px, env(safe-area-inset-top));
        background: var(--primary-color);
    }

    /* Por defecto en móvil: Sidebar ocupa todo, Chat oculto */
    .sidebar {
        width: 100%;
        display: flex;
    }

    .chat-area {
        display: none;
        width: 100%;
    }

    /* Cuando entramos al chat (se activa esta clase en el main-container con JS) */
    .mobile-chat-active .sidebar {
        display: none;
    }

    .mobile-chat-active .chat-area {
        display: flex;
    }

    /* Mostrar botón atrás solo en móvil */
    #btn-back {
        display: block;
    }

    /* Ajustes para ganar espacio en móvil */
    .chat-header {
        padding: 10px;
    }

    .message-bubble {
        max-width: 80%;
    }

    .analytics-container {
        padding-bottom: 100px;
    }

    /* Toolbar FullCalendar en 2 filas limpias para móvil */
    .fc .fc-header-toolbar.fc-toolbar {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        row-gap: 8px !important;
        margin-bottom: 12px !important;
    }

    /* Fila 1: Título centrado ocupando todo el ancho */
    .fc .fc-toolbar-chunk:nth-child(2) {
        order: 1 !important;
        width: 100% !important;
        text-align: center !important;
    }

    .fc .fc-toolbar-title {
        font-size: 1.1rem !important;
        font-weight: 600 !important;
        color: var(--text-primary) !important;
        margin: 0 !important;
    }

    /* Fila 2: Botones navegación a la izquierda y vistas a la derecha */
    .fc .fc-toolbar-chunk:nth-child(1) {
        order: 2 !important;
    }

    .fc .fc-toolbar-chunk:nth-child(3) {
        order: 3 !important;
    }

    .fc .fc-button {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
        border-radius: var(--radius-sm, 8px) !important;
    }
}

/* === ANALYTICS & DASHBOARD VIEW === */
.analytics-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: var(--bg-gray);
    display: flex;
    flex-direction: column;
    gap: 30px;
    scroll-behavior: smooth;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.kpi-card {
    background: #ffffff;
    padding: 20px;
    border: 1px solid var(--border-color);
    /* El acento de color va después del shorthand para que no lo sobrescriba */
    border-top: 4px solid var(--primary-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card-time {
    border-top: 4px solid #f59e0b;
}

.kpi-card i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.kpi-card h3 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin: 5px 0;
}

.kpi-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.chart-card {
    background: #ffffff;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    min-height: 400px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

canvas {
    height: 100% !important;
}

.chart-card h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    background: white;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
}

.filter-btn:hover {
    background: var(--bg-gray);
}

/* === LOADING OVERLAY (SESIÓN 2) === */
.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

/* === ESPECÍFICO REVENUE BREAKDOWN (SESIÓN 3) === */
.kpi-card-revenue {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.revenue-breakdown {
    display: flex;
    width: 100%;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.breakdown-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.breakdown-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.breakdown-value.realized {
    color: var(--primary-color);
}

.breakdown-value.projected {
    color: #3b82f6;
    /* Azul moderno para proyección */
}

.breakdown-separator {
    width: 1px;
    height: 30px;
    background-color: var(--border-color);
}

/* === AGENDA (FULLCALENDAR) === */
.agenda-container {
    flex: 1;
    padding: 20px;
    background: var(--bg-gray);
    overflow-y: auto;
}

#calendar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    padding: 20px;
    /* Ajustes para FullCalendar dentro de la tarjeta */
    min-height: 500px;
}

/* Personalizar FullCalendar para que use nuestro color primario */
.fc .fc-button-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.fc .fc-button-primary:hover {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

/* Cursor interactivo (manita) en las citas del calendario */
.fc-event {
    cursor: pointer !important;
}

/* === SELECTOR DE EMPLEADOS === */
.calendar-controls {
    margin-bottom: 20px;
}
.employee-select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    font-size: 1rem;
    min-width: 200px;
    outline: none;
    cursor: pointer;
}

/* === SETTINGS SECTION (BOSS MODE) === */
.settings-container {
    flex: 1;
    padding: 30px;
    background: var(--bg-gray);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-header h2 {
    color: var(--text-primary);
    margin-bottom: 5px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

/* Glassmorphism */
.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card-title h3 {
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

.card-full-width {
    grid-column: 1 / -1;
}

/* Botón del Pánico - Switch */
.panic-switch-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px 0;
}

#global-ai-status-text {
    font-weight: bold;
    font-size: 1.2rem;
}
.status-active { color: var(--primary-color); }
.status-paused { color: var(--danger); }

.boss-switch {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 40px;
}

.boss-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.boss-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--danger); /* Default Red when paused */
    transition: .4s;
    border-radius: 40px;
}

.boss-switch .slider:before {
    position: absolute;
    content: "";
    height: 32px;
    width: 32px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.boss-switch input:checked + .slider {
    background-color: var(--primary-color); /* Green when active */
}

.boss-switch input:checked + .slider:before {
    transform: translateX(40px);
}

/* Tabla Servicios */
.table-responsive {
    overflow-x: auto;
}

.services-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.services-table th, .services-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.services-table th {
    background-color: rgba(0,0,0,0.02);
    font-weight: 600;
    color: var(--text-secondary);
}

.svc-input {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
    /* La clase se usa en input, select y textarea: los unificamos aquí
       para que no convivan bordes de 5px y de 8px en la misma fila. */
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: 0.2s;
    font-size: 1.1rem;
}

.btn-icon.save { color: var(--primary-color); }
.btn-icon.save:hover { background: rgba(0,128,105,0.1); }
.btn-icon.delete { color: var(--danger); }
.btn-icon.delete:hover { background: rgba(239,68,68,0.1); }

/* Horarios */
.hours-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.day-row {
    background: rgba(0,0,0,0.01);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.day-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.day-intervals {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.time-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-outline:hover { background: rgba(0,128,105,0.1); }
.btn-outline-save { align-self: flex-start; margin-top: 10px; margin-bottom: 10px; }

.calendar-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.employee-select {
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--white);
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: border-color 0.2s;
}

.employee-select:focus {
    border-color: var(--primary-color);
}

/* === MODAL DE CITA === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-box {
    background: var(--white);
    width: 90%;
    max-width: 450px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
    animation: modalPopIn 0.2s ease-out forwards;
}

@keyframes modalPopIn {
    0% { transform: scale(0.96); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-header {
    background: var(--bg-gray);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.modal-field:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.modal-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
    max-width: 65%;
}

.modal-footer {
    padding: 15px 20px;
    background: var(--bg-gray);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer button {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.modal-footer button:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-danger {
    background: #fee2e2;
    color: #ef4444;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-primary-action {
    background: #e0f2fe;
    color: #0284c7;
}

.btn-primary-action:hover {
    background: #bae6fd;
}

/* === BADGES PARA EQUIPO === */
.badge-active {
    background-color: #d1fae5;
    color: #059669;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-inactive {
    background-color: #fee2e2;
    color: #ef4444;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-synced {
    background-color: #e0f2fe;
    color: #0284c7;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-none {
    background-color: #f1f5f9;
    color: #64748b;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}
.heatmap-card {
    min-height: 500px;
    grid-column: 1 / -1;  /* Full-width siempre */
}

.heatmap-card #chart-heatmap-container {
    min-height: 300px;
    position: relative;
    width: 100%;
}

.heatmap-card canvas {
    width: 100% !important;
    min-height: 280px;
}

.stats-select {
    background-color: #ffffff !important;
    color: #111b21 !important;
    border: 2px solid #008069;
    border-radius: 8px;
    padding: 8px 30px 8px 15px;
    font-size: 0.9em;
    margin-left: 10px;
    cursor: pointer;
    outline: none;
    appearance: auto;
    -webkit-appearance: auto;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 128, 105, 0.15);
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
    z-index: 1000;
}

.stats-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 128, 105, 0.2);
}

/* ============================================================
   SIN HOVERS PEGAJOSOS EN TÁCTIL
   En pantallas táctiles el :hover se queda fijado tras el toque
   hasta que tocas otro sitio. Va al final del archivo a propósito:
   @media no aporta especificidad, así que estas reglas necesitan
   ser las últimas para ganar a los :hover declarados más arriba.
   El realce de las tarjetas no aparece aquí porque ya está
   encapsulado en @media (hover: hover) y nunca llega a aplicarse.
   ============================================================ */
@media (hover: none) {

    .btn-icon:hover,
    .btn-icon.save:hover,
    .btn-icon.delete:hover,
    .btn-outline:hover {
        background: transparent;
    }

    .user-item:hover {
        background-color: transparent;
    }
}
