/* ==========================================================================
   EcoGarden — hoja de estilos única (public/css/app.css)
   Reglas: sin estilos inline ni bloques <style> en las vistas.
   Tipografía: exactamente 5 tamaños (--t-1 … --t-5). Reutiliza antes de crear.
   Estilo: marco oscuro + panel claro redondeado + acentos lima y verde marca.

   Índice
   1. Fuente              8. Tarjetas destacadas  15. Alertas y avisos
   2. Variables           9. Listas en filas      16. Login / público
   3. Reset              10. Tablas               17. Utilidades
   4. Tipografía         11. Formularios          18. Responsive
   5. Layout privado     12. Badges y etiquetas
   6. Sidebar            13. Botones
   7. Topbar y paneles   14. Iconos
   ========================================================================== */

/* 1. Fuente (servida desde /fonts, sin llamadas externas) ------------------ */
@font-face {
    font-family: "Outfit";
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url("../fonts/outfit.woff2") format("woff2");
}

/* 2. Variables ------------------------------------------------------------- */
:root {
    /* Marco oscuro (sidebar, columna lateral, login) */
    --dark: #1b201f;
    --dark-2: #252b2a;
    --dark-line: #353d3b;
    --dark-text: #e7ebe9;
    --dark-muted: #8d9895;

    /* Panel claro */
    --panel: #e9ecea;
    --surface: #f6f7f6;
    --line: #d2d8d5;
    --text: #1b201f;
    --muted: #7b8682;

    /* Marca y acentos */
    --brand: #008855;        /* verde del logo */
    --brand-dark: #006b43;
    --brand-soft: #d6eee2;
    --lima: #cdee6a;         /* acento destacado (como el lima de la referencia) */
    --lima-dark: #b6d94f;
    --pizarra: #c9d5d3;      /* gris verdoso para tarjetas secundarias */

    /* Estados */
    --danger: #c0392b;
    --danger-soft: #f8e1de;
    --warning: #9a6a00;
    --warning-soft: #f6ecc9;

    /* Tipografía: 5 tamaños, no agregar más */
    --t-1: 40px;  /* cifras grandes */
    --t-2: 22px;  /* título de página */
    --t-3: 16px;  /* títulos de sección y tarjeta */
    --t-4: 14px;  /* texto base */
    --t-5: 12px;  /* etiquetas, ayudas, metadatos */

    /* Forma */
    --radius-l: 18px;
    --radius: 10px;
    --radius-s: 8px;
    --gap: 22px;
}

/* 3. Reset ----------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--dark);
    color: var(--text);
    font-family: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: var(--t-4);
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

h1,
h2,
h3,
p,
ul {
    margin: 0;
}

img {
    display: block;
    max-width: 100%;
}

/* 4. Tipografía ------------------------------------------------------------ */
h1 {
    font-size: var(--t-2);
    font-weight: 500;
    line-height: 1.2;
}

h2,
h3 {
    font-size: var(--t-3);
    font-weight: 500;
    line-height: 1.3;
}

strong {
    font-weight: 600;
}

.muted,
.help {
    color: var(--muted);
    font-size: var(--t-5);
}

.title-soft {
    color: var(--brand);
}

.cifra {
    font-size: var(--t-1);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1;
}

.prose {
    display: grid;
    gap: 12px;
}

.prose h1,
.prose h2 {
    margin-top: 12px;
    font-size: var(--t-3);
}

.prose ul,
.prose ol {
    padding-left: 22px;
}

.prose code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--panel);
    font-size: var(--t-5);
}

/* 5. Layout privado: sidebar | panel claro | (columna oscura opcional) ----- */
.app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    min-height: 100vh;
}

.app-shell.has-aside {
    grid-template-columns: 220px minmax(0, 1fr) 320px;
}

.workspace {
    min-width: 0;
    margin: 14px 0;
    padding: 30px 32px;
    border-radius: var(--radius-l);
    background: var(--panel);
}

.app-shell:not(.has-aside) .workspace {
    margin-right: 14px;
}

.content {
    display: grid;
    gap: var(--gap);
}

