/* ============================================================================
   Mapeo Estratégico de Iniciativas de Transformación Digital
   Sistema de diseño de la aplicación de captura
   ============================================================================ */

:root {
    /* Paleta */
    --brand-900: #0b1f3a;
    --brand-800: #10294c;
    --brand-700: #163a6b;
    --brand-600: #1d4e8f;
    --brand-500: #2563b0;
    --brand-400: #4f86cf;
    --brand-100: #e4eefb;
    --brand-50:  #f2f7fd;

    --accent-600: #0d9488;
    --accent-500: #14b8a6;
    --accent-100: #d5f2ee;

    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50:  #f8fafc;
    --white: #ffffff;

    --danger-600: #dc2626;
    --danger-50: #fef2f2;
    --warn-600: #d97706;
    --warn-50: #fffbeb;
    --ok-600: #16a34a;
    --ok-50: #f0fdf4;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
    --shadow: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
    --shadow-lg: 0 18px 40px rgba(15,23,42,.14);

    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;

    --header-h: 68px;
    --sidebar-w: 300px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--ink-900);
    background: var(--ink-50);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- Encabezado */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: linear-gradient(100deg, var(--brand-900), var(--brand-700) 60%, var(--brand-600));
    color: var(--white);
    box-shadow: var(--shadow);
}
.app-header .brand-mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    flex: none;
}
.app-header .brand-mark svg { width: 22px; height: 22px; }
.app-header .titles { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.app-header .titles .t1 { font-weight: 700; font-size: .95rem; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .titles .t2 { font-size: .74rem; color: #cdddf3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .spacer { flex: 1; }

.save-indicator {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .78rem; color: #d7e6f8;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.14);
    padding: 6px 12px; border-radius: 999px;
    white-space: nowrap;
}
.save-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-500); }
.save-indicator.saving .dot { background: var(--warn-600); animation: pulse 1s infinite; }
.save-indicator.error .dot { background: var(--danger-600); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* --------------------------------------------------------------- Layout */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - var(--header-h)); }

.sidebar {
    background: var(--white);
    border-right: 1px solid var(--ink-200);
    padding: 26px 18px;
    position: sticky;
    top: var(--header-h);
    align-self: start;
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}
.progress-wrap { margin-bottom: 22px; }
.progress-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-500); margin-bottom: 8px; font-weight: 600; }
.progress-bar { height: 8px; background: var(--ink-200); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-500), var(--accent-500)); border-radius: 999px; transition: width .4s ease; }
.progress-pct { font-size: .78rem; color: var(--ink-500); margin-top: 6px; }

.stepper { list-style: none; margin: 0; padding: 0; }
.stepper li {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 11px 12px; border-radius: var(--radius-sm);
    cursor: pointer; color: var(--ink-700);
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}
.stepper li:hover { background: var(--brand-50); }
.stepper li.active { background: var(--brand-100); color: var(--brand-800); }
.stepper li.active .step-num { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.stepper li.done .step-num { background: var(--accent-500); color: #fff; border-color: var(--accent-500); }
.step-num {
    flex: none; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; font-size: .8rem; font-weight: 700;
    background: var(--white); border: 1.5px solid var(--ink-300); color: var(--ink-500);
}
.step-num svg { width: 15px; height: 15px; }
.step-info { display: flex; flex-direction: column; min-width: 0; }
.step-info .s-title { font-weight: 600; font-size: .9rem; }
.step-info .s-sub { font-size: .74rem; color: var(--ink-500); }

.sidebar-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--ink-200); font-size: .72rem; color: var(--ink-400); }

/* ------------------------------------------------------------- Contenido */
.content { padding: 34px 40px 120px; max-width: 900px; }
.step-panel { display: none; animation: fade .3s ease; }
.step-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-head { margin-bottom: 22px; }
.step-eyebrow { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent-600); background: var(--accent-100); padding: 4px 10px; border-radius: 999px; margin-bottom: 12px; }
.step-head h1 { font-size: 1.65rem; margin: 0 0 8px; color: var(--brand-900); letter-spacing: -.3px; }
.step-head p.lead { color: var(--ink-500); margin: 0; font-size: .98rem; max-width: 66ch; }

