/* ============================================================
   El Método Xpeakers — Sistema Visual
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap');

/* ── Variables CSS ────────────────────────────────────────── */
:root {
    --bg:       #ffffff;
    --bg-soft:  #f8f8f8;
    --text:     #111111;
    --muted:    #666666;
    --border:   #e0e0e0;
    --card:     #ffffff;
    --accent:   #c40000;
    --accent-h: #a30000;
    --accent-l: #fdf0f0;
    --success:  #1a6b3a;
    --success-l:#edf7f2;
    --warning:  #8a5a00;
    --warning-l:#fef9ed;
    --info:     #1a4b7a;
    --info-l:   #eef4fb;
    --radius:   8px;
    --radius-sm:4px;
    --shadow:   0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
    --shadow-sm:0 1px 2px rgba(0,0,0,.06);
    --sidebar-w:260px;
    --transition: .18s ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 18px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Tipografía ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    letter-spacing: -.02em;
}

h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.1rem; font-family: 'DM Sans', sans-serif; font-weight: 600; }

p { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-h); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

strong { font-weight: 600; }
small  { font-size: .8rem; color: var(--muted); }

/* ── Layout Base ──────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    flex-shrink: 0;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 56px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 50;
}

.page-content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 960px;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar-logo {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
}

.sidebar-logo .brand {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    letter-spacing: -.01em;
}

.sidebar-logo .brand-sub {
    font-size: .68rem;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-top: .2rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-section {
    padding: .25rem .75rem;
    margin-bottom: .125rem;
}

.sidebar-section-title {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: .5rem .5rem .25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    color: var(--text);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-soft);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    background: var(--accent-l);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Módulos en sidebar con badges */
.nav-modulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .45rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .84rem;
    text-decoration: none;
    color: var(--text);
    transition: background var(--transition);
    gap: .4rem;
}

.nav-modulo:hover { background: var(--bg-soft); text-decoration: none; }
.nav-modulo.active { background: var(--accent-l); color: var(--accent); font-weight: 600; }
.nav-modulo.bloqueado { color: var(--muted); cursor: default; }
.nav-modulo.bloqueado:hover { background: transparent; }

.modulo-num {
    font-size: .7rem;
    font-weight: 700;
    color: var(--muted);
    min-width: 18px;
    text-align: center;
}

.modulo-titulo {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
    font-size: .8rem;
    color: var(--muted);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .5rem;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-l);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    color: var(--accent);
    flex-shrink: 0;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .15rem .45rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
}

.badge--bloqueado { background: #f0f0f0; color: var(--muted); }
.badge--activo    { background: var(--accent-l); color: var(--accent); }
.badge--completado{ background: var(--success-l); color: var(--success); }
.badge--pendiente { background: var(--warning-l); color: var(--warning); }
.badge--info      { background: var(--info-l); color: var(--info); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 1.25rem; }

.card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    letter-spacing: -.01em;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}

/* ── Botones ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled      { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; text-decoration: none; }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-soft); text-decoration: none; }

.btn-ghost   { background: transparent; color: var(--accent); border-color: transparent; }
.btn-ghost:hover { background: var(--accent-l); text-decoration: none; }

.btn-danger  { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; text-decoration: none; }

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }

/* ── Formularios ──────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text);
}

label.required::after {
    content: ' *';
    color: var(--accent);
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=url], input[type=tel],
input[type=date], select, textarea {
    width: 100%;
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: .9rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(196,0,0,.12);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}

.hint {
    font-size: .78rem;
    color: var(--muted);
    margin-top: .25rem;
}

.field-error {
    font-size: .78rem;
    color: var(--accent);
    margin-top: .25rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 400;
}

.checkbox-label input[type=checkbox] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-top: .15rem;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Alertas ──────────────────────────────────────────────── */
.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 1rem;
    border-left: 3px solid transparent;
}

.alert--success { background: var(--success-l); border-left-color: var(--success); color: var(--success); }
.alert--error   { background: var(--accent-l);  border-left-color: var(--accent);  color: var(--accent);  }
.alert--warning { background: var(--warning-l); border-left-color: var(--warning); color: var(--warning); }
.alert--info    { background: var(--info-l);    border-left-color: var(--info);    color: var(--info);    }

/* ── Tablas ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

th {
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: .5rem .75rem;
    border-bottom: 2px solid var(--border);
}

td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-soft); }

/* ── Progress bar ─────────────────────────────────────────── */
.progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .4s ease;
}

.progress-bar--success { background: var(--success); }

/* ── Pasos de módulo ──────────────────────────────────────── */
.steps {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.step {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .78rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
}

.step--done  { background: var(--success-l); border-color: var(--success); color: var(--success); }
.step--active{ background: var(--accent-l);  border-color: var(--accent);  color: var(--accent);  }

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ── Auth pages ───────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-soft);
    padding: 1.5rem;
}

.auth-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo .brand {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    display: block;
    letter-spacing: -.02em;
    line-height: 1.1;
}

.auth-logo .brand-accent {
    color: var(--accent);
}

.auth-logo small {
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* ── Loader / Autosave indicator ──────────────────────────── */
.autosave-indicator {
    font-size: .75rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: .3rem;
    min-height: 1.2em;
    transition: color var(--transition);
}

.autosave-indicator.saving { color: var(--info); }
.autosave-indicator.saved  { color: var(--success); }
.autosave-indicator.error  { color: var(--accent); }

/* ── Grid helpers ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Utilidades ───────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-sm { font-size: .85rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ── Responsive sidebar ───────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform var(--transition);
    }

    .sidebar.open { transform: translateX(0); }

    .page-content { padding: 1.25rem; }

    .topbar { padding: 0 1rem; }
}

/* ── Accesibilidad ────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.empty-state p { margin-top: .5rem; font-size: .9rem; }

/* ── Topbar elements ──────────────────────────────────────── */
.topbar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 700;
    flex: 1;
    letter-spacing: -.01em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* ── Separador ────────────────────────────────────────────── */
hr.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── Markdown body ────────────────────────────────────────── */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: .5rem;
}

.markdown-body p { margin-bottom: .75rem; }
.markdown-body ul,
.markdown-body ol { padding-left: 1.5rem; margin-bottom: .75rem; }
.markdown-body li { margin-bottom: .25rem; }
.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--muted);
    font-style: italic;
    margin: 1rem 0;
}
.markdown-body code {
    background: var(--bg-soft);
    padding: .1em .35em;
    border-radius: 3px;
    font-size: .88em;
    font-family: monospace;
}
.markdown-body pre {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: .75rem;
}
.markdown-body pre code { background: none; padding: 0; }