.aside {
    display: grid;
    align-content: start;
    gap: var(--gap);
    padding: 30px 22px;
    color: var(--dark-text);
}

.aside .muted {
    color: var(--dark-muted);
}

/* 6. Sidebar --------------------------------------------------------------- */
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 28px 18px 22px;
    color: var(--dark-muted);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 22px;
    border-bottom: 1px solid var(--dark-line);
    color: var(--dark-text);
    font-size: var(--t-3);
    font-weight: 500;
}

.brand img {
    width: 30px;
    height: auto;
}

.nav {
    display: grid;
    gap: 2px;
}

.nav-title {
    margin: 18px 10px 6px;
    padding-top: 18px;
    border-top: 1px solid var(--dark-line);
    color: var(--dark-muted);
    font-size: var(--t-5);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-s);
    color: var(--dark-muted);
}

.nav-link:hover {
    color: var(--dark-text);
}

.nav-link.is-active {
    color: var(--lima);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 0 8px;
    color: var(--dark-text);
}

.sidebar-user .stack {
    flex: 1;
    gap: 0;
    min-width: 0;
}

.sidebar-user .muted {
    overflow: hidden;
    color: var(--dark-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--lima);
    color: var(--dark);
    font-size: var(--t-5);
    font-weight: 600;
}

