/* ============================================================
   CONTENTHUB · ARTIC SYSTEM  ·  v3
   Dirección: control-room frío, claro y de alto contraste.
   Tipografía técnica con fallbacks de sistema (se ve bien aunque
   las fuentes web no carguen).
   ============================================================ */

:root {
    /* Riel / sidebar (navy profundo) */
    --rail:        #13212f;
    --rail-2:      #1b2e40;
    --rail-line:   rgba(255,255,255,.10);
    --rail-text:   rgba(231,238,244,.66);

    /* Lienzo y superficies (frío y claro) */
    --canvas:      #eef2f6;
    --surface:     #ffffff;
    --surface-2:   #f5f8fa;
    --field:       #ffffff;

    /* Tinta */
    --ink:         #14222f;
    --ink-2:       #56697a;
    --ink-3:       #8a9aa8;

    /* Líneas */
    --line:        #e1e8ee;
    --line-2:      #ccd6df;

    /* Acento (azul acero frío) */
    --accent:      #2c6ca3;
    --accent-deep: #235a89;
    --accent-soft: #e8f0f7;
    --accent-ink:  #ffffff;

    /* Estado */
    --danger:      #b04646;
    --danger-soft: #fbecec;

    /* Tipografía */
    --display: 'Space Grotesk', 'Archivo', system-ui, -apple-system, Segoe UI, sans-serif;
    --ui:      'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono:    'JetBrains Mono', 'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --radius:    10px;
    --radius-sm: 7px;
    --shadow:    0 1px 2px rgba(20,34,47,.05), 0 14px 30px -20px rgba(20,34,47,.28);
    --shadow-sm: 0 1px 2px rgba(20,34,47,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
    font-family: var(--ui);
    background: var(--canvas);
    color: var(--ink);
    font-size: 13.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ============================================================
   WRAPPER
   ============================================================ */
.app-wrapper { display: flex; width: 100vw; height: 100vh; }

/* ============================================================
   SIDEBAR / RIEL
   ============================================================ */
.sidebar {
    width: 252px;
    flex-shrink: 0;
    background: var(--rail);
    border-right: 1px solid var(--rail-line);
    display: flex;
    flex-direction: column;
    padding: 28px 20px 20px;
}

.logo { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--rail-line); }

.logo h1 {
    font-family: var(--display);
    font-weight: 700;
    font-size: 21px;
    letter-spacing: .14em;
    color: #fff;
    text-transform: uppercase;
}

.tagline {
    display: inline-block;
    margin-top: 9px;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: .12em;
    color: var(--accent);
    text-transform: uppercase;
}

/* NAV */
.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 3px; counter-reset: nav; padding-top: 4px; }

.nav-item {
    counter-increment: nav;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--rail-text);
    cursor: pointer;
    font-family: var(--ui);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .01em;
    text-align: left;
    transition: background .16s ease, color .16s ease;
}

.nav-item::before {
    content: counter(nav, decimal-leading-zero);
    font-family: var(--mono);
    font-size: 10px;
    color: rgba(255,255,255,.3);
    width: 18px;
}

.nav-item .icon { display: none; }

.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }

.nav-item.active {
    background: rgba(255,255,255,.06);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item.active::before { color: var(--accent); }

/* FOOTER */
.sidebar-footer { border-top: 1px solid var(--rail-line); padding-top: 16px; }

.sidebar-footer::before {
    content: 'SYS · ONLINE';
    display: block;
    font-family: var(--mono);
    font-size: 8.5px;
    letter-spacing: .22em;
    color: rgba(255,255,255,.3);
    margin-bottom: 12px;
    padding-left: 2px;
}

.settings-btn {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--rail-line);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.03);
    color: rgba(255,255,255,.78);
    cursor: pointer;
    font-family: var(--ui);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .02em;
    transition: background .16s ease, color .16s ease;
}
.settings-btn:hover { background: rgba(255,255,255,.09); color: #fff; }

/* ============================================================
   MAIN
   ============================================================ */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--canvas); }

/* PAGE HEADER */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 30px 34px 20px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    background: var(--canvas);
}

