
/* ============ VARIABLES CETI ============ */
:root {
    --ceti-primary: #1e40af;
    --ceti-secondary: #3b82f6;
    --ceti-orange: #f59e0b;
    --ceti-orange-dark: #d97706;
    --ceti-green: #10b981;
    --ceti-green-dark: #059669;
    --ceti-red: #dc2626;
    --ceti-red-dark: #b91c1c;
    --ceti-gray-50: #f9fafb;
    --ceti-gray-100: #f3f4f6;
    --ceti-gray-200: #e5e7eb;
    --ceti-gray-300: #d1d5db;
    --ceti-gray-500: #6b7280;
    --ceti-gray-700: #374151;
    --ceti-gray-900: #111827;
    --ceti-white: #ffffff;
    --ceti-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ceti-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ============ CONNECTION STATUS DISCRETO ============ */
.connection-status {
    position: fixed;
    top: 15px;
    right: 15px;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 1040; /* REDUCIDO - Por debajo del sidebar */
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 90px;
    justify-content: center;
    opacity: 0.9;
    max-width: 200px;
}

.connection-status.online {
    background: rgba(16, 185, 129, 0.9);
    color: white;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.connection-status.offline {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.3);
    animation: pulseOfflineSubtle 3s ease-in-out infinite;
}

.connection-status-icon {
    font-size: 0.8rem;
    opacity: 0.9;
}

.connection-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

/* Auto-ocultar cuando está online */
.connection-status.online {
    animation: fadeInOut 4s ease-in-out;
}

@keyframes pulseOfflineSubtle {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.02); }
}

@keyframes fadeInOut {
    0%, 15%, 85%, 100% { opacity: 0.9; }
    50% { opacity: 0.6; }
}

/* ============ PWA INSTALL PROMPT ELEGANTE ============ */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--ceti-primary) 0%, var(--ceti-secondary) 100%);
    color: white;
    border-radius: 16px;
    box-shadow: var(--ceti-shadow-lg), 0 25px 50px rgba(30, 64, 175, 0.25);
    z-index: 1045; /* REDUCIDO - Por debajo del sidebar */
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 420px;
    width: calc(100% - 40px);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
}

.install-prompt.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.install-prompt::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ceti-orange) 0%, var(--ceti-green) 100%);
}

.install-prompt-content {
    padding: 1.25rem;
}

.install-prompt-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.install-prompt-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.install-prompt-text h6 {
    margin: 0 0 0.25rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}

.install-prompt-text p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.85;
    line-height: 1.4;
}

