/* ============================================================
   MecsaDocs — Design System (SiteFlow style sincronizado con CMS/Proyectos)
   ============================================================ */
:root {
    --brand:           #013483;
    --brand-dark:      #012a6a;
    --brand-darker:    #012050;
    --brand-light:     rgba(1, 52, 131, 0.10);
    --brand-xlight:    rgba(1, 52, 131, 0.06);

    --sidebar-bg:      #ffffff;
    --sidebar-border:  #f0f0f0;
    --sidebar-hover:   #f8f9fa;
    --sidebar-active:  rgba(1, 52, 131, 0.06);
    --sidebar-text:    #6b7280;
    --sidebar-text-h:  #111827;
    --sidebar-text-a:  #013483;
    --sidebar-w:       240px;

    --topbar-bg:       #ffffff;
    --topbar-border:   #f0f0f0;
    --topbar-h:        60px;

    --surface-0:       #ffffff;
    --surface-1:       #f8f9fa;
    --surface-2:       #f0f1f3;
    --border:          #eaeaea;
    --border-light:    #e2e8f0;

    --text:            #111827;
    --text-2:          #6b7280;
    --text-muted:      #9ca3af;

    --green:           #22c55e;
    --red:             #ef4444;
    --yellow:          #f59e0b;
    --blue:            #3b82f6;
    --purple:          #8b5cf6;
    --teal:            #14b8a6;
    --orange:          #f97316;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow:    0 4px 12px rgba(15, 23, 42, .06);
    --shadow-md: 0 10px 25px rgba(15, 23, 42, .08);

    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--surface-1);
    color: var(--text);
    font-family: var(--font-stack);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

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

/* ====== App shell ====== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}
.app.sidebar-collapsed { grid-template-columns: 64px 1fr; }

/* ====== Sidebar ====== */
.sidebar {
    grid-area: sidebar;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 30;
}
.sidebar-workspace {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-workspace .ws-logo {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 16px;
}
.sidebar-workspace .ws-info { flex: 1; min-width: 0; }
.sidebar-workspace .ws-name { font-weight: 700; color: var(--text); font-size: 14px; line-height: 1.1; }
.sidebar-workspace .ws-badge {
    display: inline-block; margin-top: 2px;
    font-size: 9.5px; font-weight: 700; letter-spacing: .5px;
    color: var(--brand); background: var(--brand-light);
    padding: 2px 6px; border-radius: 4px;
}
.sidebar-scroll { padding: 8px 8px 24px; }
.sidebar-section { margin-top: 10px; }
.sidebar-group-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
    color: #b0b7c3; padding: 8px 12px 4px; font-weight: 700;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin: 1px 0;
    border-radius: 8px;
    color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
    cursor: pointer; text-decoration: none;
    position: relative;
}
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-h); }
.nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-a);
    font-weight: 600;
}
.nav-link.active::before {
    content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-link .nav-icon { width: 18px; text-align: center; color: inherit; font-size: 14px; }
.nav-link .nav-badge {
    margin-left: auto; background: var(--surface-2); color: var(--text-2);
    font-size: 10.5px; padding: 1px 7px; border-radius: 999px; font-weight: 700;
}

.sidebar-sep { border: 0; border-top: 1px solid var(--sidebar-border); margin: 10px 0; }

/* ====== Topbar ====== */
.topbar {
    grid-area: topbar;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex; align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: sticky; top: 0; z-index: 20;
}
.topbar-toggle {
    background: transparent; border: 0; cursor: pointer;
    width: 36px; height: 36px; border-radius: 8px;
    color: var(--text-2);
}
.topbar-toggle:hover { background: var(--surface-2); color: var(--text); }
.topbar-breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-2);
    overflow: hidden; white-space: nowrap;
}
.topbar-breadcrumb .bc-link { color: var(--text-2); }
.topbar-breadcrumb .bc-link:hover { color: var(--brand); }
.topbar-breadcrumb .bc-sep { font-size: 9px; color: var(--text-muted); }
.topbar-breadcrumb .bc-current { color: var(--text); font-weight: 600; }

