/**
 * ═══════════════════════════════════════════════════════════════
 * CLIMEX ONE - Sistema de Diseño Unificado
 * ═══════════════════════════════════════════════════════════════
 * 
 * Este archivo contiene todos los estilos base compartidos entre
 * las aplicaciones del ecosistema Climex One.
 * 
 * Aplicaciones: Index, CRM, Service, Finance, Report, Estimator
 * ═══════════════════════════════════════════════════════════════
 */

/* ─────────────────────────────────────────────────────────────────
   VARIABLES CSS - Colores, tipografía, espaciado
   ───────────────────────────────────────────────────────────────── */
:root {
    /* Colores de marca */
    --climex-primary: #007AFF;
    --climex-primary-dark: #0056b3;
    --climex-primary-light: #60a5fa;
    --climex-brand-dark: #1e40af;
    
    /* Colores por aplicación */
    --color-crm: #8b5cf6;
    --color-crm-light: #a78bfa;
    --color-service: #10b981;
    --color-service-light: #34d399;
    --color-finance: #f59e0b;
    --color-finance-light: #fbbf24;
    --color-report: #ef4444;
    --color-report-light: #f87171;
    --color-estimator: #06b6d4;
    --color-estimator-light: #22d3ee;
    
    /* Fondos y superficies (estilo iOS) */
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E5E5EA;
    
    /* Texto */
    --text-primary: #1C1C1E;
    --text-secondary: #3C3C43;
    --text-tertiary: #8E8E93;
    --text-quaternary: #AEAEB2;
    
    /* Estados */
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-error: #FF3B30;
    --color-info: #5AC8FA;
    
    /* Bordes y sombras */
    --border-color: #e5e7eb;
    --border-color-light: rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    
    /* Radios */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;
    
    /* Tipografía */
    --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* Transiciones */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Z-index scale */
    --z-dropdown: 50;
    --z-sticky: 60;
    --z-modal: 70;
    --z-modal-content: 75;
    --z-overlay: 80;
    --z-toast: 90;
    --z-loader: 100;
}

/* ─────────────────────────────────────────────────────────────────
   RESET Y BASE
   ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100dvh;
    overflow: hidden;
    font-family: var(--font-system);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────────────────────────
   LAYOUT PRINCIPAL
   ───────────────────────────────────────────────────────────────── */
.main-layout {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: relative;
}

.scroll-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 100px;
    padding-top: 10px;
}

/* ─────────────────────────────────────────────────────────────────
   CONTENEDOR MÁXIMO PARA APPS - Evita desproporciones en pantallas grandes
   ───────────────────────────────────────────────────────────────── */
.app-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* Para pantallas muy grandes, centrar el contenido */
@media (min-width: 1400px) {
    .app-container {
        max-width: 1000px;
    }
    
    .scroll-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .scroll-content > * {
        width: 100%;
        max-width: 1000px;
    }
}

/* Contenedor específico para formularios - más angosto */
.form-container {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

/* Contenedor para listas y grids */
.list-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* Contenedor para dashboards */
.dashboard-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────────────
   COMPONENTES iOS - Cards
   ───────────────────────────────────────────────────────────────── */
.ios-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color-light);
    transition: transform var(--transition-normal);
    margin-bottom: 12px;
}

.ios-card:active {
    transform: scale(0.99);
}

.ios-card--elevated {
    box-shadow: var(--shadow-lg);
}

.ios-card--interactive:hover {
    box-shadow: var(--shadow-md);
}

/* ─────────────────────────────────────────────────────────────────
   COMPONENTES iOS - Inputs
   ───────────────────────────────────────────────────────────────── */
.ios-input {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 16px;
    font-family: var(--font-system);
    outline: none;
    transition: all var(--transition-normal);
    box-sizing: border-box;
    color: var(--text-primary);
}