.install-prompt-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn-install {
    background: rgba(255, 255, 255, 0.95);
    color: var(--ceti-primary);
    border: none;
    padding: 0.7rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-install:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

.btn-install:active {
    transform: translateY(0);
}

.btn-dismiss {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============ OFFLINE BANNER MEJORADO ============ */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000; /* Máxima prioridad - Por encima de todo */
    background: linear-gradient(135deg, var(--ceti-orange) 0%, var(--ceti-orange-dark) 100%);
    color: white;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    animation: slideDownSmooth 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.offline-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 1rem;
}

.offline-banner-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.offline-banner-icon {
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.offline-banner-text {
    flex: 1;
}

.offline-banner-text strong {
    font-weight: 600;
}

.offline-banner-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-retry-connection {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-retry-connection:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn-retry-connection:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-dismiss-banner {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-dismiss-banner:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

@keyframes slideDownSmooth {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============ NOTIFICATIONS REFINADAS ============ */
.pwa-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1046; /* Por debajo del sidebar */
    min-width: 280px;
    max-width: 400px;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--ceti-shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideUpNotification 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pwa-notification::before {
    content: '';
    width: 4px;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 10px 0 0 10px;
}

.pwa-notification.alert-success {
    background: rgba(16, 185, 129, 0.95);
    color: white;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.pwa-notification.alert-success::before {
    background: rgba(255, 255, 255, 0.8);
}

.pwa-notification.alert-warning {
    background: rgba(245, 158, 11, 0.95);
    color: white;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.pwa-notification.alert-warning::before {
    background: rgba(255, 255, 255, 0.8);
}

.pwa-notification.alert-info {
    background: rgba(59, 130, 246, 0.95);
    color: white;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.pwa-notification.alert-info::before {
    background: rgba(255, 255, 255, 0.8);
}

.pwa-notification.alert-error {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pwa-notification.alert-error::before {
    background: rgba(255, 255, 255, 0.8);
}

.pwa-notification-icon {
    font-size: 1rem;
    opacity: 0.9;
}

@keyframes slideUpNotification {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============ UPDATE NOTIFICATION ============ */
.update-notification {
    position: fixed;
    bottom: 90px; /* Encima del install prompt */
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--ceti-green) 0%, var(--ceti-green-dark) 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--ceti-shadow-lg), 0 20px 40px rgba(16, 185, 129, 0.3);
    z-index: 1047; /* Por debajo del sidebar */
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideUpNotification 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    max-width: 350px;
    width: calc(100% - 40px);
}

.update-content {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
}

.btn-update {
    background: rgba(255, 255, 255, 0.95);
    color: var(--ceti-green-dark);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-update:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

/* ============ SYNC STATUS ============ */
.sync-status {
    position: fixed;
    top: 60px; /* Debajo del connection status */
    right: 15px;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 1040; /* REDUCIDO - Por debajo del sidebar */
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
    max-width: 180px;
}

/* ============ RESPONSIVE DESIGN OPTIMIZADO ============ */
@media (max-width: 768px) {
    .connection-status {
        top: 10px;
        right: 10px;
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        min-width: 80px;
        max-width: 150px;
    }
    
    .sync-status {
        top: 50px;
        right: 10px;
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        max-width: 150px;
    }
    
    .install-prompt {
        left: 15px;
        right: 15px;
        transform: none;
        width: auto;
        max-width: none;
    }
    
    .install-prompt.show {
        transform: translateY(0);
    }
    
    .install-prompt-content {
        padding: 1rem;
    }
    
    .install-prompt-header {
        gap: 0.8rem;
    }
    
    .install-prompt-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .install-prompt-text h6 {
        font-size: 1rem;
    }
    
    .install-prompt-text p {
        font-size: 0.8rem;
    }
    
    .install-prompt-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-install,
    .btn-dismiss {
        width: 100%;
        justify-content: center;
    }
    
    .offline-banner {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
    
    .offline-banner-content {
        flex-direction: column;
        gap: 0.6rem;
        text-align: center;
    }
    
    .offline-banner-main {
        justify-content: center;
    }
    
    .pwa-notification {
        left: 15px;
        right: 15px;
        bottom: 15px;
        min-width: auto;
        max-width: none;
    }
    
    .update-notification {
        left: 15px;
        right: 15px;
        transform: none;
        bottom: 15px;
        max-width: none;
        width: auto;
    }
}

@media (max-width: 480px) {
    .connection-status {
        top: 8px;
        right: 8px;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        min-width: 70px;
        max-width: 120px;
    }
    
    .sync-status {
        top: 45px;
        right: 8px;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        max-width: 120px;
    }
    
    .offline-banner {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .offline-banner-content {
        gap: 0.5rem;
    }
    
    .btn-retry-connection {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }
    
    .install-prompt-content {
        padding: 0.8rem;
    }
    
    .install-prompt-text h6 {
        font-size: 0.95rem;
    }
    
    .install-prompt-text p {
        font-size: 0.75rem;
    }
}

/* ============ LANDSCAPE OPTIMIZATION ============ */
@media (max-height: 500px) and (orientation: landscape) {
    .install-prompt {
        max-width: 380px;
        right: 20px;
        left: auto;
        transform: translateX(0);
    }
    
    .install-prompt.show {
        transform: translateY(0);
    }
    
    .install-prompt-header {
        margin-bottom: 0.6rem;
    }
    
    .install-prompt-actions {
        flex-direction: row;
        margin-top: 0.6rem;
    }
    
    .offline-banner {
        padding: 0.4rem 1rem;
    }
    
    .connection-status {
        top: 45px;
    }
    
    .sync-status {
        top: 80px;
    }
}

/* ============ PERFORMANCE OPTIMIZATIONS ============ */
.offline-banner,
.connection-status,
.install-prompt,
.pwa-notification,
.update-notification,
.sync-status {
    will-change: transform, opacity;
    contain: layout style paint;
}

/* ============ ANIMACIONES DE SALIDA ============ */
@keyframes slideUpFadeOut {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-100%);
        opacity: 0;
    }
}

@keyframes fadeOutScale {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* ============ ACCESIBILIDAD ============ */
@media (prefers-reduced-motion: reduce) {
    .offline-banner,
    .connection-status,
    .install-prompt,
    .pwa-notification,
    .update-notification,
    .sync-status {
        animation: none;
        transition: opacity 0.2s ease;
    }
    
    .btn-install:hover,
    .btn-update:hover,
    .btn-retry-connection:hover {
        transform: none;
    }
    
    .connection-status.offline {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .install-prompt,
    .connection-status,
    .pwa-notification,
    .offline-banner,
    .sync-status {
        border-width: 2px;
    }
    
    .connection-status.online,
    .connection-status.offline {
        border-width: 2px;
    }
}

/* ============ DARK MODE REFINADO ============ */
@media (prefers-color-scheme: dark) {
    .offline-banner {
        background: linear-gradient(135deg, var(--ceti-red) 0%, var(--ceti-red-dark) 100%);
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    }
    
    .connection-status.online {
        background: rgba(34, 197, 94, 0.9);
        box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
    }
    
    .connection-status.offline {
        background: rgba(248, 113, 113, 0.9);
        box-shadow: 0 2px 12px rgba(248, 113, 113, 0.4);
    }
    
    .install-prompt {
        background: linear-gradient(135deg, var(--ceti-gray-900) 0%, var(--ceti-gray-700) 100%);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ============ PRINT STYLES ============ */
@media print {
    .offline-banner,
    .connection-status,
    .install-prompt,
    .pwa-notification,
    .update-notification,
    .sync-status {
        display: none !important;
    }
}

/* ============ UTILS ============ */
.pwa-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.pwa-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ============ CORRECCIONES ESPECÍFICAS PARA CONFLICTOS ============ */
/* Asegurar que el header principal no interfiera */
.sidebar {
    z-index: 1050 !important; /* Sidebar por encima del connection status */
}

.main-header {
    z-index: 1045 !important; /* Header por debajo del sidebar pero encima de connection */
}

/* Notificaciones dropdown con z-index correcto */
.notification-dropdown {
    z-index: 1055 !important; /* Por encima del sidebar */
}

/* Corrección para el install prompt en móviles */
@media (max-width: 576px) {
    .install-prompt {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
        max-width: none;
    }
    
    .install-prompt.show {
        transform: translateY(0);
    }
    
    .update-notification {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
    }
}
/* Ajustar posición del connection status cuando el sidebar esté abierto */
@media (min-width: 992px) {
    .connection-status {
        right: 15px; /* Mantener en la esquina derecha */
        top: 15px;
    }
    
    /* Cuando el sidebar esté cerrado, puede moverse un poco más a la izquierda si es necesario */
    .sidebar-closed ~ .main-content .connection-status {
        right: 15px;
    }
}

@media (max-width: 991px) {
    .sidebar {
        z-index: 1055 !important;
    }
    
    .sidebar-open {
        z-index: 1055 !important;
    }
}

@media (max-width: 768px) {
    .connection-status {
        top: 10px;
        right: 10px;
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        min-width: 80px;
        max-width: 150px;
        z-index: 1040; /* Por debajo del sidebar móvil */
    }
    
    .sync-status {
        top: 50px;
        right: 10px;
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        max-width: 150px;
        z-index: 1040;
    }
}

@media (max-width: 480px) {
    .connection-status {
        top: 8px;
        right: 8px;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        min-width: 70px;
        max-width: 120px;
        z-index: 1040;
    }
    
    .sync-status {
        top: 45px;
        right: 8px;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        max-width: 120px;
        z-index: 1040;
    }
}

/* En móviles, asegurar que no interfiera */
@media (max-width: 991px) {
    .connection-status {
        top: 10px;
        right: 10px;
        z-index: 1040; /* Por debajo del sidebar móvil */
    }
}

