/* Tipografía del sistema: Se ve bien y no requiere internet */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* === VARIABLES Y BASE === */
:root {
    --brand-primary: #2c3e50;
    --brand-primary-hover: #1a252f;
    --brand-secondary: #64748b;
    --bg-body: #f4f6f8;
    --bg-card: #ffffff;
    --text-main: #334155;
    --border-color: #e2e8f0;
}

body { 
    background-color: var(--bg-body); 
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* === TARJETAS (CARDS) === */
.card { 
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); 
    border-radius: 10px;
    background-color: var(--bg-card);
}
.card-header { 
    background-color: transparent !important; 
    color: var(--brand-primary) !important; 
    border-bottom: 1px solid var(--border-color); 
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-radius: 10px 10px 0 0 !important;
}

/* === LOGIN === */
.login-card { max-width: 400px; margin: 80px auto; }

/* === BOTONES === */
.btn { 
    border-radius: 6px; 
    font-weight: 500; 
    transition: all 0.2s ease;
}
.btn-primary, .btn-dark { 
    background-color: var(--brand-primary) !important; 
    border-color: var(--brand-primary) !important; 
    color: #fff !important;
}
.btn-primary:hover, .btn-dark:hover { 
    background-color: var(--brand-primary-hover) !important; 
    border-color: var(--brand-primary-hover) !important;
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2);
}

/* === FORMULARIOS === */
.form-control, .form-select { 
    border-radius: 6px;
    border: 1px solid #cbd5e1; 
    box-shadow: none !important;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}
.form-control:focus, .form-select:focus { 
    border-color: var(--brand-primary); 
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1) !important;
}
label { color: var(--brand-secondary); margin-bottom: 0.25rem; }

/* === NAVEGACIÓN (TABS) === */
.nav-pills { gap: 8px; }
.nav-pills .nav-link { 
    color: var(--brand-secondary); 
    border-radius: 8px; 
    font-weight: 500;
    padding: 0.6rem 1rem;
    border: 1px solid transparent;
}
.nav-pills .nav-link:hover { background-color: #e2e8f0; color: var(--brand-primary); }
.nav-pills .nav-link.active { 
    background-color: var(--brand-primary) !important; 
    color: #ffffff !important;
    box-shadow: 0 4px 6px rgba(44, 62, 80, 0.15);
}

.nav-tabs { border-bottom: 2px solid var(--border-color); gap: 15px; }
.nav-tabs .nav-link { border: none; color: var(--brand-secondary); padding: 0.75rem 0.5rem; font-weight: 500; }
.nav-tabs .nav-link:hover { border: none; color: var(--brand-primary); }
.nav-tabs .nav-link.active { 
    border: none; 
    color: var(--brand-primary); 
    font-weight: 600; 
    border-bottom: 3px solid var(--brand-primary); 
    background: transparent;
}

/* === MODALES === */
.modal-content { 
    border: none; 
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.modal-header { 
    background-color: transparent !important; 
    color: var(--brand-primary) !important; 
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    padding: 1.25rem 1.5rem;
}
.modal-body { padding: 1.5rem; }

/* === TABLAS === */
.table { color: var(--text-main); font-size: 0.9rem; }
.table-dark { background-color: var(--brand-primary); color: white; }
.table-dark th { background-color: var(--brand-primary); border-color: #3e566d; font-weight: 600; letter-spacing: 0.5px; }
.table-hover tbody tr:hover { background-color: #f8fafc; }

/* === UTILIDADES EXTRAS === */
.badge { font-weight: 500; padding: 0.4em 0.65em; border-radius: 6px; }
.item-subcarga { font-size: 0.85em; color: var(--brand-secondary); display: block; margin-top: 2px; }
.cursor-pointer { cursor: pointer; }
.is-completed { text-decoration: line-through; color: #10b981; opacity: 0.6; }

.progress { border-radius: 8px; background-color: #e2e8f0; }
.progress-bar { background-color: #10b981 !important; }

/* === PIZARRA DE CALENDARIO === */
.custom-scrollbar::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9; 
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}
.timeline-row:hover { background-color: #f8fafc; }
.timeline-bar:hover { filter: brightness(1.1); transform: scaleY(1.05); }

/* === NUEVO ENTORNO ADAPTATIVO Y SIDEBAR (INTEGRACIÓN) === */
.top-navbar {
    height: 65px;
    position: sticky;
    top: 0;
    z-index: 1050;
    background-color: #ffffff;
}

.sidebar {
    background-color: var(--bg-body) !important;
    border-right: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    /* 1. Ajustamos el sidebar para que sea un bloque fijo, sin scroll propio */
    .sidebar {
        /* Eliminamos 'position: sticky' y 'top' porque el contenedor flex ya controla la altura */
        height: calc(100vh - 65px); 
        overflow-y: hidden; /* Esto asegura que el sidebar NO tenga barra de scroll */
        flex-shrink: 0;     /* Evita que el sidebar se encoja */
    }

    /* 2. Aseguramos que el main ocupe el resto del espacio y controle el scroll */
    main {
        height: calc(100vh - 65px); /* Altura fija igual que el sidebar */
        overflow-y: auto;           /* Activa la barra de scroll solo aquí */
    }
}

.btn-sidebar {
    border: none;
    background: transparent;
    color: var(--text-main);
    padding: 0.65rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.btn-sidebar:hover {
    background: var(--border-color);
    color: var(--brand-primary);
}

.btn-sidebar.active {
    background-color: var(--brand-primary) !important;
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: inset 4px 0 0 0 #3498db;
}

.tracking-wide { letter-spacing: 0.06em; }

#vistaMobileHome .btn {
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#vistaMobileHome .btn:active { transform: scale(0.98); }

@media (max-width: 767.98px) {
    main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    .card-body { padding: 1.25rem 1rem; }
}

/* === BLOQUEO DE ORIENTACIÓN (MOBILE) === */
#orientation-overlay {
    display: none;
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh;
    background-color: var(--brand-primary);
    color: white;
    z-index: 99999;
    text-align: center;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
/* Se activa la cortina solo si el celular mide menos de 900px y lo ponen en horizontal */
@media screen and (max-width: 900px) and (orientation: landscape) {
    #orientation-overlay {
        display: flex !important;
    }
    /* Ocultamos el resto de la app para que no se desordene el layout de fondo */
    #pantallaApp, #pantallaLogin {
        display: none !important;
    }
}