.ios-input:focus {
    background-color: var(--bg-secondary);
    border-color: var(--climex-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.ios-input::placeholder {
    color: var(--text-quaternary);
}

/* Variantes de input por app */
.ios-input--crm:focus {
    border-color: var(--color-crm);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.ios-input--service:focus {
    border-color: var(--color-service);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Fix para inputs de fecha en móvil */
.ios-input[type="date"],
.ios-input[type="time"] {
    max-width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ─────────────────────────────────────────────────────────────────
   COMPONENTES iOS - Botones
   ───────────────────────────────────────────────────────────────── */
.ios-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-system);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
}

.ios-btn:active {
    transform: scale(0.97);
}

.ios-btn--primary {
    background-color: var(--climex-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

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

.ios-btn--secondary {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.ios-btn--danger {
    background-color: #FEE2E2;
    color: var(--color-error);
}

.ios-btn--full {
    width: 100%;
}

/* ─────────────────────────────────────────────────────────────────
   FAB (Floating Action Button) - Menú flotante unificado
   ───────────────────────────────────────────────────────────────── */
.fab-menu-button {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.25);
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
}

.fab-menu-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.fab-menu-button:active {
    transform: scale(0.95);
}

.fab-menu-button i,
.fab-menu-button svg {
    color: white !important;
    stroke: white !important;
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.fab-menu-button.open {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
}

.fab-menu-button.open i,
.fab-menu-button.open svg {
    color: white;
    transform: rotate(45deg);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 200;
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Drawer */
.sidebar-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 201;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-drawer.open {
    right: 0;
}

@media (max-width: 400px) {
    .sidebar-drawer {
        width: 100%;
        right: -100%;
    }
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    color: white;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 12px;
    opacity: 0.8;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.nav-section:last-child {
    border-bottom: none;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 20px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #334155;
    text-decoration: none;
    transition: background 0.2s ease;
}

.nav-item:hover {
    background: #f8fafc;
}

.nav-item:active {
    background: #f1f5f9;
}

.nav-item img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
}

.nav-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.nav-item-text {
    font-weight: 600;
    font-size: 14px;
}

.nav-item-badge {
    margin-left: auto;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ─────────────────────────────────────────────────────────────────
   COMPONENTES iOS - Navegación inferior
   ───────────────────────────────────────────────────────────────── */
.ios-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: env(safe-area-inset-bottom);
}

.ios-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.ios-nav-item:hover {
    color: var(--text-secondary);
}

.ios-nav-item.active {
    color: var(--climex-primary);
}

.ios-nav-item span {
    font-size: 10px;
    font-weight: 500;
}

/* ─────────────────────────────────────────────────────────────────
   COMPONENTES iOS - Header
   ───────────────────────────────────────────────────────────────── */
.ios-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(242, 242, 247, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.ios-header__logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ios-header__logo img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.ios-header__title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* ─────────────────────────────────────────────────────────────────
   MODALES
   ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: var(--z-modal);
    animation: fadeIn var(--transition-slow) ease-out;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-2xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    max-height: 90dvh;
    overflow: hidden;
    animation: slideUp var(--transition-slow) ease-out;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

/* Modal desde abajo (mobile) */
@media (max-width: 640px) {
    .modal-overlay--bottom {
        align-items: flex-end;
        padding: 0;
    }
    
    .modal-overlay--bottom .modal-content {
        max-width: 100%;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        max-height: 85dvh;
    }
}

/* ─────────────────────────────────────────────────────────────────
   LOADER MODERNO - Pantalla de carga
   ───────────────────────────────────────────────────────────────── */
#app-loader,
.app-loader {
    position: fixed;
    inset: 0;
    background: linear-gradient(145deg, #F8F9FC 0%, #EEF1F8 100%);
    z-index: var(--z-loader);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

/* Contenedor del logo con efecto de círculos */
.loader-logo-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 140px;
}

/* Círculos de fondo animados */
.loader-logo-container::before {
    content: '';
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.08) 0%, rgba(30, 64, 175, 0.03) 100%);
    animation: loaderPulseOuter 2.5s ease-in-out infinite;
}

.loader-logo-container::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.12) 0%, rgba(30, 64, 175, 0.06) 100%);
    animation: loaderPulseInner 2.5s ease-in-out infinite 0.4s;
}

/* Spinner circular */
.loader-spinner {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2.5px solid rgba(30, 58, 95, 0.3);
    border-top-color: #1e3a5f;
    animation: loaderSpin 1s linear infinite;
}

/* Logo principal - TAMAÑO FIJO Y NITIDO */
.loader-logo,
.app-loader__logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 4px 16px rgba(0, 122, 255, 0.25));
    animation: loaderFloat 3s ease-in-out infinite;
    border-radius: 10px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Texto de carga con puntos animados */
.loader-text,
.app-loader__text,
#loading-text {
    margin-top: 28px;
    color: #64748b;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Puntos animados */
.loader-dots {
    display: flex;
    gap: 3px;
    margin-left: 4px;
}

.loader-dots span {
    width: 4px;
    height: 4px;
    background: #1e3a5f;
    border-radius: 50%;
    animation: loaderDotBounce 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(1) { animation-delay: 0s; }
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Barra de progreso opcional */
.loader-progress {
    width: 100px;
    height: 3px;
    background: rgba(30, 58, 95, 0.15);
    border-radius: 10px;
    margin-top: 16px;
    overflow: hidden;
}

.loader-progress-bar {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, #1e3a5f, #2d4a6f);
    border-radius: 10px;
    animation: loaderProgress 1.2s ease-in-out infinite;
}

/* ═══ ANIMACIONES DEL LOADER ═══ */
@keyframes loaderFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.02); }
}

@keyframes loaderPulseOuter {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.08); opacity: 0.3; }
}