.page-header h2 {
    font-family: var(--display);
    font-weight: 700;
    font-size: 27px;
    letter-spacing: -.01em;
    color: var(--ink);
}

.page-header h2::before {
    content: attr(data-eyebrow);
    display: block;
    font-family: var(--mono);
    font-weight: 500;
    font-size: 10px;
    letter-spacing: .14em;
    color: var(--accent);
    margin-bottom: 9px;
}

.header-controls { display: flex; gap: 10px; align-items: center; padding-bottom: 3px; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-wrapper { flex: 1; overflow-y: auto; }

.tab-content { display: none; height: 100%; flex-direction: column; overflow: hidden; }
.tab-content.active { display: flex; }
.tab-content > .page-header { flex-shrink: 0; }
.tab-content > *:not(.page-header) { flex: 1; overflow-y: auto; padding: 24px 34px 40px; }

/* ============================================================
   STATS
   ============================================================ */
.stats-container { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; counter-reset: stat; }

.stat-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 18px 16px;
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease;
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-box::before {
    counter-increment: stat;
    content: counter(stat, decimal-leading-zero);
    position: absolute;
    top: 16px; right: 18px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-3);
}

.stat-value {
    font-family: var(--display);
    font-weight: 700;
    font-size: 34px;
    line-height: 1;
    color: var(--ink);
    margin-bottom: 9px;
}

.stat-label {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-2);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.card h3,
.generator-panel h3,
.ideas-panel h3,
.events-sidebar h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-2);
    padding-bottom: 13px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--line);
}
.card h3::before,
.generator-panel h3::before,
.ideas-panel h3::before,
.events-sidebar h3::before {
    content: '';
    width: 7px; height: 7px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.list-content { max-height: 320px; overflow-y: auto; }

.list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.list-item-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }

.empty {
    text-align: center;
    color: var(--ink-3);
    padding: 30px 14px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .04em;
}

/* ============================================================
   GENERATOR
   ============================================================ */
.generator-layout { display: grid; grid-template-columns: 370px 1fr; gap: 16px; align-items: start; }

.generator-panel, .ideas-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.ideas-panel { min-height: 62vh; }

/* FORMS */
.form-group { margin-bottom: 17px; }
.form-group label {
    display: block;
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: 7px;
    color: var(--ink-2);
}

.control-input, textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--field);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--ui);
    font-size: 13px;
    transition: border-color .16s ease, box-shadow .16s ease;
}
.control-input::placeholder, textarea::placeholder { color: var(--ink-3); }
.control-input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 86px; }

select.control-input {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
        linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
    background-position: calc(100% - 17px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 9px; }
.radio, .checkbox { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--ink); }
.radio input, .checkbox input { cursor: pointer; accent-color: var(--accent); width: 15px; height: 15px; }

.api-selection { display: flex; gap: 7px; }
.api-btn {
    flex: 1;
    padding: 9px 4px;
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    cursor: pointer;
    font-family: var(--ui);
    font-size: 11.5px;
    font-weight: 600;
    transition: all .16s ease;
}
.api-btn:hover { border-color: var(--accent); color: var(--accent); }
.api-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

small { display: block; margin-top: 6px; font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--ui);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .01em;
    cursor: pointer;
    width: 100%;
    transition: all .16s ease;
    border: 1px solid transparent;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px -8px rgba(44,108,163,.7); }
