/* =======================================================
   Components — Sistema CMS
   ======================================================= */

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--ff);
    font-size: var(--fs-base);
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-700); }
h1, h2, h3, h4, h5, h6 { margin: 0; color: var(--c-text); font-weight: var(--fw-semibold); }
p { margin: 0 0 var(--sp-3); }
img { max-width: 100%; display: block; }

/* ---- Shell layout ---- */
.app-shell { display: flex; min-height: 100vh; }
.app-main  { flex: 1; display: flex; flex-direction: column; margin-left: var(--sidebar-w); min-width: 0; }
.app-content { flex: 1; padding: var(--sp-6); }

/* ---- Sidebar (flat dark, no gradient) ---- */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--sidebar-w);
    background: var(--c-sb-bg);
    color: var(--c-sb-fg);
    display: flex; flex-direction: column;
    z-index: 100;
}
.sidebar-brand {
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--c-sb-border);
    display: flex; align-items: center; gap: var(--sp-3);
    color: #fff;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-md);
}
.brand-mark {
    width: 36px; height: 36px;
    background: var(--c-primary);
    border-radius: var(--r);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 18px;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3); }
.nav-section-label {
    padding: var(--sp-4) var(--sp-3) var(--sp-1);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--c-text-light);
    font-weight: var(--fw-semibold);
    opacity: .6;
}
.nav-link {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-sm);
    color: var(--c-sb-fg);
    font-size: var(--fs-base);
    transition: var(--transition-base);
    margin-bottom: 2px;
}
.nav-link:hover {
    background: rgba(255,255,255,.04);
    color: #fff;
}
.nav-link.active {
    background: var(--c-sb-active);
    color: var(--c-sb-fg-active);
    font-weight: var(--fw-medium);
}
.nav-link .icon { font-size: 18px; width: 22px; text-align: center; opacity: .85; }

/* ---- Collapsible nav groups (estilo Argon/Tabler) ---- */
.nav-group-toggle {
    width: 100%;
    background: transparent;
    border: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-sm);
    color: var(--c-sb-fg);
    font-size: var(--fs-base);
    transition: var(--transition-base);
    margin-bottom: 2px;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-group-toggle .label { flex: 1; }
.nav-group-toggle .chevron {
    font-size: 11px; opacity: .6;
    transition: transform .2s ease;
}
.nav-group.expanded .nav-group-toggle { color: #fff; }
.nav-group.expanded .nav-group-toggle .chevron { transform: rotate(180deg); opacity: 1; }

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    padding-left: calc(var(--sp-3) + 11px);
    position: relative;
}
.nav-submenu::before {
    content: '';
    position: absolute;
    left: calc(var(--sp-3) + 11px);
    top: 0; bottom: 8px;
    width: 1px;
    background: rgba(255,255,255,.08);
}
.nav-group.expanded .nav-submenu { max-height: 400px; }

.nav-sublink {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 7px var(--sp-3) 7px var(--sp-4);
    border-radius: var(--r-sm);
    color: var(--c-sb-fg);
    font-size: var(--fs-sm);
    transition: var(--transition-base);
    position: relative;
    margin-left: var(--sp-2);
    opacity: .85;
}
.nav-sublink::before {
    content: '';
    position: absolute;
    left: 0;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    transition: var(--transition-base);
}
.nav-sublink:hover { color: #fff; opacity: 1; }
.nav-sublink:hover::before { background: rgba(255,255,255,.5); }
.nav-sublink.active {
    background: var(--c-sb-active);
    color: var(--c-sb-fg-active);
    font-weight: var(--fw-medium);
    opacity: 1;
}
.nav-sublink.active::before { background: var(--c-primary); }

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-h);
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 0 var(--sp-6);
    display: flex; align-items: center; gap: var(--sp-4);
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { flex: 1; }
.topbar-title h1 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: 0; }
.breadcrumb { display: flex; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--c-text-muted); margin-bottom: 2px; }
.breadcrumb a { color: var(--c-text-muted); }
.breadcrumb .sep::before { content: '/'; margin: 0 4px; color: var(--c-text-light); }

