/* =================================================================
   JFS-COMMON.CSS — Estilos compartidos Sistema de Gestión CT v2
   Header, dock flotante, botones, status messages, modal genérico.
   Variables de tema (claro/oscuro) base.
   Cada módulo puede sobreescribir y añadir variables específicas.
   ================================================================= */

/* === VARIABLES DE TEMA (base — los módulos pueden extender) === */
:root {
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --text-main: #2d3748;
    --text-sec: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --input-bg: #ffffff;
    --input-readonly: #f7fafc;
    --header-bg: linear-gradient(135deg, #2c3e50 0%, #3d5a6d 50%, #4a6e83 100%);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.06);
    --dock-bg: rgba(255, 255, 255, 0.95);
    --dock-item-hover: rgba(0,0,0,0.05);
}

body.dark-mode {
    --bg-body: #1a202c;
    --bg-card: #2d3748;
    --text-main: #f7fafc;
    --text-sec: #a0aec0;
    --text-muted: #718096;
    --border-color: #4a5568;
    --input-bg: #4a5568;
    --input-readonly: #2c313d;
    --header-bg: linear-gradient(135deg, #171923 0%, #2d3748 100%);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.3);
    --dock-bg: rgba(26, 32, 44, 0.95);
    --dock-item-hover: rgba(255,255,255,0.1);
}

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

/* === HEADER GLOBAL === */
.header-global {
    background: var(--header-bg);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: fixed; top: 0; left: 0; width: 100%; z-index: 1000; height: 70px;
    display: flex; align-items: center; justify-content: space-between;
}
.header-global h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; }

/* Indicador de causa activa (header) */
.header-rit-badge {
    background: rgba(255,255,255,0.18);
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.25);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.header-rit-badge.empty { opacity: 0.6; }

/* === Botones del header === */
.btn-theme {
    background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3);
    color: white; padding: 0.4rem 0.8rem; border-radius: 8px; cursor: pointer;
    font-size: 1.1rem; line-height: 1; transition: all 0.2s;
}
.btn-theme:hover { background: rgba(255,255,255,0.3); transform: scale(1.05); }

.btn-manual {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white; text-decoration: none; padding: 0.4rem 1rem;
    border-radius: 8px; font-weight: 600; font-size: 0.9rem;
    border: 1px solid rgba(255,255,255,0.2);
    display: inline-flex; align-items: center; gap: 0.5rem; transition: all 0.2s;
}
.btn-manual:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

.btn-logout {
    background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4);
    color: white; padding: 0.4rem 1rem; border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: 0.9rem; transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.3); }

