@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- ESTILOS GLOBALES DEL SGI --- */
:root {
    --sgi-accent: #7f1d1d;
    --sgi-accent-hover: #991b1b;
    --sgi-accent-ui: #c80000;
    --sgi-surface-bg: #f1f5f9;
    --sgi-surface-from: #f1f5f9;
    --sgi-surface-to: #f1f5f9;
    --sgi-border-card: rgba(148, 163, 184, 0.28);
}
html {
    background-color: var(--sgi-surface-bg);
    min-height: 100%;
}
body { 
    font-family: 'Inter', sans-serif; 
    background-color: var(--sgi-surface-bg); 
    font-size: 13px;
}
/* Módulos iframe: fondo plano único que llena el viewport del iframe. */
body.sgi-module-page {
    background: var(--sgi-surface-bg) !important;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
}
.sgi-nav-badge {
    position: absolute;
    top: 50%;
    right: 0.65rem;
    transform: translateY(-50%);
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.3rem;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.125rem;
    text-align: center;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 9999px;
    box-shadow: none;
    letter-spacing: -0.02em;
}
.card { 
    background-color: white; 
    border-radius: 0.5rem; 
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
    border: 1px solid var(--sgi-border-card);
}
.btn-primary { 
    background-color: #c80000; 
    color: white; 
    transition: background-color 0.2s; 
}
.btn-primary:hover { 
    background-color: #a20000; 
}
.nav-link { 
    transition: all 0.2s; 
    border-left: 3px solid transparent; 
    font-size: 13px;
}
.nav-link.active { 
    border-left-color: var(--sgi-accent-ui); 
    background: linear-gradient(90deg, rgba(254, 226, 226, 0.85), rgba(255, 255, 255, 0.4)); 
    color: var(--sgi-accent); 
    font-weight: 600; 
}
.nav-link:not(.active):hover { 
    background-color: #f8fafc; 
}
.sgi-nav-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0.35rem 1rem 0.15rem;
    margin: 0;
}
.sgi-sidebar-brand img {
    filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.06));
}
.tab-btn, .tab-btn-reg {
    font-size: 13px;
    padding: 12px 20px;
}
.tab-btn.border-red-500, .tab-btn-reg.border-red-500 {
    border-color: #c80000;
}
.tab-btn.text-red-500, .tab-btn-reg.text-red-500 {
    color: #c80000;
}
input, select {
    font-size: 13px;
}
input:focus, select:focus {
    border-color: #c80000 !important;
    box-shadow: 0 0 0 2px rgba(200, 0, 0, 0.2) !important;
    outline: none;
}
.loader { 
    border: 4px solid #fee2e2; 
    border-top: 4px solid #c80000; 
    border-radius: 50%; 
    width: 24px; 
    height: 24px; 
    animation: spin 1s linear infinite; 
}
@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

/* --- TAMAÑOS DE TÍTULOS --- */
h2 { font-size: 24px; }
h3 { font-size: 16px; }

/* --- ESTILOS DE TABLAS --- */
th, td {
    padding: 12px 16px;
    font-size: 12px;
}

/* --- ESTILOS PARA V3 --- */
.danger-btn {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}
.danger-btn:hover {
    background-color: #fecaca;
    color: #991b1b;
}