@keyframes loaderPulseInner {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.06); opacity: 0.4; }
}

@keyframes loaderSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loaderProgress {
    0% { transform: translateX(-150%); }
    100% { transform: translateX(350%); }
}

@keyframes loaderDotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ═══ VARIANTES POR APP - Todas usan azul oscuro unificado ═══ */
.loader--crm .loader-spinner,
.loader--service .loader-spinner,
.loader--finance .loader-spinner,
.loader--report .loader-spinner,
.loader--estimator .loader-spinner,
.loader--costos .loader-spinner {
    border-top-color: #1e3a5f;
}

.loader--crm .loader-logo-container::before,
.loader--crm .loader-logo-container::after,
.loader--service .loader-logo-container::before,
.loader--service .loader-logo-container::after,
.loader--finance .loader-logo-container::before,
.loader--finance .loader-logo-container::after,
.loader--report .loader-logo-container::before,
.loader--report .loader-logo-container::after,
.loader--estimator .loader-logo-container::before,
.loader--estimator .loader-logo-container::after,
.loader--costos .loader-logo-container::before,
.loader--costos .loader-logo-container::after {
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.12) 0%, rgba(30, 64, 175, 0.04) 100%);
}

.loader--crm .loader-progress-bar,
.loader--service .loader-progress-bar,
.loader--finance .loader-progress-bar,
.loader--report .loader-progress-bar,
.loader--estimator .loader-progress-bar,
.loader--costos .loader-progress-bar {
    background: linear-gradient(90deg, #1e3a5f, #2d4a6f);
}

.loader--crm .loader-dots span,
.loader--service .loader-dots span,
.loader--finance .loader-dots span,
.loader--report .loader-dots span,
.loader--estimator .loader-dots span,
.loader--costos .loader-dots span {
    background: #1e3a5f;
}

/* ═══ FADE OUT DEL LOADER ═══ */
#app-loader.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* ─────────────────────────────────────────────────────────────────
   ANIMACIONES GENERALES
   ───────────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fade-in { animation: fadeIn var(--transition-slow) ease-out; }
.slide-up { animation: slideUp var(--transition-slow) ease-out; }
.slide-down { animation: slideDown var(--transition-slow) ease-out; }

/* ─────────────────────────────────────────────────────────────────
   UTILIDADES
   ───────────────────────────────────────────────────────────────── */
.hidden-screen { display: none !important; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────
   PROFILE IMAGE
   ───────────────────────────────────────────────────────────────── */
.profile-img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.profile-img:hover {
    transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────────────
   GRID DE APPS (Index) - RESPONSIVE
   ───────────────────────────────────────────────────────────────── */
.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 5px;
}

.app-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-2xl);
    padding: 15px 10px;
    text-align: center;
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    min-height: 120px;
    position: relative;
    overflow: hidden;
}