.callout {
    display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
    background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--ink-700);
    font-size: .88rem; margin: 18px 0;
}
.callout .ic { flex: none; color: var(--brand-500); }
.callout.info { background: var(--brand-50); border-color: var(--brand-100); }
.callout.warn { background: var(--warn-50); border-color: #fde68a; }
.callout.warn .ic { color: var(--warn-600); }

/* ------------------------------------------------------------- Tarjetas */
.card {
    background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden;
}
.card > .card-head { padding: 16px 20px; border-bottom: 1px solid var(--ink-100); display: flex; align-items: center; gap: 10px; }
.card > .card-head h3 { margin: 0; font-size: 1rem; color: var(--brand-800); }
.card > .card-head .badge-sub { margin-left: auto; }
.card > .card-body { padding: 20px; }

.section-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--brand-600); margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 16px; background: var(--accent-500); border-radius: 2px; }

/* ------------------------------------------------------------- Formularios */
.field { margin-bottom: 18px; }
.field > label, .field-label { display: block; font-weight: 600; font-size: .88rem; color: var(--ink-900); margin-bottom: 6px; }
.field .hint { font-size: .78rem; color: var(--ink-500); margin: -2px 0 8px; }
.req { color: var(--danger-600); font-weight: 700; }
.optional { color: var(--ink-400); font-weight: 500; font-size: .78rem; }

.input, input[type=text], input[type=email], input[type=number], input[type=tel], input[type=month], input[type=date], select, textarea {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--ink-900);
    background: var(--white); border: 1.5px solid var(--ink-300); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
textarea { resize: vertical; min-height: 84px; }
.input.invalid, input.invalid, select.invalid, textarea.invalid { border-color: var(--danger-600); box-shadow: 0 0 0 3px var(--danger-50); }
.char-count { text-align: right; font-size: .72rem; color: var(--ink-400); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Opciones (radio / checkbox como tarjetas) */
.option-list { display: grid; gap: 10px; }
.option-list.cols-2 { grid-template-columns: 1fr 1fr; }
.option {
    display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px;
    border: 1.5px solid var(--ink-200); border-radius: var(--radius-sm); cursor: pointer;
    transition: border-color .15s, background .15s; background: var(--white);
}
.option:hover { border-color: var(--brand-400); background: var(--brand-50); }
.option.checked { border-color: var(--brand-500); background: var(--brand-50); }
.option input { margin-top: 2px; accent-color: var(--brand-600); width: 17px; height: 17px; flex: none; }
.option .opt-text { font-size: .89rem; }
.option .opt-text small { display: block; color: var(--ink-500); font-size: .78rem; }

/* Pills / chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.chip.brand { background: var(--brand-100); color: var(--brand-700); }
.chip.accent { background: var(--accent-100); color: var(--accent-600); }
.chip.gray { background: var(--ink-100); color: var(--ink-700); }
.chip.ok { background: var(--ok-50); color: var(--ok-600); }
.chip.warn { background: var(--warn-50); color: var(--warn-600); }
.badge-sub { font-size: .72rem; color: var(--ink-500); }

/* ------------------------------------------------------------- Iniciativas */
.eje-group { margin-bottom: 22px; }
.eje-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.eje-head .eje-name { font-weight: 700; color: var(--brand-800); font-size: .95rem; }
.eje-head .eje-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 999px; }
.eje-tag.central { background: var(--brand-100); color: var(--brand-700); }
.eje-tag.habilitador { background: var(--accent-100); color: var(--accent-600); }

.ini-option { border: 1.5px solid var(--ink-200); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; transition: border-color .15s, background .15s; background: var(--white); }
.ini-option.checked { border-color: var(--brand-500); background: var(--brand-50); box-shadow: var(--shadow-sm); }
.ini-option .ini-top { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.ini-option input[type=checkbox] { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand-600); flex: none; }
.ini-option .ini-name { font-weight: 600; font-size: .92rem; }
.ini-option .ini-code { font-size: .72rem; color: var(--brand-500); font-weight: 700; margin-right: 6px; }
.ini-option .ini-desc { font-size: .8rem; color: var(--ink-500); margin-top: 3px; }
.ini-relacion { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--ink-200); }
.ini-relacion .field-label { font-size: .8rem; }