/* --- ESTILOS PARA LA CALCULADORA (RESTAURADOS) --- */
.calc-section { margin-top: 1.5rem; padding: 1.5rem; background-color: white; border-radius: 6px; }
.calc-section h3 { font-size: 1rem; color: #34495e; margin-top: 0; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #ecf0f1; }
.calc-section label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: #555; font-size: 0.8rem; }
.calc-section input[type="date"], 
.calc-section input[type="number"], 
.calc-section select { 
    width: 100%; padding: 0.6rem; font-size: 0.8rem; margin-bottom: 1rem; 
    border-radius: 4px; border: 1px solid #ced4da; background-color: #fff; 
    transition: border-color 0.2s ease, box-shadow 0.2s ease; 
}
.calc-section .form-actions { margin-top: 1rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.calc-section button { padding: 0.6rem 1.2rem; font-size: 0.8rem; font-weight: 500; border: none; border-radius: 4px; cursor: pointer; color: #fff; transition: background-color 0.2s ease; flex-grow: 1; min-width: 110px; }
.calc-section .calc-btn-primary { background-color: #c80000; } 
.calc-section .calc-btn-primary:hover { background-color: #a20000; }
.calc-section .calc-btn-secondary { background-color: #6c757d; flex-grow: 0; } 
.calc-section .calc-btn-secondary:hover { background-color: #5a6268; }
.calc-section .feedback-message { padding: 0.75rem 1rem; margin-top: 1rem; border-radius: 4px; font-size: 0.8em; border: 1px solid transparent; display: none; }
.calc-section .feedback-message.success { background-color: #d1e7dd; border-color: #badbcc; color: #0f5132; }
.calc-section .feedback-message.error { background-color: #f8d7da; border-color: #f5c2c7; color: #842029; }
.calc-section .result-box { 
    white-space: pre-wrap; 
    font-family: monospace; 
    max-height: 350px; 
    overflow-y: auto; 
    background-color: #f8fafc; 
    padding: 1rem; 
    border: 1px solid #e9ecef; 
    border-radius: 4px; 
    font-size: 12px;
    color: #495057; 
    min-height: 50px; 
}
.calc-section .result-box:empty::before { content: "Aquí aparecerán los resultados..."; color: #999; font-style: italic; }
.calc-section .copy-btn-inline {
    background: none; border: none; color: #c80000; 
    font-size: 12px;
    font-weight: 600; cursor: pointer; padding: 0;
    transition: color 0.2s;
}
.calc-section .copy-btn-inline:hover { color: #a20000; }
.calc-section .copy-btn-inline.copied { color: #10b981; }
.calc-section .hidden-field { display: none; }

/* * NUEVOS ESTILOS PARA MEJORAS * */
.logo-spin {
    animation: logo-spin-animation 2s linear infinite;
}

@keyframes logo-spin-animation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#preloader {
    transition: opacity 0.5s ease-in-out;
}

/* --- ESTILOS PARA INHABILITAR VISTA MÓVIL (SOLO SGI) --- */
#mobile-notice {
    display: none; /* Oculto por defecto en escritorio */
}

/* Pestañas estilo Seguimientos (reutilizable en otros módulos) */
.tab-sgi-wrap {
    border-radius: 1rem;
    background: rgba(226, 232, 240, 0.65);
    padding: 0.35rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.tab-sgi {
    flex: 1 1 auto;
    min-width: min(100%, 7.5rem);
    border-radius: 0.75rem;
    padding: 0.75rem 0.85rem;
    font-size: 0.8125rem;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    border: none;
    cursor: pointer;
    background: transparent;
    color: #64748b;
    font-family: inherit;
}
.tab-sgi:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--sgi-accent);
}
.tab-sgi[aria-selected="true"] {
    background: #fff;
    color: var(--sgi-accent);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
/* Listas con altura acotada (menos scroll en página completa) */
.list-scroll-sgi {
    max-height: min(65vh, 560px);
    overflow-y: auto;
    scrollbar-gutter: stable;
}
@media (min-width: 1024px) {
    .list-scroll-sgi { max-height: min(70vh, 620px); }
}
/* Superficie del iframe principal en el shell */
.sgi-main-content-surface {
    background: var(--sgi-surface-bg);
    min-height: 0;
    overflow: hidden;
}
.sgi-shell-main-column {
    background: var(--sgi-surface-bg);
}
.page-content {
    background: var(--sgi-surface-bg);
    min-height: 100%;
}
.page-content iframe {
    display: block;
    background: var(--sgi-surface-bg);
    color-scheme: light;
}
html.sgi-main-page,
body.sgi-main-page {
    height: 100%;
}
body.sgi-main-page #app-container {
    height: 100vh;
    overflow: hidden;
}

/* Panel central de selección (Gestiones, Admin, Modificaciones — mismo criterio que Seguimientos) */
.sgi-selector-panel {
    background: #fff;
    border-radius: 0.5rem;
    border: 1px solid var(--sgi-border-card);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
    padding: 1.75rem 1.5rem;
    text-align: center;
}
.sgi-selector-panel .sgi-field-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
    justify-content: center;
}
@media (min-width: 640px) {
    .sgi-selector-panel .sgi-field-row {
        flex-direction: row;
        align-items: center;
    }
}
.sgi-input-select {
    border-radius: 0.375rem;
    border: 1px solid rgb(226, 232, 240);
    padding: 0.65rem 0.85rem;
    font-size: 0.8125rem;
    width: 100%;
    max-width: 100%;
    background: #fff;
    color: #1e293b;
    font-family: inherit;
}
.sgi-input-select:focus {
    outline: none;
    border-color: rgba(127, 29, 29, 0.45);
    box-shadow: 0 0 0 3px rgba(127, 29, 29, 0.1);
}

/* Título de módulo (iframes SGI) */
.sgi-module-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
    margin-bottom: 1.25rem;
}
@media (min-width: 768px) {
    .sgi-module-title { font-size: 1.875rem; }
}

@media (max-width: 767px) {
    /* Solo el panel completo está deshabilitado en móvil; login + avisos siguen visibles */
    .sgi-main-page #app-container {
        display: none !important;
    }

    body.sgi-mobile-companion #sgi-mobile-entry-wrap {
        display: none !important;
    }

    #sgi-mobile-entry-wrap {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        background-color: #f1f5f9;
    }

    /* Aviso inicial en franja superior; el formulario va debajo */
    .sgi-main-page #mobile-notice {
        display: block;
        flex-shrink: 0;
    }

    body.sgi-mobile-companion #mobile-post-login {
        display: flex !important;
    }
}

@media (min-width: 768px) {
    #mobile-post-login {
        display: none !important;
    }
}