/* 7. Topbar y paneles ------------------------------------------------------ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: var(--gap);
}

.panel {
    display: grid;
    gap: 14px;
}

.panel-box {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.link-more {
    color: var(--text);
    font-size: var(--t-5);
}

.link-more:hover {
    color: var(--brand);
}

.aside .link-more {
    color: var(--dark-text);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

/* 8. Tarjetas destacadas --------------------------------------------------- */
.card {
    display: grid;
    align-content: space-between;
    gap: 18px;
    min-height: 150px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.card-top,
.card-foot {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.card-foot {
    align-items: center;
}

.card-lima {
    border-color: var(--lima);
    background: var(--lima);
}

.card-lima .muted,
.card-pizarra .muted {
    color: #4f5a57;
}

.card-pizarra {
    border-color: var(--pizarra);
    background: var(--pizarra);
}

.card-dark {
    border-color: var(--dark-line);
    background: var(--dark-2);
    color: var(--dark-text);
}

.card-compact {
    min-height: 0;
}

/* 9. Listas en filas (como “Recent invoices”) ------------------------------ */
.list {
    display: grid;
    gap: 10px;
    padding: 0;
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.list-item.is-featured {
    border-color: var(--pizarra);
    background: var(--pizarra);
}

.list-dark .list-item {
    border-color: var(--dark-line);
    background: var(--dark-2);
    color: var(--dark-text);
}

/* 10. Tablas --------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    min-width: 640px;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table th {
    padding: 0 16px 2px;
    color: var(--muted);
    font-size: var(--t-5);
    font-weight: 400;
    text-align: left;
}

.table td {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    vertical-align: middle;
}

.table td:first-child {
    border-left: 1px solid var(--line);
    border-radius: var(--radius) 0 0 var(--radius);
}

.table td:last-child {
    border-right: 1px solid var(--line);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.pagination {
    display: flex;
    gap: 8px;
    padding: 0;
    list-style: none;
}

.page-item .page-link,
.page-item.disabled span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: var(--t-5);
}

.page-item.disabled span {
    color: var(--muted);
}

/* 11. Formularios ---------------------------------------------------------- */
.form {
    display: grid;
    gap: 18px;
}

.form-narrow {
    max-width: 760px;
}

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

.field {
    display: grid;
    gap: 6px;
}

.field label {
    color: var(--muted);
    font-size: var(--t-5);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: #ffffff;
    color: var(--text);
}

.field textarea {
    min-height: 90px;
    padding: 10px 14px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(0, 136, 85, 0.15);
}

.field input[readonly] {
    background: var(--panel);
    color: var(--muted);
}

.field-error {
    color: var(--danger);
    font-size: var(--t-5);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

/* Grupos del formulario: secciones, filas de 3 y 4 columnas, casillas en lista y fotos */
.form-fieldset {
    display: grid;
    gap: 18px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.form-section {
    margin-top: 6px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.check-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.foto {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
}

.documento {
    width: 100%;
    max-width: 320px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* Confirmación sin JavaScript: <details class="confirm"> */
.confirm {
    position: relative;
    display: inline-block;
}

.confirm summary {
    list-style: none;
}

.confirm summary::-webkit-details-marker {
    display: none;
}

.confirm-box {
    position: absolute;
    right: 0;
    z-index: 5;
    display: grid;
    gap: 10px;
    width: 240px;
    margin-top: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: 0 14px 30px rgba(27, 32, 31, 0.14);
    color: var(--text);
    font-size: var(--t-5);
}

/* 12. Badges y etiquetas --------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--pizarra);
    color: var(--text);
    font-size: var(--t-5);
    white-space: nowrap;
}

.badge::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.badge-plain::before {
    display: none;
}

.badge-ok {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.badge-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-primary {
    background: var(--lima);
    color: var(--dark);
}

/* 13. Botones -------------------------------------------------------------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    font-size: var(--t-4);
    white-space: nowrap;
}

.button:hover {
    border-color: var(--muted);
}

.button-primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #ffffff;
}

.button-primary:hover {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
}

.button-danger {
    border-color: var(--danger-soft);
    color: var(--danger);
}

.button-ghost {
    border-color: transparent;
    background: transparent;
}

.button-small {
    min-height: 32px;
    padding: 0 12px;
    font-size: var(--t-5);
}

.button-full {
    width: 100%;
}

.button-between {
    justify-content: space-between;
}

/* Botón circular con icono (chevron, flecha, salir) */
.button-icon {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.75;
}

.button-icon:hover {
    opacity: 1;
}

.button-icon-plain {
    border-color: transparent;
}

/* 14. Iconos (SVG de línea, color = currentColor) -------------------------- */
.icon {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.6;
}

.icon-l {
    width: 24px;
    height: 24px;
}

/* 15. Alertas y avisos ----------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.alert-success {
    border-color: var(--brand-soft);
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.alert-error {
    border-color: var(--danger-soft);
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-warning {
    border-color: var(--warning-soft);
    background: var(--warning-soft);
    color: var(--warning);
}

/* 16. Login / público ------------------------------------------------------ */
.public-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.public-wrap {
    width: min(100%, 420px);
}

.login-panel {
    display: grid;
    gap: 26px;
    padding: 36px 32px;
    border-radius: var(--radius-l);
    background: var(--panel);
}

.login-intro {
    display: grid;
    justify-items: center;
    gap: 14px;
    text-align: center;
}

.login-logo {
    width: 170px;
    height: auto;
}

/* 17. Utilidades ----------------------------------------------------------- */
/* Campo trampa anti-bots: fuera de pantalla, no se usa display:none para que los bots lo llenen */
.campo-trampa {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.stack {
    display: grid;
    gap: 4px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.text-right {
    text-align: right;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--t-5);
}

/* 18. Responsive ----------------------------------------------------------- */
@media (max-width: 1200px) {
    .app-shell.has-aside {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .app-shell.has-aside .workspace {
        margin-right: 14px;
    }

    .aside {
        grid-column: 2;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        padding: 8px 14px 22px 0;
    }
}

@media (max-width: 900px) {
    .app-shell,
    .app-shell.has-aside {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        gap: 14px;
        padding: 18px 16px 6px;
    }

    .brand {
        padding-bottom: 14px;
    }

    .nav {
        display: flex;
        flex-wrap: wrap;
    }

    .nav-title {
        display: none;
    }

    .sidebar-user {
        margin-top: 0;
    }

    .workspace,
    .app-shell:not(.has-aside) .workspace,
    .app-shell.has-aside .workspace {
        margin: 0 8px;
        padding: 22px 16px;
    }

    .aside {
        grid-column: auto;
        padding: 22px 16px;
    }

    .topbar,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .grid-2,
    .form-grid,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }

    .cifra {
        font-size: var(--t-2);
    }
}
