/* Responsive Styles - Added for responsive design */
/* Mobile: ≤640px, Tablet: 641-1024px, Desktop: >1024px */

/* ============================================
   MOBILE MENU - Swipe Area & Overlay
   ============================================ */

/* Added for mobile menu - Área invisible para detectar arrastre desde el borde izquierdo */
.swipe-area {
    display: none; /* Oculto por defecto (desktop) */
    position: fixed;
    top: 0;
    left: 0;
    width: 40px; /* Área más ancha para facilitar el arrastre */
    height: 100vh;
    z-index: 1001;
    background-color: transparent;
    cursor: grab;
    touch-action: none; /* Prevenir gestos del navegador */
}

.swipe-area:active {
    cursor: grabbing;
}

/* Indicador visual mejorado - barra más larga y ancha, siempre centrada */
@media (max-width: 1024px) {
    .swipe-area::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 5px; /* Más ancha */
        height: 80px; /* Más larga */
        background-color: var(--color-primary);
        opacity: 0.4;
        border-radius: 0 3px 3px 0;
        transition: opacity 0.3s ease;
        /* Asegurar que siempre esté centrada verticalmente */
        margin: 0;
        padding: 0;
    }
    
    .swipe-area:hover::before {
        opacity: 0.7;
    }
}

/* Asegurar centrado en todas las resoluciones */
@media (max-width: 640px) {
    .swipe-area::before {
        /* Mantener centrado en mobile */
        top: 50%;
        transform: translateY(-50%);
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .swipe-area::before {
        /* Mantener centrado en tablet */
        top: 50%;
        transform: translateY(-50%);
    }
}

/* Added for mobile menu overlay */
.menu-overlay {
    display: none; /* Oculto por defecto (desktop) */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.menu-overlay-active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================
   SIDEBAR RESPONSIVE
   ============================================ */

/* Desktop: >1024px - Mantener diseño original */
@media (min-width: 1025px) {
    .sidebar {
        position: fixed;
        transform: translateX(0);
        transition: transform 0.3s ease;
    }
    
    .main-content {
        margin-left: 280px;
    }
    
    .swipe-area {
        display: none !important;
    }
    
    .menu-overlay {
        display: none !important;
    }
    
    .menu-toggle-btn {
        display: none !important;
    }
    
    /* Inteligencia de Negocio - Mostrar tabla y ocultar cards en desktop */
    .business-intelligence-table {
        display: block !important;
    }
    
    .business-intelligence-cards {
        display: none !important;
    }
    
    /* Productos Más Buscados - Mostrar tabla y ocultar cards en desktop */
    .top-products-table {
        display: block !important;
    }
    
    .top-products-cards {
        display: none !important;
    }
}

/* Tablet: 641px - 1024px */
@media (max-width: 1024px) {
    /* Added for responsive */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        z-index: 1000;
    }
    
    .sidebar-open {
        transform: translateX(0);
        z-index: 1003;
    }
    
    .main-content {
        margin-left: 0;
        padding: 24px;
        width: 100%;
    }
    
    /* Ocultar swipe area - ya no se usa */
    .swipe-area {
        display: none !important;
    }
    
    /* Mostrar overlay y botón hamburger */
    .menu-overlay {
        display: block;
    }
    
    .menu-toggle-btn {
        display: flex !important;
        top: 16px !important;
        left: 16px !important;
        width: 48px !important;
        height: 48px !important;
        aspect-ratio: 1 !important; /* Mantener forma cuadrada siempre */
    }
    
    /* Botón refresh - Posicionarlo arriba a la derecha, mismas dimensiones que menu-toggle-btn */
    .btn-refresh {
        position: fixed !important;
        top: 16px !important; /* Misma posición vertical que el botón del menú */
        right: 16px !important; /* Posición a la derecha */
        left: auto !important; /* Anular left */
        z-index: 1004 !important; /* Mismo z-index que el botón del menú */
        width: 48px !important; /* Mismo ancho que menu-toggle-btn */
        height: 48.2px !important; /* Proporcional desde mobile (48px * 1.0045) */
        /* aspect-ratio: 1 !important; */ /* Desbloqueado para permitir ajuste manual de altura */
        border-radius: 8px !important; /* Mismo border-radius que menu-toggle-btn */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important; /* Mismo box-shadow que menu-toggle-btn */
        box-sizing: border-box !important; /* Incluir border en el height */
        display: flex !important;
    }
    
    /* Icono del botón refresh - Adaptado al tamaño del botón (44px altura) */
    .btn-refresh i {
        font-size: 20px !important; /* Adaptado al tamaño más pequeño del botón */
    }

    /* Ocultar botón refresh cuando el menú esté abierto */
    body.menu-open .btn-refresh {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    
    /* Ajustes de contenido - Ajustar padding para el botón hamburger */
    .page-header {
        padding-top: 0;
        padding-left: 64px; /* Espacio para el botón hamburger */
        margin-bottom: 0 !important;
    }
    
    /* Ajustar el contenido para que quede 2px después de los subtítulos */
    .page-header p {
        margin-bottom: 0 !important;
    }
    
    /* Agregar margin-top al contenido para crear espacio después del subtítulo */
    #page-content > #conversations-content,
    #page-content > #clients-content,
    #page-content > #analytics-content {
        margin-top: 20px !important;
    }
    
    /* Resumen General */
    #page-content > #dashboard-content {
        margin-top: 40px !important;
    }
    
    .page-header-top {
        flex-wrap: wrap;
    }
    
    .page-header h1 {
        font-size: 28px;
    }
    
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    /* Espaciado mejorado para cards en tablet */
    .card-header {
        margin-bottom: 18px;
        padding-bottom: 14px;
        flex-direction: column !important; /* Cambiar a columna para apilar título y subtítulo */
        align-items: flex-start !important; /* Alinear a la izquierda */
        width: 100%; /* Ocupar todo el ancho */
    }
    
    .card-header p {
        margin-top: 10px !important;
        margin-bottom: 0;
        width: 100%; /* Ocupar todo el ancho */
    }
    
    .card-title {
        margin-bottom: 6px;
        width: 100%; /* Ocupar todo el ancho */
    }
    
    /* Espaciado para contenido de charts en cards */
    .card > div[style*="padding"] {
        padding-top: 18px !important;
    }
    
    /* Espaciado para tablas dentro de cards */
    .card .table-container {
        margin-top: 16px; /* Espacio entre header y tabla en tablet */
    }
    
    /* Inteligencia de Negocio - Ocultar tabla y mostrar cards en tablet */
    .business-intelligence-table {
        display: none; /* Ocultar tabla en tablet */
    }
    
    .business-intelligence-cards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 16px;
    }
    
    /* Cards de Inteligencia de Negocio para tablet */
    .bi-card {
        background-color: var(--color-secondary-light);
        border: 1px solid var(--color-border);
        border-radius: 12px;
        padding: 18px;
        transition: all 0.3s ease;
    }
    
    .bi-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
        border-color: var(--color-primary);
    }
    
    .bi-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--color-border);
    }
    
    .bi-keyword {
        font-size: 17px;
        font-weight: 600;
        color: var(--color-primary);
        margin: 0;
    }
    
    .bi-badge {
        font-size: 19px;
        font-weight: 700;
        padding: 5px 14px;
        border-radius: 8px;
        background-color: rgba(255, 215, 0, 0.1);
    }
    
    .bi-card-body {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    
    .bi-metric {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
    }
    
    .bi-label {
        font-size: 14px;
        color: var(--color-text-secondary);
        font-weight: 500;
    }
    
    .bi-value {
        font-size: 15px;
        color: var(--color-text);
        font-weight: 600;
        text-align: right;
    }
    
    .bi-value small {
        font-size: 12px;
        opacity: 0.7;
        font-weight: 400;
    }
    
    .bi-empty {
        text-align: center;
        padding: 32px;
        color: var(--color-text-secondary);
        font-size: 15px;
    }
    
    /* Productos Más Buscados - Ocultar tabla y mostrar cards en tablet */
    .top-products-table {
        display: none; /* Ocultar tabla en tablet */
    }
    
    .top-products-cards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 16px;
    }
    
    /* Cards de Productos Más Buscados para tablet */
    .product-card {
        background-color: var(--color-secondary-light);
        border: 1px solid var(--color-border);
        border-radius: 12px;
        padding: 18px;
        transition: all 0.3s ease;
    }
    
    .product-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
        border-color: var(--color-primary);
    }
    
    .product-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--color-border);
    }
    
    .product-name {
        font-size: 17px;
        font-weight: 600;
        color: var(--color-text);
        margin: 0;
        flex: 1;
        margin-right: 12px;
    }
    
    .product-badge {
        font-size: 15px;
        font-weight: 700;
        padding: 5px 14px;
        border-radius: 8px;
        background-color: rgba(255, 215, 0, 0.15);
        color: var(--color-primary);
        white-space: nowrap;
    }
    
    .product-card-body {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .product-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 16px;
        padding: 8px 0;
    }
    
    .product-metric-inline {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 0 0 auto;
    }
    
    .product-keywords-inline {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
    }
    
    .product-label {
        font-size: 13px;
        color: var(--color-text-secondary);
        font-weight: 500;
        white-space: nowrap;
    }
    
    .product-value {
        font-size: 15px;
        color: var(--color-text);
        font-weight: 600;
        white-space: nowrap;
    }
    
    .product-keywords {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .product-keyword-badge {
        background: rgba(255, 215, 0, 0.2);
        padding: 4px 8px;
        border-radius: 6px;
        font-size: 12px;
        color: var(--color-primary);
        font-weight: 500;
        white-space: nowrap;
    }
    
    .product-no-keywords {
        opacity: 0.5;
        font-size: 13px;
        font-style: italic;
    }
    
    .product-link-row {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding: 8px 0;
        border-top: 1px solid var(--color-border);
    }
    
    .product-link-container {
        flex: 1;
        min-width: 0;
    }
    
    .product-link-url {
        color: var(--color-primary) !important;
        text-decoration: none;
        font-weight: 500;
        font-size: 13px;
        word-break: break-all;
        display: block;
        transition: opacity 0.2s ease;
    }
    
    .product-link-url:hover {
        opacity: 0.8;
        text-decoration: underline;
    }
    
    .product-no-link {
        opacity: 0.5;
        font-size: 13px;
        font-style: italic;
    }
    
    .product-empty {
        text-align: center;
        padding: 32px;
        color: var(--color-text-secondary);
        font-size: 15px;
    }
}