.topbar-search {
    flex: 1; max-width: 460px;
    margin: 0 auto;
    position: relative;
}
.topbar-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-1);
    font-size: 13px;
    transition: border .15s, background .15s;
}
.topbar-search input:focus {
    outline: none; border-color: var(--brand); background: #fff;
    box-shadow: 0 0 0 3px var(--brand-light);
}
.topbar-search i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 13px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-icon-btn {
    background: transparent; border: 0; cursor: pointer;
    width: 36px; height: 36px; border-radius: 8px;
    color: var(--text-2);
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar-avatar {
    width: 34px; height: 34px; border-radius: 999px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; cursor: pointer; user-select: none;
}

/* ====== Main ====== */
.main {
    grid-area: main;
    padding: 22px 28px 60px;
    overflow-x: hidden;
}

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 18px; gap: 14px; flex-wrap: wrap;
}
.page-title {
    font-size: 22px; font-weight: 700; color: var(--text); margin: 0;
}
.page-subtitle { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }

/* ====== Cards ====== */
.card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}
.card-hover { transition: box-shadow .2s, transform .2s, border .2s; }
.card-hover:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--brand-light);
    transform: translateY(-2px);
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ====== Project card ====== */
.project-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex; flex-direction: column; gap: 10px;
    text-decoration: none; color: inherit;
    position: relative; overflow: hidden;
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.project-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: var(--card-color, var(--brand));
}
.project-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--card-color, var(--brand-light));
    transform: translateY(-2px);
    color: inherit;
}
.project-card .pc-head { display: flex; align-items: center; gap: 12px; }
.project-card .pc-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--card-color, var(--brand));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.project-card .pc-title { font-weight: 700; color: var(--text); font-size: 15px; line-height: 1.2; }
.project-card .pc-meta { color: var(--text-muted); font-size: 11.5px; }
.project-card .pc-desc { color: var(--text-2); font-size: 13px; line-height: 1.5; }
.project-card .pc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.project-card .tag {
    background: var(--surface-1); color: var(--text-2);
    border: 1px solid var(--border);
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
.project-card .pc-footer {
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text-muted); font-size: 11.5px;
    border-top: 1px solid var(--border);
    padding-top: 10px; margin-top: auto;
}

/* ====== Status pills ====== */
.pill {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 999px; border: 1px solid;
}
.pill-activo         { color: var(--green);  background: rgba(34,197,94,.10);  border-color: rgba(34,197,94,.25); }
.pill-en-desarrollo  { color: var(--yellow); background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.25); }
.pill-mantenimiento  { color: var(--blue);   background: rgba(59,130,246,.10); border-color: rgba(59,130,246,.25); }
.pill-archivado      { color: var(--text-2); background: var(--surface-2);     border-color: var(--border); }
.pill-borrador       { color: var(--orange); background: rgba(249,115,22,.10); border-color: rgba(249,115,22,.25); }
.pill-publicado      { color: var(--green);  background: rgba(34,197,94,.10);  border-color: rgba(34,197,94,.25); }

/* ====== Section / page list ====== */
.section-list { display: grid; gap: 10px; }
.section-row {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none; color: inherit;
    transition: border .2s, box-shadow .2s, transform .15s;
}
.section-row:hover {
    border-color: var(--brand-light);
    box-shadow: var(--shadow-sm);
    transform: translateX(2px);
    color: inherit;
}
.section-row .sr-icon {
    width: 38px; height: 38px; border-radius: 9px;
    background: var(--brand-light); color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
}
.section-row .sr-info { flex: 1; min-width: 0; }
.section-row .sr-title { font-weight: 600; color: var(--text); font-size: 14px; }
.section-row .sr-desc  { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.section-row .sr-meta  { color: var(--text-muted); font-size: 11.5px; display: flex; gap: 10px; }

/* ====== Buttons ====== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer; transition: background .15s, border .15s, color .15s, transform .1s;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-secondary { background: var(--surface-0); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-1); border-color: var(--border-light); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #c0392b; color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ====== Forms ====== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 13.5px; font-family: inherit; background: #fff;
    transition: border .15s, box-shadow .15s;
}
.form-control:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}
.form-control:disabled { background: var(--surface-2); color: var(--text-muted); }
textarea.form-control { min-height: 90px; resize: vertical; }

/* ====== Table ====== */
.table {
    width: 100%; background: var(--surface-0);
    border-collapse: collapse; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
    font-size: 13px;
}
.table thead th {
    background: var(--surface-1); color: var(--text-2);
    font-weight: 600; padding: 11px 14px;
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}
.table tbody td {
    padding: 11px 14px; border-bottom: 1px solid var(--border);
    color: var(--text);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-1); }