/* === Status Messages (Toasts) === */
.status-message {
    position: fixed; top: 90px; right: 20px;
    padding: 1rem 1.5rem; border-radius: 12px;
    font-weight: 500; z-index: 2000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    font-size: 0.95rem;
}
.status-success { background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%); color: #22543d; border-left: 4px solid #38a169; }
.status-info    { background: linear-gradient(135deg, #bee3f8 0%, #90cdf4 100%); color: #2c5282; border-left: 4px solid #3182ce; }
.status-warning { background: linear-gradient(135deg, #fefcbf 0%, #faf089 100%); color: #744210; border-left: 4px solid #d69e2e; }
.status-error   { background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%); color: #742a2a; border-left: 4px solid #e53e3e; }

/* === DOCK FLOTANTE === */
.dock-container {
    position: fixed; background: var(--dock-bg); backdrop-filter: blur(12px);
    border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    display: flex; gap: 12px; z-index: 3000;
    border: 1px solid rgba(255,255,255,0.6);
    transition: width 0.3s, height 0.3s, padding 0.3s;
    cursor: grab; padding: 8px 14px; align-items: center;
}
body.dark-mode .dock-container { border-color: rgba(255,255,255,0.1); }
.dock-container:active { cursor: grabbing; }
.dock-vertical { flex-direction: column; width: auto; padding: 14px 8px; }
.dock-handle { color: #cbd5e0; font-size: 1.4rem; cursor: grab; padding: 0 5px; user-select: none; display: flex; align-items: center; justify-content: center; }
.dock-vertical .dock-handle { transform: rotate(90deg); margin-bottom: 8px; }
.dock-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #4a5568; transition: all 0.2s; padding: 6px 10px; border-radius: 10px; }
body.dark-mode .dock-item { color: #a0aec0; }
.dock-item:hover { background: rgba(0,0,0,0.05); transform: translateY(-2px); color: #2d3748; }
body.dark-mode .dock-item:hover { background: rgba(255,255,255,0.1); color: white; }
.dock-icon { font-size: 1.4rem; margin-bottom: 2px; line-height: 1; }
.dock-label { font-size: 0.75rem; font-weight: 600; margin-top: 2px; }
.dock-separator { width: 1px; height: 24px; background: #e2e8f0; margin: 0 4px; }
body.dark-mode .dock-separator { background: rgba(255,255,255,0.12); }
.dock-vertical .dock-separator { width: 24px; height: 1px; margin: 4px 0; }
/* Active state (inyectado también desde jfs-common.js para asegurar especificidad) */
.dock-item.active { background: rgba(0,0,0,0.08); color: #2d3748; }
body.dark-mode .dock-item.active { background: rgba(255,255,255,0.15); color: #f7fafc; }

/* === BOTONES GENÉRICOS === */
.btn {
    padding: 0.4rem 0.8rem; border: none; border-radius: 8px;
    font-weight: 500; cursor: pointer; transition: all 0.3s ease;
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-size: 0.9rem; justify-content: center; text-decoration: none; height: auto;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #38a169 0%, #48bb78 100%); color: white; }
.btn-blue    { background: linear-gradient(135deg, #3182ce 0%, #4299e1 100%); color: white; }
.btn-purple  { background: linear-gradient(135deg, #805ad5 0%, #9f7aea 100%); color: white; }
.btn-orange  { background: linear-gradient(135deg, #dd6b20 0%, #ed8936 100%); color: white; }
.btn-reset   { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }
.btn-reset:hover { background: #fed7d7; }
body.dark-mode .btn-reset { background: #742a2a; color: #fed7d7; border-color: #9b2c2c; }

/* === WIDGET DE INDICADORES (UTM / UF / IMR) === */
.jfs-indic-bar { display: flex; gap: 0.4rem; align-items: stretch; flex-wrap: wrap; }
.jfs-indic-chip {
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 10px; padding: 0.3rem 0.65rem; cursor: pointer;
    transition: all 0.15s; color: var(--text-main); font: inherit; line-height: 1.1;
}
.jfs-indic-chip:hover { border-color: #3182ce; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.jfs-indic-ico { font-size: 1rem; }
.jfs-indic-txt { display: flex; flex-direction: column; align-items: flex-start; font-size: 0.82rem; }
.jfs-indic-txt b { font-weight: 700; }
.jfs-indic-txt small { font-size: 0.62rem; color: var(--text-muted); }
/* Versión completa (dashboard): misma altura que los botones .btn (una sola línea) */
.jfs-indic-full .jfs-indic-chip { padding: 0.4rem 0.8rem; border-radius: 8px; }
.jfs-indic-full .jfs-indic-ico { font-size: 1rem; }
.jfs-indic-full .jfs-indic-txt { font-size: 0.82rem; flex-direction: row; align-items: baseline; gap: 0.35rem; }
.jfs-indic-full .jfs-indic-txt small { font-size: 0.68rem; }

/* Popover de calculadora */
#jfs-indic-pop {
    position: fixed; z-index: 4000;
    background: var(--bg-card); color: var(--text-main);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.22); padding: 0.9rem 1rem;
    font-size: 0.85rem;
}
.jfs-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.7rem; font-weight: 700; gap: 0.5rem; }
.jfs-pop-head small { font-weight: 400; color: var(--text-muted); font-size: 0.72rem; }
.jfs-pop-edit { background: none; border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; padding: 0.15rem 0.4rem; font-size: 0.85rem; color: var(--text-sec); flex-shrink: 0; }
.jfs-pop-edit:hover { background: var(--dock-item-hover); border-color: #3182ce; }
.jfs-pop-row { display: grid; grid-template-columns: auto 1fr auto auto 1fr; gap: 0.4rem; align-items: center; }
.jfs-pop-row label { font-size: 0.7rem; color: var(--text-sec); font-weight: 600; }
.jfs-pop-row input {
    width: 100%; padding: 0.45rem 0.5rem; border: 2px solid var(--border-color);
    border-radius: 7px; background: var(--input-bg); color: var(--text-main);
    font-size: 0.9rem; font-family: inherit; text-align: right; min-width: 0;
}
.jfs-pop-row input:focus { outline: none; border-color: #3182ce; }
.jfs-pop-eq { color: #3182ce; font-weight: 700; text-align: center; }
.jfs-pop-hint { font-size: 0.68rem; color: var(--text-muted); margin: 0.45rem 0 0; }
/* IMR */
.jfs-pop-presun { background: var(--input-readonly); border-radius: 8px; padding: 0.5rem 0.7rem; margin-bottom: 0.7rem; }
.jfs-presun-item { display: flex; justify-content: space-between; align-items: center; padding: 0.2rem 0; }
.jfs-presun-item + .jfs-presun-item { border-top: 1px dashed var(--border-color); }
.jfs-presun-item span { font-size: 0.8rem; }
.jfs-presun-item small { color: var(--text-muted); font-size: 0.68rem; }
.jfs-presun-item b { color: #2b6cb0; font-size: 0.95rem; }
body.dark-mode .jfs-presun-item b { color: #90cdf4; }
.jfs-pop-row-imr { grid-template-columns: auto 1fr auto auto 1fr; }
.jfs-pop-custom { display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.4rem; align-items: center; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border-color); }
.jfs-pop-custom label { font-size: 0.7rem; color: var(--text-sec); font-weight: 600; }
.jfs-pop-custom input { width: 100%; padding: 0.4rem 0.5rem; border: 2px solid var(--border-color); border-radius: 7px; background: var(--input-bg); color: var(--text-main); font-size: 0.9rem; text-align: right; min-width: 0; }
.jfs-pop-custom input:focus { outline: none; border-color: #3182ce; }
.jfs-pop-custom b { color: #2b6cb0; }
body.dark-mode .jfs-pop-custom b { color: #90cdf4; }

/* En el header, la franja de indicadores se oculta en pantallas chicas (se mantiene sutil) */
@media (max-width: 980px) { #jfs-indic-header { display: none !important; } }

@media (max-width: 600px) {
    .jfs-indic-txt small { display: none; }
    .jfs-pop-row, .jfs-pop-row-imr { grid-template-columns: auto 1fr; }
    .jfs-pop-custom { grid-template-columns: auto 1fr; }
    .jfs-pop-eq { display: none; }
}