/* ------------------------------------------------------------- Apoyos */
.ini-block { border: 1px solid var(--ink-200); border-radius: var(--radius); margin-bottom: 16px; background: var(--white); box-shadow: var(--shadow-sm); overflow: hidden; }
.ini-block > .ib-head { padding: 16px 18px; background: var(--brand-50); border-bottom: 1px solid var(--ink-100); }
.ini-block > .ib-head .ib-code { font-size: .72rem; color: var(--brand-500); font-weight: 700; }
.ini-block > .ib-head .ib-name { font-weight: 700; color: var(--brand-800); }
.ini-block > .ib-body { padding: 18px; }

.apoyo-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--ink-200); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--ink-50); }
.apoyo-row .a-name { font-weight: 600; font-size: .9rem; }
.apoyo-row .a-meta { font-size: .76rem; color: var(--ink-500); }
.apoyo-row .spacer { flex: 1; }

.ficha-editor { border: 1.5px solid var(--brand-200, var(--brand-100)); border-radius: var(--radius); padding: 20px; margin-top: 12px; background: var(--brand-50); }

/* Repetibles */
.repeat-item { border: 1px solid var(--ink-200); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 12px; background: var(--white); position: relative; }
.repeat-item .remove-x { position: absolute; top: 10px; right: 10px; }

/* ------------------------------------------------------------- Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; font: inherit; font-weight: 600; font-size: .9rem;
    border-radius: var(--radius-sm); border: 1.5px solid transparent; cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); text-decoration: none; }
.btn-accent { background: var(--accent-600); color: #fff; }
.btn-accent:hover { background: #0f766e; text-decoration: none; }
.btn-ghost { background: var(--white); color: var(--brand-700); border-color: var(--ink-300); }
.btn-ghost:hover { background: var(--brand-50); border-color: var(--brand-400); text-decoration: none; }
.btn-subtle { background: var(--ink-100); color: var(--ink-700); }
.btn-subtle:hover { background: var(--ink-200); text-decoration: none; }
.btn-danger-ghost { background: transparent; color: var(--danger-600); border-color: transparent; padding: 6px 10px; }
.btn-danger-ghost:hover { background: var(--danger-50); text-decoration: none; }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--ink-400); padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.icon-btn:hover { color: var(--danger-600); background: var(--danger-50); }
.icon-btn svg { width: 18px; height: 18px; }

/* Barra de navegación inferior */
.nav-bar {
    position: fixed; bottom: 0; left: var(--sidebar-w); right: 0;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 40px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    border-top: 1px solid var(--ink-200); z-index: 40;
}
.nav-bar .spacer { flex: 1; }
.nav-bar .ctx { font-size: .8rem; color: var(--ink-500); }

/* ------------------------------------------------------------- Resumen */
.summary-ini { border: 1px solid var(--ink-200); border-radius: var(--radius); margin-bottom: 12px; }
.summary-ini .si-head { padding: 12px 16px; background: var(--ink-50); font-weight: 600; color: var(--brand-800); display: flex; align-items: center; gap: 10px; }
.summary-ini .si-body { padding: 12px 16px; font-size: .86rem; }
.summary-line { display: flex; gap: 10px; padding: 4px 0; }
.summary-line .k { color: var(--ink-500); min-width: 180px; }
.summary-line .v { color: var(--ink-900); font-weight: 500; }

/* Pantalla de carga / bienvenida */
.loader { display: grid; place-items: center; min-height: 60vh; color: var(--ink-500); gap: 14px; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--ink-200); border-top-color: var(--brand-600); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero {
    border-radius: var(--radius-lg); padding: 30px 32px; margin-bottom: 26px;
    background: linear-gradient(120deg, var(--brand-900), var(--brand-700));
    color: #fff; box-shadow: var(--shadow);
}
.hero h2 { margin: 0 0 10px; font-size: 1.4rem; letter-spacing: -.2px; }
.hero p { margin: 0; color: #d7e6f8; font-size: .92rem; max-width: 72ch; }

/* Toast */
.toast-wrap { position: fixed; right: 20px; bottom: 84px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink-900); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .86rem; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }

.hidden { display: none !important; }

/* ------------------------------------------------------------- Responsive */
@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--ink-200); }
    .stepper { display: flex; overflow-x: auto; gap: 6px; }
    .stepper li { flex-direction: column; min-width: 120px; text-align: center; align-items: center; }
    .content { padding: 24px 18px 130px; }
    .nav-bar { left: 0; padding: 12px 18px; }
    .grid-2, .grid-3, .option-list.cols-2 { grid-template-columns: 1fr; }
}