.search-box {
    background: var(--c-surface-alt);
    border: 1px solid var(--c-border);
    border-radius: var(--r);
    padding: 6px 12px;
    display: flex; align-items: center; gap: 8px;
    width: 280px;
    max-width: 100%;
}
.search-box input {
    border: none; outline: none; background: transparent;
    flex: 1; font-size: var(--fs-sm); color: var(--c-text);
}
.search-box .icon { color: var(--c-text-muted); }

.icon-btn {
    width: 38px; height: 38px;
    border-radius: var(--r);
    background: transparent; border: none;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-text-muted); cursor: pointer;
    transition: var(--transition-base);
    position: relative;
}
.icon-btn:hover { background: var(--c-surface-alt); color: var(--c-text); }
.icon-btn .dot {
    position: absolute; top: 8px; right: 10px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--c-danger);
    border: 2px solid var(--c-surface);
}

.user-chip {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: 4px 12px 4px 4px;
    border-radius: var(--r-full);
    background: var(--c-surface-alt);
    cursor: pointer;
}
.user-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-chip-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); }

/* ---- Page header ---- */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--sp-5);
    flex-wrap: wrap; gap: var(--sp-4);
}
.page-header h2 { font-size: var(--fs-xl); margin: 0 0 2px; }
.page-header .subtitle { color: var(--c-text-muted); font-size: var(--fs-sm); }

/* ---- Cards ---- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border-soft);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xs);
    overflow: hidden;
}
.card-body { padding: var(--sp-5); }
.card-header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--c-border-soft);
    display: flex; justify-content: space-between; align-items: center;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-md);
}
.card-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--c-border-soft);
    background: var(--c-surface-alt);
}

/* ---- Stat tiles (sin gradient; iconos en solid color blocks) ---- */
.stat-tile {
    background: var(--c-surface);
    border: 1px solid var(--c-border-soft);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--sh-xs);
    position: relative;
    overflow: hidden;
}
.stat-tile-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: var(--sp-3);
}
.stat-tile .label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: var(--sp-1);
}
.stat-tile .value {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    line-height: 1.1;
    color: var(--c-text);
}
.stat-tile .delta {
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
    margin-top: var(--sp-2);
}
.stat-tile .delta .up   { color: var(--c-success); font-weight: var(--fw-semibold); }
.stat-tile .delta .down { color: var(--c-danger);  font-weight: var(--fw-semibold); }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--r);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
    flex-shrink: 0;
}
.stat-icon.primary { background: var(--c-primary); }
.stat-icon.info    { background: var(--c-info); }
.stat-icon.success { background: var(--c-success); }
.stat-icon.warning { background: var(--c-warning); }
.stat-icon.danger  { background: var(--c-danger); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: 9px 16px;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    border: 1px solid transparent;
    background: var(--c-surface);
    color: var(--c-text);
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
}
.btn:hover { opacity: .92; }
.btn-primary    { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-600); color: #fff; }
.btn-outline    { background: transparent; border-color: var(--c-border); color: var(--c-text); }
.btn-outline:hover { background: var(--c-surface-alt); }
.btn-ghost      { background: transparent; color: var(--c-text-muted); }
.btn-ghost:hover { background: var(--c-surface-alt); color: var(--c-text); }
.btn-danger     { background: var(--c-danger); color: #fff; }
.btn-success    { background: var(--c-success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.btn-lg { padding: 12px 24px; font-size: var(--fs-md); }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--c-text);
    margin-bottom: var(--sp-2);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: var(--fs-sm);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--c-surface);
    color: var(--c-text);
    transition: var(--transition-base);
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-50);
}
.form-control::placeholder { color: var(--c-text-light); }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-help { font-size: var(--fs-xs); color: var(--c-text-muted); margin-top: var(--sp-1); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #d1d5db;
    border-radius: 20px;
    transition: var(--transition-base);
}
.switch .slider::before {
    content: ''; position: absolute;
    left: 2px; top: 2px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition-base);
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--c-primary); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ---- Badges ---- */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    border-radius: var(--r-full);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-success { background: var(--c-success-soft); color: #166534; }
.badge-warning { background: var(--c-warning-soft); color: #92400e; }
.badge-danger  { background: var(--c-danger-soft);  color: #991b1b; }
.badge-info    { background: var(--c-info-soft);    color: #1e40af; }
.badge-muted   { background: var(--c-surface-alt);  color: var(--c-text-muted); }
.badge-primary { background: var(--c-primary-50);   color: var(--c-primary-700); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-sm);
}
.table thead th {
    background: var(--c-surface-alt);
    color: var(--c-text-muted);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .4px;
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
.table tbody td {
    padding: var(--sp-4);
    border-bottom: 1px solid var(--c-border-soft);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--c-surface-alt); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Avatar ---- */
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; }
.avatar-lg { width: 56px; height: 56px; }
.avatar-xl { width: 80px; height: 80px; }
.avatar-stack { display: inline-flex; }
.avatar-stack > * { border: 2px solid var(--c-surface); margin-left: -8px; }
.avatar-stack > :first-child { margin-left: 0; }

/* ---- Progress bar ---- */
.progress {
    height: 6px;
    background: var(--c-border-soft);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--c-primary);
    border-radius: var(--r-full);
}

/* ---- Tabs ---- */
.tabs {
    display: inline-flex;
    background: var(--c-surface-alt);
    padding: 4px;
    border-radius: var(--r);
    border: 1px solid var(--c-border-soft);
}
.tab {
    padding: 8px 16px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--c-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
}
.tab.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-xs); }