.btn-primary:hover { background: var(--accent-deep); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); width: auto; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; margin-top: 8px; }
.btn-danger:hover { background: #f6dede; }

.header-controls .btn-secondary, .page-header .btn-secondary { margin: 0; }
.header-controls .control-input { width: auto; }

/* ============================================================
   ERROR BOX (IA)
   ============================================================ */
.error-box {
    border: 1px solid #eccaca;
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    padding: 16px;
    color: var(--danger);
}
.error-box strong { display: block; font-size: 13px; margin-bottom: 6px; }
.error-box span { display: block; font-family: var(--mono); font-size: 11px; line-height: 1.5; word-break: break-word; color: #8a3a3a; }
.error-box small { color: #a06a6a; margin-top: 10px; }

/* ============================================================
   BODEGA
   ============================================================ */
.vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }

.vault-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.vault-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }

.vault-card-header {
    background: var(--accent-soft);
    color: var(--accent-deep);
    padding: 10px 14px;
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}
.vault-card-body { padding: 15px 14px; }
.vault-card-title { font-size: 13.5px; font-weight: 700; color: var(--ink); margin-bottom: 7px; }
.vault-card-content { font-size: 11.5px; color: var(--ink-2); margin-bottom: 13px; line-height: 1.5; }
.vault-card-stats {
    display: flex; justify-content: space-between;
    padding-top: 11px; border-top: 1px solid var(--line);
    font-family: var(--mono); font-size: 9.5px; letter-spacing: .04em;
    color: var(--ink-3); text-transform: uppercase;
}

/* ============================================================
   CALENDARIO
   ============================================================ */
.calendar-container { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.calendar-view, .events-sidebar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    min-height: 52vh;
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   ANALYTICS
   ============================================================ */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.stats-content { min-height: 120px; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.stats-content p {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12.5px; color: var(--ink-2);
    padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.stats-content p:last-child { border-bottom: none; }
.stats-content b { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--ink); }

/* ============================================================
   IDEAS
   ============================================================ */
.ideas-grid { display: flex; flex-direction: column; gap: 12px; }
.idea-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 17px;
}
.idea-card-title { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 7px; }
.idea-card-content { font-size: 12.5px; color: var(--ink-2); margin-bottom: 13px; line-height: 1.55; }
.idea-card-meta { display: flex; gap: 6px; margin-bottom: 13px; flex-wrap: wrap; }
.idea-card-meta span {
    font-family: var(--mono); font-size: 9.5px; letter-spacing: .03em;
    color: var(--accent-deep); background: var(--accent-soft);
    border-radius: 4px; padding: 3px 8px;
}
.idea-card-actions { display: flex; gap: 7px; }
.idea-btn {
    flex: 1; padding: 8px 6px;
    font-family: var(--ui); font-size: 11px; font-weight: 600;
    border: 1px solid var(--line-2); border-radius: 6px;
    background: var(--surface); color: var(--ink-2); cursor: pointer;
    transition: all .16s ease;
}
.idea-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(19,33,47,.55); backdrop-filter: blur(3px);
    align-items: center; justify-content: center; padding: 20px;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px;
    max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto;
    position: relative; box-shadow: 0 30px 60px -24px rgba(19,33,47,.5);
}
.modal-content h3 {
    font-family: var(--display); font-weight: 700;
    font-size: 19px; letter-spacing: -.01em; color: var(--ink);
    margin-bottom: 22px; padding-right: 28px;
}
.modal-close {
    position: absolute; right: 18px; top: 16px;
    background: none; border: none; color: var(--ink-3);
    cursor: pointer; font-size: 24px; line-height: 1; transition: color .16s ease;
}
.modal-close:hover { color: var(--ink); }
.form-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; }
.form-actions .btn-primary, .form-actions .btn-secondary, .form-actions .btn-danger { margin: 0; width: 100%; }

/* ============================================================
   ACCESIBILIDAD
   ============================================================ */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    .stats-container { grid-template-columns: repeat(2, 1fr); }
    .content-grid { grid-template-columns: 1fr; }
    .generator-layout { grid-template-columns: 1fr; }
    .calendar-container { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .sidebar { width: 62px; padding: 22px 8px; }
    .logo { text-align: center; }
    .logo h1 { font-size: 0; }
    .logo h1::first-letter { font-size: 18px; }
    .tagline { display: none; }
    .nav-item { justify-content: center; font-size: 0; gap: 0; padding: 11px 6px; }
    .nav-item::before { width: auto; font-size: 12px; }
    .settings-btn { font-size: 0; padding: 11px 6px; }
    .settings-btn::before { content: '⚙'; font-size: 15px; }
    .sidebar-footer::before { display: none; }
    .page-header { padding: 20px; }
    .page-header h2 { font-size: 22px; }
    .tab-content > *:not(.page-header) { padding: 18px; }
    .stats-container { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 28px; }
}