/* Mobile: ≤640px */
@media (max-width: 640px) {
    /* Added for responsive */
    .sidebar {
        width: 100%;
        max-width: 320px;
    }
    
    .sidebar-open {
        z-index: 1003;
    }
    
    .main-content {
        padding: 16px;
    }
    
    /* Ocultar swipe area - ya no se usa */
    .swipe-area {
        display: none !important;
    }
    
    /* Mostrar botón hamburger */
    .menu-toggle-btn {
        display: flex !important;
        top: 12px !important;
        left: 12px !important;
        width: 44px !important;
        height: 44px !important;
        aspect-ratio: 1 !important; /* Mantener forma cuadrada siempre */
        font-size: 22px;
        z-index: 1004; /* Por encima del sidebar abierto */
    }
    
    /* Botón refresh - Posicionarlo arriba a la derecha, mismas dimensiones que menu-toggle-btn */
    .btn-refresh {
        position: fixed !important;
        top: 12px !important; /* Misma posición vertical que el botón del menú */
        right: 12px !important; /* Posición a la derecha */
        left: auto !important; /* Anular left */
        z-index: 1004 !important; /* Mismo z-index que el botón del menú */
        width: 44px !important; /* Mismo ancho que menu-toggle-btn */
        height: 44.2px !important; /* Base mobile - Proporcional al tamaño del menú (44px * 1.0045) */
        /* aspect-ratio: 1 !important; */ /* Desbloqueado para permitir ajuste manual de altura */
        border-radius: 8px !important; /* Mismo border-radius que menu-toggle-btn */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important; /* Mismo box-shadow que menu-toggle-btn */
        box-sizing: border-box !important; /* Incluir border en el height */
        display: flex !important;
    }
    
    /* Icono del botón refresh - Adaptado al tamaño del botón (40px altura) */
    .btn-refresh i {
        font-size: 18px !important; /* Adaptado al tamaño más pequeño del botón */
    }

    /* Ocultar botón refresh cuando el menú esté abierto */
    body.menu-open .btn-refresh {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    
    /* Sidebar header ajustes - Centrado para que no se tape con el botón */
    .sidebar-header {
        padding: 20px 16px;
        justify-content: center;
    }
    
    .sidebar-header h2 {
        font-size: 18px;
    }
    
    .sidebar-logo {
        width: 36px;
        height: 36px;
    }
    
    /* Navegación */
    .nav-link {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .nav-icon {
        font-size: 18px;
        width: 20px;
    }
    
    /* Footer del sidebar */
    .sidebar-footer {
        padding: 12px;
    }
    
    .btn-logout {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    /* Contenido principal - Ajustar padding para el botón hamburger */
    .page-header {
        margin-bottom: 0 !important; /* Sin margin-bottom para que todas las páginas queden igual */
        padding-top: 0;
        padding-left: 60px; /* Espacio para el botón hamburger */
    }
    
    /* Ajustar el contenido para que quede 2px después de los subtítulos */
    .page-header p {
        margin-bottom: 0 !important;
    }
    
    /* Agregar margin-top al contenido para crear espacio después del subtítulo */
    #page-content > #conversations-content,
    #page-content > #clients-content,
    #page-content > #analytics-content {
        margin-top: 20px !important;
    }
    
    /* Resumen General */
    #page-content > #dashboard-content {
        margin-top: 40px !important;
    }
    
    .page-header h1 {
        font-size: 24px;
        margin-bottom: 4px;
    }
    
    .page-header p {
        font-size: 14px;
    }
    
    .page-header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    /* KPI Cards */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .kpi-card {
        padding: 20px;
    }
    
    .kpi-value {
        font-size: 32px;
    }
    
    .kpi-label {
        font-size: 13px;
    }
    
    /* Charts */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .chart-container {
        padding: 20px;
    }
    
    .chart-title {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    /* Icono del botón refresh - Adaptado al tamaño del botón (40px altura) */
    .btn-refresh i {
        font-size: 18px !important; /* Adaptado al tamaño más pequeño del botón */
    }
    
    .btn-refresh.completed::after {
        font-size: 16px;
    }
    
    /* Cards */
    .card {
        padding: 20px;
        margin-bottom: 16px;
    }
    
    .card-header {
        margin-bottom: 20px; /* Aumentado de 16px para más espacio */
        padding-bottom: 16px; /* Aumentado de 12px para más espacio */
        flex-direction: column !important; /* Cambiar a columna para apilar título y subtítulo */
        align-items: flex-start !important; /* Alinear a la izquierda */
        width: 100%; /* Ocupar todo el ancho */
    }
    
    .card-header p {
        margin-top: 12px !important; /* Aumentado de 8px para más espacio entre título y descripción */
        margin-bottom: 0;
        width: 100%; /* Ocupar todo el ancho */
    }
    
    .card-title {
        font-size: 18px;
        margin-bottom: 8px; /* Añadir espacio después del título */
        width: 100%; /* Ocupar todo el ancho */
    }
    
    /* Espaciado adicional para el contenido dentro de cards (charts) */
    .card > div[style*="padding"] {
        padding-top: 20px !important; /* Asegurar espacio entre header y contenido */
    }
    
    /* Tablas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 16px; /* Añadir espacio entre card-header y tabla */
    }
    
    table {
        font-size: 13px;
        min-width: 600px; /* Ancho mínimo para scroll horizontal */
    }
    
    th, td {
        padding: 10px 12px;
    }
    
    th {
        font-size: 12px;
    }
    
    /* Inteligencia de Negocio - Ocultar tabla y mostrar cards en mobile */
    .business-intelligence-table {
        display: none; /* Ocultar tabla en mobile */
    }
    
    .business-intelligence-cards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 16px;
    }
    
    /* Cards de Inteligencia de Negocio */
    .bi-card {
        background-color: var(--color-secondary-light);
        border: 1px solid var(--color-border);
        border-radius: 12px;
        padding: 16px;
        transition: all 0.3s ease;
    }
    
    .bi-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
        border-color: var(--color-primary);
    }
    
    .bi-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--color-border);
    }
    
    .bi-keyword {
        font-size: 16px;
        font-weight: 600;
        color: var(--color-primary);
        margin: 0;
    }
    
    .bi-badge {
        font-size: 18px;
        font-weight: 700;
        padding: 4px 12px;
        border-radius: 8px;
        background-color: rgba(255, 215, 0, 0.1);
    }
    
    .bi-card-body {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .bi-metric {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
    }
    
    .bi-label {
        font-size: 13px;
        color: var(--color-text-secondary);
        font-weight: 500;
    }
    
    .bi-value {
        font-size: 14px;
        color: var(--color-text);
        font-weight: 600;
        text-align: right;
    }
    
    .bi-value small {
        font-size: 11px;
        opacity: 0.7;
        font-weight: 400;
    }
    
    .bi-empty {
        text-align: center;
        padding: 24px;
        color: var(--color-text-secondary);
        font-size: 14px;
    }
    
    /* Productos Más Buscados - Ocultar tabla y mostrar cards en mobile */
    .top-products-table {
        display: none; /* Ocultar tabla en mobile */
    }
    
    .top-products-cards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 16px;
    }
    
    /* Cards de Productos Más Buscados */
    .product-card {
        background-color: var(--color-secondary-light);
        border: 1px solid var(--color-border);
        border-radius: 12px;
        padding: 16px;
        transition: all 0.3s ease;
    }
    
    .product-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
        border-color: var(--color-primary);
    }
    
    .product-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--color-border);
        flex-direction: column;
        gap: 10px;
    }
    
    .product-name {
        font-size: 16px;
        font-weight: 600;
        color: var(--color-text);
        margin: 0;
        width: 100%;
    }
    
    .product-badge {
        font-size: 14px;
        font-weight: 700;
        padding: 4px 12px;
        border-radius: 8px;
        background-color: rgba(255, 215, 0, 0.15);
        color: var(--color-primary);
        align-self: flex-start;
    }
    
    .product-card-body {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .product-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 6px 0;
    }
    
    .product-metric-inline {
        display: flex;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
    }
    
    .product-keywords-inline {
        display: flex;
        align-items: center;
        gap: 6px;
        flex: 1;
        min-width: 0;
    }
    
    .product-label {
        font-size: 12px;
        color: var(--color-text-secondary);
        font-weight: 500;
        white-space: nowrap;
    }
    
    .product-value {
        font-size: 14px;
        color: var(--color-text);
        font-weight: 600;
        white-space: nowrap;
    }
    
    .product-keywords {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .product-keyword-badge {
        background: rgba(255, 215, 0, 0.2);
        padding: 3px 6px;
        border-radius: 6px;
        font-size: 11px;
        color: var(--color-primary);
        font-weight: 500;
        white-space: nowrap;
    }
    
    .product-no-keywords {
        opacity: 0.5;
        font-size: 12px;
        font-style: italic;
    }
    
    .product-link-row {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        padding: 8px 0;
        border-top: 1px solid var(--color-border);
    }
    
    .product-link-container {
        flex: 1;
        min-width: 0;
    }
    
    .product-link-url {
        color: var(--color-primary) !important;
        text-decoration: none;
        font-weight: 500;
        font-size: 12px;
        word-break: break-all;
        display: block;
        transition: opacity 0.2s ease;
    }
    
    .product-link-url:hover {
        opacity: 0.8;
        text-decoration: underline;
    }
    
    .product-no-link {
        opacity: 0.5;
        font-size: 12px;
        font-style: italic;
    }
    
    .product-empty {
        text-align: center;
        padding: 24px;
        color: var(--color-text-secondary);
        font-size: 14px;
    }
    
    /* Empty states */
    .empty-state {
        padding: 40px 16px;
    }
    
    .empty-state-icon {
        font-size: 48px;
        margin-bottom: 12px;
    }
    
    .empty-state-text {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .empty-state-subtext {
        font-size: 13px;
    }
}

/* ============================================
   LOGIN RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    /* Added for responsive */
    .login-container {
        padding: 16px;
    }
    
    .login-box {
        padding: 32px 24px;
        max-width: 100%;
    }
    
    .login-logo {
        width: 64px;
        height: 64px;
        margin-bottom: 12px;
    }
    
    .login-header h1 {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .login-header h3 {
        font-size: 14px;
    }
    
    .login-form {
        gap: 16px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .btn-login {
        padding: 12px;
        font-size: 15px;
    }
}

/* ============================================
   CHAT VIEWER RESPONSIVE
   ============================================ */

/* Tablet: 641px - 1024px */
@media (max-width: 1024px) {
    /* Added for responsive */
    .chat-container {
        flex-direction: column;
        height: auto;
        gap: 16px;
    }
    
    .chat-list {
        width: 100%;
        max-height: 300px;
    }
    
    .chat-viewer {
        min-height: 500px;
    }
}

/* Mobile: ≤640px */
@media (max-width: 640px) {
    /* Added for responsive */
    .chat-container {
        gap: 12px;
    }
    
    .chat-list {
        max-height: 250px;
        border-radius: 8px;
    }
    
    .chat-list-header {
        padding: 12px;
    }
    
    .chat-list-header h3 {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .chat-list-search {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .chat-item {
        padding: 10px;
    }
    
    .chat-item-id {
        font-size: 13px;
        margin-bottom: 8px; /* Añadir más espacio entre nombre y fecha */
    }
    
    .chat-item-date {
        font-size: 11px;
        margin-top: 4px; /* Espacio adicional para separar del nombre */
    }
    
    .chat-viewer {
        min-height: 400px;
        border-radius: 8px;
    }
    
    .chat-viewer-header {
        padding: 12px 16px;
    }
    
    .chat-viewer-header h3 {
        font-size: 16px;
    }
    
    .chat-viewer-info {
        font-size: 11px;
    }
    
    .chat-messages {
        padding: 16px;
        gap: 10px;
    }
    
    .chat-message {
        max-width: 85%;
    }
    
    /* Ajustes responsive para mensajes del cliente */
    .mensaje-cliente.mensaje-corto {
        max-width: none !important;
        width: fit-content !important;
    }
    
    .mensaje-cliente.mensaje-medio {
        max-width: min(80%, 400px) !important;
    }
    
    .mensaje-cliente.mensaje-largo {
        max-width: min(85%, 500px) !important;
    }
    
    .mensaje-cliente,
    .mensaje-bot {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .message-text {
        font-size: 13px;
    }
    
    .message-meta {
        font-size: 10px;
        margin-top: 4px;
    }
    
    .message-time {
        font-size: 10px;
    }
    
    .message-type {
        font-size: 9px;
        padding: 2px 6px;
    }
    
    .chat-empty {
        padding: 30px 16px;
    }
    
    .chat-empty-icon {
        font-size: 48px;
        margin-bottom: 12px;
    }
    
    .chat-empty-text {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .chat-empty-subtext {
        font-size: 13px;
    }
}

/* ============================================
   UTILIDADES RESPONSIVE
   ============================================ */

/* Prevenir scroll horizontal en mobile */
@media (max-width: 640px) {
    /* Added for responsive */
    body {
        overflow-x: hidden;
    }
    
    .app-container {
        overflow-x: hidden;
    }
    
    .main-content {
        overflow-x: hidden;
    }
    
    /* Asegurar que las imágenes no se desborden */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Ajustar inputs y selects */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px; /* Evitar zoom en iOS */
    }
}

/* Mejoras de accesibilidad y touch */
@media (max-width: 1024px) {
    /* Added for responsive */
    /* Aumentar área táctil mínima */
    .nav-link,
    .btn,
    .btn-logout {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Excluir btn-refresh del min-height para permitir ajuste manual */
    .btn-refresh {
        min-height: unset !important;
    }
    
    /* chat-item necesita mantener su estructura interna para el espaciado */
    .chat-item {
        min-height: 44px;
        display: block; /* Mantener block para que el espaciado funcione */
    }
    
    /* Mejorar contraste en mobile */
    .nav-link:focus,
    .btn:focus,
    .btn-logout:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }
}

/* Ajustes para tablets en orientación landscape */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: landscape) {
    /* Added for responsive */
    .sidebar {
        width: 260px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 360px) {
    /* Added for responsive */
    .main-content {
        padding: 12px;
    }
    
    /* Ajustar botón hamburger para pantallas muy pequeñas */
    .menu-toggle-btn {
        top: 8px !important;
        left: 8px !important;
        width: 40px !important;
        height: 40px !important;
        aspect-ratio: 1 !important; /* Mantener forma cuadrada siempre */
        font-size: 20px;
    }
    
    /* Botón refresh - Ajustar para pantallas muy pequeñas, posicionarlo arriba a la derecha, mismas dimensiones que menu-toggle-btn */
    .btn-refresh {
        position: fixed !important;
        top: 8px !important; /* Misma posición vertical que el botón del menú */
        right: 8px !important; /* Posición a la derecha */
        left: auto !important; /* Anular left */
        z-index: 1004 !important;
        width: 40px !important; /* Mismo ancho que menu-toggle-btn */
        height: 40.2px !important; /* Proporcional desde mobile (40px * 1.0045) */
        /* aspect-ratio: 1 !important; */ /* Desbloqueado para permitir ajuste manual de altura */
        border-radius: 8px !important; /* Mismo border-radius que menu-toggle-btn */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important; /* Mismo box-shadow que menu-toggle-btn */
        box-sizing: border-box !important; /* Incluir border en el height */
        display: flex !important;
    }
    
    /* Icono del botón refresh - Adaptado al tamaño del botón (36px altura) */
    .btn-refresh i {
        font-size: 16px !important; /* Adaptado al tamaño más pequeño del botón */
    }
    
    /* Ajustar padding del header para el botón */
    .page-header {
        padding-top: 0;
        padding-left: 56px; /* Espacio para el botón hamburger más pequeño */
        margin-bottom: 0 !important;
    }
    
    /* Ajustar el contenido para que quede 2px después de los subtítulos */
    .page-header p {
        margin-bottom: 0 !important;
    }
    
    /* Agregar margin-top al contenido para crear espacio después del subtítulo */
    #page-content > #conversations-content,
    #page-content > #clients-content,
    #page-content > #analytics-content {
        margin-top: 20px !important;
    }
    
    /* Resumen General */
    #page-content > #dashboard-content {
        margin-top: 40px !important;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .kpi-value {
        font-size: 28px;
    }
    
    .card {
        padding: 16px;
    }
    
    .login-box {
        padding: 24px 20px;
    }
}

/* ============================================
   CHARTS RESPONSIVE (Chart.js)
   ============================================ */

/* Estilos para desktop - Análisis de Horarios y Embudo de Conversión */
@media (min-width: 1025px) {
    /* Análisis de Horarios - Usar toda la altura disponible en desktop */
    #heatmap-chart {
        width: 100% !important;
        height: 500px !important; /* Altura fija para desktop */
        max-height: none !important;
    }
    
    /* Contenedor del gráfico de heatmap en desktop */
    .heatmap-chart-container {
        padding: 24px !important;
        width: 100%;
        min-height: 520px; /* Altura mínima para el contenedor */
    }
    
    /* Wrapper con scroll para el heatmap */
    .heatmap-scroll-wrapper {
        width: 100%;
        max-height: 800px;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar {
        width: 8px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-track {
        background: var(--color-bg-secondary, #1a1a1a);
        border-radius: 4px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-thumb {
        background: var(--color-primary, #FFD700);
        border-radius: 4px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-thumb:hover {
        background: var(--color-primary-hover, #ffed4e);
    }
    
    /* Embudo de Conversión - Desktop */
    #conversion-funnel-chart {
        width: 100% !important;
        height: 500px !important;
        max-height: 500px !important;
        min-height: 500px !important;
    }
    
    .conversion-funnel-container {
        padding: 24px !important;
        width: 100%;
        min-height: 550px !important;
        height: 550px !important;
    }
    
    /* Mantener compatibilidad con nombre antiguo */
    #funnel-chart {
        width: 100% !important;
        height: 500px !important;
        max-height: 500px !important;
        min-height: 500px !important;
    }
    
    .funnel-chart-container {
        padding: 24px !important;
        width: 100%;
        min-height: 550px !important;
        height: 550px !important;
    }
}

@media (max-width: 640px) {
    /* Added for responsive */
    /* Asegurar que los canvas de Chart.js sean responsive */
    canvas {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Contenedores de charts */
    .chart-container canvas,
    #sentiment-chart,
    #response-types-chart,
    #heatmap-chart {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Embudo de Conversión - Mobile */
    #conversion-funnel-chart {
        width: 100% !important;
        height: 450px !important;
        max-height: 450px !important;
        min-height: 450px !important;
    }
    
    .conversion-funnel-container {
        padding: 16px 0 0 0 !important;
        width: 100%;
        min-height: 480px !important;
        height: 480px !important;
    }
    
    /* Mantener compatibilidad con nombre antiguo */
    #funnel-chart {
        width: 100% !important;
        height: 450px !important;
        max-height: 450px !important;
        min-height: 450px !important;
    }
    
    .funnel-chart-container {
        padding: 16px 0 0 0 !important;
        width: 100%;
        min-height: 480px !important;
        height: 480px !important;
    }
    
    /* Ajustar padding de contenedores de charts en cards */
    .card > div[style*="padding"] {
        padding: 20px 16px !important; /* Más padding-top para separar del header */
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    /* Added for responsive */
    canvas {
        max-width: 100%;
    }
    
    .chart-container canvas {
        max-height: 350px;
    }
    
    /* Análisis de Horarios - Asegurar que el gráfico ocupe todo el ancho y tenga buena altura */
    #heatmap-chart {
        width: 100% !important;
        height: 500px !important; /* Altura fija para que se vea bien */
        max-height: none !important;
        image-rendering: -webkit-optimize-contrast; /* Mejor calidad de renderizado */
        image-rendering: auto; /* Renderizado suave para gráficos */
    }
    
    /* Contenedor del gráfico de heatmap */
    .heatmap-chart-container {
        padding: 20px 0 0 0 !important; /* Sin padding lateral para usar todo el ancho, solo padding superior */
        width: 100%;
        min-height: 590px; /* Altura mínima para el contenedor */
    }
    
    /* Wrapper con scroll para el heatmap en tablet */
    .heatmap-scroll-wrapper {
        width: 100%;
        max-height: 600px;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar {
        width: 8px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-track {
        background: var(--color-bg-secondary, #1a1a1a);
        border-radius: 4px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-thumb {
        background: var(--color-primary, #FFD700);
        border-radius: 4px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-thumb:hover {
        background: var(--color-primary-hover, #ffed4e);
    }
    
    /* Asegurar que el canvas use todo el ancho */
    #heatmap-chart {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Embudo de Conversión - Tablet */
    #conversion-funnel-chart {
        width: 100% !important;
        height: 480px !important;
        max-height: 480px !important;
        min-height: 480px !important;
    }
    
    .conversion-funnel-container {
        padding: 20px 0 0 0 !important;
        width: 100%;
        min-height: 520px !important;
        height: 520px !important;
    }
    
    /* Mantener compatibilidad con nombre antiguo */
    #funnel-chart {
        width: 100% !important;
        height: 480px !important;
        max-height: 480px !important;
        min-height: 480px !important;
    }
    
    .funnel-chart-container {
        padding: 20px 0 0 0 !important;
        width: 100%;
        min-height: 520px !important;
        height: 520px !important;
    }
    
    /* Mejorar área táctil de los elementos de la leyenda en tablet */
    #heatmap-chart + canvas,
    .chartjs-legend li {
        min-height: 44px; /* Área táctil mínima recomendada */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Asegurar que la leyenda use todo el ancho y esté alineada correctamente */
    .chartjs-legend {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px 0 !important; /* Padding vertical para área táctil */
        margin: 0 !important;
        cursor: pointer !important; /* Indicar que es interactivo */
    }
    
    .chartjs-legend li {
        width: auto !important;
        margin: 0 8px !important;
        padding: 12px 16px !important;
        cursor: pointer !important; /* Indicar que es interactivo */
        user-select: none; /* Prevenir selección de texto */
    }
    
    /* Mejorar feedback visual al tocar */
    .chartjs-legend li:hover,
    .chartjs-legend li:active {
        opacity: 0.7;
        transform: scale(1.05);
        transition: all 0.2s ease;
    }
}

/* Ajustes específicos para el gráfico de Análisis de Horarios en mobile */
@media (max-width: 640px) {
    /* Análisis de Horarios - Asegurar que el gráfico ocupe todo el ancho y tenga buena altura */
    #heatmap-chart {
        width: 100% !important;
        height: 450px !important; /* Altura fija para que se vea bien en mobile */
        max-height: none !important;
        image-rendering: -webkit-optimize-contrast; /* Mejor calidad de renderizado */
        image-rendering: auto; /* Renderizado suave para gráficos */
    }
    
    /* Contenedor del gráfico de heatmap */
    .heatmap-chart-container {
        padding: 16px 0 0 0 !important; /* Sin padding lateral para usar todo el ancho, solo padding superior */
        width: 100%;
        min-height: 535px; /* Altura mínima para el contenedor */
    }
    
    /* Wrapper con scroll para el heatmap en mobile */
    .heatmap-scroll-wrapper {
        width: 100%;
        max-height: 600px;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar {
        width: 6px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-track {
        background: var(--color-bg-secondary, #1a1a1a);
        border-radius: 3px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-thumb {
        background: var(--color-primary, #FFD700);
        border-radius: 3px;
    }
    
    .heatmap-scroll-wrapper::-webkit-scrollbar-thumb:hover {
        background: var(--color-primary-hover, #ffed4e);
    }
    
    /* Asegurar que el canvas use todo el ancho */
    #heatmap-chart {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Mejorar área táctil de los elementos de la leyenda en mobile */
    #heatmap-chart + canvas,
    .chartjs-legend li {
        min-height: 48px !important; /* Área táctil aumentada */
        min-width: 48px !important; /* Ancho mínimo para área táctil */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 14px 16px !important; /* Padding aumentado para área táctil */
        margin: 4px 6px !important; /* Margen para separar elementos */
        touch-action: manipulation; /* Mejorar respuesta táctil */
        -webkit-tap-highlight-color: rgba(255, 215, 0, 0.3); /* Resaltado al tocar */
    }
    
    /* Asegurar que los elementos de la leyenda sean fáciles de tocar */
    .chartjs-legend-item {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 14px 18px !important;
        margin: 4px 6px !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(255, 215, 0, 0.3) !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }
    
    /* Asegurar que la leyenda use todo el ancho y esté alineada correctamente */
    .chartjs-legend {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px 5px !important; /* Padding vertical aumentado */
        margin: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
    }
    
    /* Mejorar feedback visual al tocar */
    .chartjs-legend li:hover,
    .chartjs-legend li:active,
    .chartjs-legend li:focus {
        opacity: 0.8 !important;
        transform: scale(1.05) !important;
        transition: all 0.2s ease !important;
        background-color: rgba(255, 255, 255, 0.05) !important;
        border-radius: 6px !important;
    }
    
    /* Asegurar que los elementos sean clickeables en todos los navegadores */
    .chartjs-legend li * {
        pointer-events: none !important; /* Permitir que el click pase al li */
    }
    
    .chartjs-legend li {
        pointer-events: auto !important; /* Asegurar que el li sea clickeable */
    }
}

/* ============================================
   HEATMAP WEEK SELECTOR - RESPONSIVE
   ============================================ */

/* Estilos base para el selector de semana */
.heatmap-week-selector {
    width: 100%;
    margin-bottom: 16px;
}

.week-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.week-nav-btn {
    background-color: var(--color-secondary-light, #1a1a1a);
    border: 1px solid var(--color-border, #333333);
    border-radius: 8px;
    color: var(--color-primary, #FFD700);
    cursor: pointer;
    padding: 10px 16px;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}

.week-nav-btn:hover {
    background-color: rgba(255, 215, 0, 0.1);
    border-color: var(--color-primary, #FFD700);
    transform: scale(1.05);
}

.week-nav-btn:active {
    transform: scale(0.95);
}

.week-nav-btn:focus {
    outline: 2px solid var(--color-primary, #FFD700);
    outline-offset: 2px;
}

.week-display {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.week-range-text {
    color: var(--color-text, #ffffff);
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 100%;
}

/* Desktop: >1024px */
@media (min-width: 1025px) {
    .week-navigation {
        gap: 20px;
    }
    
    .week-nav-btn {
        padding: 12px 20px;
        font-size: 20px;
        min-width: 48px;
        min-height: 48px;
    }
    
    .week-range-text {
        font-size: 18px;
    }
}

/* Tablet: 641px - 1024px */
@media (min-width: 641px) and (max-width: 1024px) {
    .heatmap-week-selector {
        padding: 16px 20px 0 20px !important;
    }
    
    .week-navigation {
        gap: 16px;
    }
    
    .week-nav-btn {
        padding: 10px 16px;
        font-size: 18px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .week-range-text {
        font-size: 16px;
    }
}

/* Mobile: ≤640px */
@media (max-width: 640px) {
    .heatmap-week-selector {
        padding: 12px 16px 0 16px !important;
    }
    
    .week-navigation {
        gap: 12px;
        flex-wrap: nowrap;
    }
    
    .week-nav-btn {
        padding: 10px 14px;
        font-size: 16px;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
    }
    
    .week-range-text {
        font-size: 14px;
        white-space: normal;
        line-height: 1.4;
        max-width: 100%;
    }
    
    .week-display {
        flex: 1;
        min-width: 0;
        padding: 0 4px;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 360px) {
    .week-navigation {
        gap: 8px;
    }
    
    .week-nav-btn {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .week-range-text {
        font-size: 12px;
    }
}