.app-btn:active {
    transform: scale(0.97);
    background-color: #f8fafc;
}

.app-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.app-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform var(--transition-slow);
}

.app-btn:hover .app-logo-img {
    transform: scale(1.1);
}

.app-btn h3 {
    font-size: 12px;
    line-height: 1.2;
}

.app-btn p {
    font-size: 10px;
}

/* Desktop Layout Container */
.desktop-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
}

/* Apps Section Header */
.apps-section-header {
    display: none;
}

/* Category Divider */
.app-category {
    grid-column: 1 / -1;
    padding: 12px 0 6px 0;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 4px;
    display: none; /* Oculto en móvil */
}

/* Mostrar categorías en tablet+ */
@media (min-width: 640px) {
    .app-category {
        display: block;
        font-size: 12px;
        padding: 16px 0 8px 0;
    }
}

/* ─────────────────────────────────────────────────────────────────
   CALENDARIO (Index - Agenda)
   ───────────────────────────────────────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    position: relative;
    cursor: pointer;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.calendar-day:hover {
    background-color: rgba(0, 122, 255, 0.05);
}

.calendar-day.active {
    background-color: var(--climex-primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.3);
}

.calendar-day.today {
    color: var(--climex-primary);
    font-weight: bold;
    background-color: rgba(0, 122, 255, 0.1);
}

.calendar-day.holiday {
    background: repeating-linear-gradient(
        45deg,
        #e5e7eb,
        #e5e7eb 5px,
        #f3f4f6 5px,
        #f3f4f6 10px
    );
    color: #9ca3af;
    font-style: italic;
}

.dot-indicator {
    width: 5px;
    height: 5px;
    border-radius: var(--radius-full);
    margin-top: 2px;
}

.dots-container {
    display: flex;
    gap: 2px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 80%;
}

/* ─────────────────────────────────────────────────────────────────
   NOTAS (Index)
   ───────────────────────────────────────────────────────────────── */
.note-item {
    border-left: 3px solid #ccc;
    padding-left: 10px;
    margin-bottom: 12px;
}

.note-date {
    color: var(--color-error);
    font-weight: bold;
    font-size: 11px;
}

.note-user {
    color: var(--text-primary);
    font-weight: 800;
    font-size: 13px;
}

.note-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.3;
}

/* ─────────────────────────────────────────────────────────────────
   PDF CONTAINER (Service, Report)
   ───────────────────────────────────────────────────────────────── */
.pdf-container {
    width: 210mm;
    box-sizing: border-box;
    background: white;
    margin: 0 auto;
    color: black;
    font-family: Arial, sans-serif;
    font-size: 11px;
    display: none;
    position: relative;
}

.pdf-page {
    width: 100%;
    height: 296mm;
    padding: 10mm 15mm 15mm 15mm;
    position: relative;
    background: white;
    overflow: hidden;
    page-break-after: always;
}

.pdf-page:last-child {
    page-break-after: auto;
}

/* PDF utilities */
.line-bottom {
    border-bottom: 1px solid #000;
    padding-bottom: 1px;
}

.box-check {
    border: 1px solid #000;
    width: 11px;
    height: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 3px;
    font-size: 9px;
    font-weight: bold;
}

.lined-paper {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 17px,
        #9ca3af 18px
    );
    background-size: 100% 18px;
    line-height: 18px;
    padding-top: 2px;
    background-color: white;
}

/* PDF Preview Overlay */
#pdf-preview-overlay {
    display: none;
}

#pdf-preview-overlay.active {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f1f5f9;
    z-index: 99999;
}

#report-content-wrapper {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#report-paper {
    background: white;
    width: 100%;
    max-width: 1100px;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

body.has-preview #app-root {
    display: none;
}