/* ====== Empty state ====== */
.empty-state {
    background: var(--surface-0);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 44px 24px;
    text-align: center;
    color: var(--text-2);
}
.empty-state .empty-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--brand-light); color: var(--brand);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}
.empty-state h3 { color: var(--text); font-size: 16px; margin: 0 0 4px; }
.empty-state p  { margin: 0 0 14px; font-size: 13.5px; }

/* ====== Stats grid (dashboard) ====== */
.stats-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 22px;
}
.stat {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex; align-items: center; gap: 12px;
}
.stat .stat-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--brand-light); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.stat .stat-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.stat .stat-label { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ====== Content / WYSIWYG render ====== */
.doc-content {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 44px;
    line-height: 1.7;
    color: var(--text);
    font-size: 14.5px;
    max-width: 900px;
}
.doc-content h1, .doc-content h2, .doc-content h3, .doc-content h4 {
    color: var(--text); font-weight: 700; line-height: 1.25;
    margin: 1.6em 0 .6em;
}
.doc-content h1 { font-size: 1.9em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.doc-content h2 { font-size: 1.5em; }
.doc-content h3 { font-size: 1.22em; }
.doc-content h4 { font-size: 1.05em; }
.doc-content p { margin: .8em 0; }
.doc-content ul, .doc-content ol { padding-left: 1.6em; margin: .8em 0; }
.doc-content li { margin: .25em 0; }
.doc-content code {
    background: var(--surface-2); color: var(--brand-darker);
    padding: 2px 6px; border-radius: 4px; font-size: .88em;
    font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
}
.doc-content pre {
    background: #0f172a; color: #e2e8f0;
    padding: 16px 18px; border-radius: 10px; overflow-x: auto;
    font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: 13px; line-height: 1.55;
}
.doc-content pre code { background: transparent; color: inherit; padding: 0; }
.doc-content table {
    width: 100%; border-collapse: collapse; margin: 1em 0;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.doc-content th { background: var(--surface-1); padding: 9px 12px; text-align: left; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); }
.doc-content td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.doc-content blockquote {
    border-left: 3px solid var(--brand); background: var(--brand-xlight);
    padding: 10px 16px; margin: 1em 0; border-radius: 0 8px 8px 0;
    color: var(--text-2);
}
.doc-content img { max-width: 100%; border-radius: 8px; }
.doc-content a { color: var(--brand); text-decoration: underline; text-decoration-color: var(--brand-light); text-underline-offset: 3px; }

/* ====== Tag chips ====== */
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--surface-1); color: var(--text-2);
    border: 1px solid var(--border);
    font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
}

/* ====== Login screen ====== */
.login-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at top left, rgba(1,52,131,.10), transparent 50%) , var(--surface-1);
    padding: 24px;
}
.login-card {
    background: #fff; border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 36px 36px 28px;
    width: 100%; max-width: 380px;
    border: 1px solid var(--border);
}
.login-card .login-logo {
    width: 56px; height: 56px; border-radius: 14px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 22px; margin: 0 auto 16px;
}
.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 22px; color: var(--text); }
.login-card .subtitle { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 22px; }

/* ====== Alerts ====== */
.alert {
    border-radius: 8px; padding: 10px 14px;
    font-size: 13.5px; margin-bottom: 14px;
    border: 1px solid;
}
.alert-error   { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.alert-success { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.alert-info    { color: #1e40af; background: #dbeafe; border-color: #bfdbfe; }

/* ====== Responsive ====== */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .sidebar { position: fixed; left: 0; top: 0; height: 100vh; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-md); }
    .app.sidebar-open .sidebar { transform: translateX(0); }
    .main { padding: 18px 16px 60px; }
    .doc-content { padding: 22px 18px; }
}