/* ---- Hero banner (no gradient, use image + overlay) ---- */
.hero {
    position: relative;
    height: 260px;
    background-size: cover;
    background-position: center;
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-sm);
}
.hero::before {
    content: '';
    position: absolute; inset: 0;
    background: rgba(30, 33, 54, .45);
}

/* ---- Flex/Grid utilities ---- */
.grid { display: grid; gap: var(--sp-4); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }
.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.text-end { text-align: right; }
.fw-semibold { font-weight: var(--fw-semibold); }

/* ---- Responsive ---- */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-2-1, .grid-1-2, .grid-2 { grid-template-columns: 1fr; }
    .search-box { display: none; }
}
@media (max-width: 575px) {
    .grid-4 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .app-content { padding: var(--sp-4); }
}

/* ---- Auth layout (login/register) ---- */
.auth-layout {
    min-height: 100vh;
    background: var(--c-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
}
.auth-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1100px; width: 100%;
    background: var(--c-surface);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--sh-lg);
    min-height: 620px;
}
.auth-illustration {
    background: #1e2136 center/cover;
    position: relative;
    display: flex; align-items: flex-end;
    padding: var(--sp-8);
    color: #fff;
    overflow: hidden;
}
.auth-illustration::before {
    content: ''; position: absolute; inset: 0;
    background: rgba(30, 33, 54, .55);
    z-index: 1;
}
.auth-illustration > * { position: relative; z-index: 2; }
.auth-quote { max-width: 360px; }
.auth-quote h3 { color: #fff; font-size: var(--fs-xl); margin-bottom: var(--sp-3); }
.auth-quote p { color: rgba(255,255,255,.8); font-size: var(--fs-sm); }
.auth-form-side {
    padding: var(--sp-10) var(--sp-8);
    display: flex; flex-direction: column; justify-content: center;
}
.auth-form-side .brand {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin-bottom: var(--sp-8);
    display: flex; align-items: center; gap: var(--sp-3);
}
.divider {
    display: flex; align-items: center; gap: var(--sp-3);
    color: var(--c-text-light); font-size: var(--fs-xs);
    margin: var(--sp-5) 0;
}
.divider::before, .divider::after {
    content: ''; flex: 1; height: 1px; background: var(--c-border-soft);
}
.social-btn {
    width: 100%;
    padding: 11px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--c-text);
    cursor: pointer;
    transition: var(--transition-base);
}
.social-btn:hover { background: var(--c-surface-alt); }

@media (max-width: 767px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-illustration { display: none; }
    .auth-form-side { padding: var(--sp-6); }
}