/* ─────────────────────────────────────────────────────────────────
   ACCESIBILIDAD
   ───────────────────────────────────────────────────────────────── */
/* Focus visible para navegación con teclado */
:focus-visible {
    outline: 2px solid var(--climex-primary);
    outline-offset: 2px;
}

/* Reducir movimiento si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE - TABLET Y DESKTOP
   ───────────────────────────────────────────────────────────────── */

/* Tablet Portrait (640px+) */
@media (min-width: 640px) {
    .app-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 10px;
    }
    
    .app-btn {
        min-height: 130px;
        padding: 20px 15px;
    }
    
    .app-logo-img {
        width: 52px;
        height: 52px;
    }
    
    .app-btn h3 {
        font-size: 13px;
    }
}

/* Tablet Landscape / Small Desktop (768px+) */
@media (min-width: 768px) {
    .desktop-container {
        max-width: 800px;
        margin: 0 auto;
        padding: 0 20px;
    }
    
    .app-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    .app-btn {
        min-height: 140px;
        border-radius: 20px;
    }
    
    .apps-section-header {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #e2e8f0;
    }
    
    .apps-section-header h2 {
        font-size: 28px;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .desktop-container {
        max-width: 900px;
        padding: 0 40px;
    }
    
    .app-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 24px;
    }
    
    .app-btn {
        min-height: 130px;
        padding: 20px 15px;
    }
    
    .app-logo-img {
        width: 52px;
        height: 52px;
        margin-bottom: 10px;
    }
    
    .app-btn h3 {
        font-size: 13px;
    }
    
    .app-btn p {
        font-size: 10px;
    }
    
    /* Header más grande en desktop */
    #main-container .ios-header {
        padding: 16px 40px;
    }
    
    /* Scroll content con más padding */
    #main-container .scroll-content {
        padding: 20px 40px;
    }
}

/* Large Desktop (1280px+) */
@media (min-width: 1280px) {
    .desktop-container {
        max-width: 1000px;
    }
    
    .app-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 24px;
    }
    
    .app-btn {
        min-height: 140px;
        padding: 22px 18px;
    }
    
    .app-logo-img {
        width: 54px;
        height: 54px;
    }
    
    .app-btn h3 {
        font-size: 13px;
    }
}

/* Extra Large Desktop (1536px+) */
@media (min-width: 1536px) {
    .desktop-container {
        max-width: 1100px;
    }
    
    .app-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 28px;
    }
    
    .app-btn {
        min-height: 145px;
    }
    
    .app-logo-img {
        width: 56px;
        height: 56px;
    }
}

/* ─────────────────────────────────────────────────────────────────
   PRINT STYLES
   ───────────────────────────────────────────────────────────────── */
@media print {
    .ios-nav,
    .ios-header,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        overflow: visible;
    }
    
    .scroll-content {
        overflow: visible;
        padding: 0;
    }
}
/* ─────────────────────────────────────────────────────────────────
   APP SECTIONS - Secciones organizadas del dashboard
   ───────────────────────────────────────────────────────────────── */

.app-section {
    width: 100%;
    margin-bottom: 24px;
}

.app-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.app-section-title i,
.app-section-title svg {
    color: #64748b;
}

.app-section-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Mobile adjustments for sections */
@media (max-width: 640px) {
    .app-section-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .app-section-title {
        font-size: 12px;
        margin-bottom: 12px;
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
    .app-section-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }
}

/* Large Desktop - 1920x1080 */
@media (min-width: 1280px) {
    .app-section {
        max-width: 900px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .app-section-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    .app-section-title {
        font-size: 13px;
    }
}

/* ─────────────────────────────────────────────────────────────────
   DESKTOP CONTAINER - Centrado para pantallas grandes
   ───────────────────────────────────────────────────────────────── */

@media (min-width: 1280px) {
    .desktop-container {
        max-width: 1000px;
        margin: 0 auto;
    }
    
    #dynamicAppGrid {
        max-width: 1000px;
        margin: 0 auto;
        display: block !important;
    }
}