/* =========================================================
   FacturacionAfip — sistema de diseño
   Paleta: tinta contable + timbre fiscal
   Tipografía: Space Grotesk (títulos) / Inter (texto)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ink: #0E161F;
    --surface: #141F2B;
    --surface-2: #1B2836;
    --surface-3: #223142;
    --line: #263140;
    --line-soft: #1E2A38;

    --accent: #2FD9A8;
    --accent-ink: #06231A;
    --accent-dim: #1D8A6A;

    --warn: #F2B705;
    --warn-ink: #2B2100;
    --danger: #F2555A;
    --danger-ink: #350707;

    --text: #E9F1F6;
    --text-muted: #8CA0AF;
    --text-faint: #5C7182;

    --radius-s: 6px;
    --radius-m: 10px;
    --shadow-pop: 0 12px 32px rgba(0,0,0,.35);

    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ink);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    margin: 0 0 .4em 0;
    letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* Textura de fondo: líneas finas tipo hoja de libro contable */
.ledger-bg {
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 27px,
        var(--line-soft) 28px
    );
}

/* ============ LOGIN ============ */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}

.login-brand {
    background: var(--surface);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    overflow: hidden;
    border-right: 1px solid var(--line);
}

.login-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--line-soft) 32px);
    opacity: .6;
}

.login-brand .mark {
    position: relative;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2.5rem;
}

.login-brand h1 {
    position: relative;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    max-width: 18ch;
    color: var(--text);
}

.login-brand p {
    position: relative;
    color: var(--text-muted);
    max-width: 40ch;
    margin-top: .75rem;
}

.login-stamp {
    position: relative;
    margin-top: 3rem;
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    border: 2px solid var(--accent-dim);
    color: var(--accent);
    padding: .5rem 1rem;
    border-radius: 999px;
    transform: rotate(-4deg);
    font-family: var(--font-display);
    font-size: .8rem;
    width: fit-content;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--ink);
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.login-card h2 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-card .sub { color: var(--text-muted); margin-bottom: 2rem; font-size: .92rem; }

@media (max-width: 860px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-panel { padding: 1.25rem; }
}

/* ============ FORMULARIOS ============ */
.field { margin-bottom: 1.1rem; }
.field label {
    display: block;
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: .4rem;
    font-weight: 500;
}

.input, select.input, textarea.input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    color: var(--text);
    padding: .72rem .85rem;
    font-family: var(--font-body);
    font-size: .95rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

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

.field-error { color: var(--danger); font-size: .82rem; margin-top: .35rem; }
.validation-summary-errors ul { list-style: none; padding: 0; margin: 0 0 1rem 0; }
.validation-summary-errors li {
    background: rgba(242,85,90,.12);
    border: 1px solid rgba(242,85,90,.35);
    color: #FFB4B6;
    padding: .6rem .8rem;
    border-radius: var(--radius-s);
    font-size: .88rem;
    margin-bottom: .4rem;
}

.checkbox-row { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: .88rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border: none;
    border-radius: var(--radius-s);
    padding: .75rem 1.3rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: transform .1s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); text-decoration: none; }
.btn-sm { padding: .45rem .8rem; font-size: .82rem; }

/* ============ APP SHELL ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .mark {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent);
    font-size: 1.15rem;
    padding: 0 .5rem;
    margin-bottom: 2rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .75rem;
    border-radius: var(--radius-s);
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: .15rem;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-3); color: var(--accent); }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
    font-size: .82rem;
    color: var(--text-faint);
}

.main {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem 4rem;
}

.topbar-mobile {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-mobile .mark { font-family: var(--font-display); font-weight: 700; color: var(--accent); }
.burger { background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-pop);
    }
    .sidebar.open { transform: translateX(0); }
    .topbar-mobile { display: flex; }
    .main { padding: 1.25rem; }
    .sidebar-scrim {
        display: none;
        position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25;
    }
    .sidebar-scrim.open { display: block; }
}

/* ============ HEADER DE PÁGINA ============ */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}
.page-head .eyebrow { color: var(--accent); font-size: .8rem; font-weight: 600; margin-bottom: .3rem; }
.page-head h1 { font-size: 1.6rem; }
.page-head p { color: var(--text-muted); margin: .25rem 0 0; font-size: .9rem; }

/* ============ TIRA DE MÉTRICAS (ledger tape, no cards genéricas) ============ */
.metric-tape {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    overflow: hidden;
    margin-bottom: 2rem;
    background: var(--surface);
}
.metric {
    padding: 1.25rem 1.5rem;
    border-right: 1px solid var(--line);
}
.metric:last-child { border-right: none; }
.metric .label { color: var(--text-muted); font-size: .78rem; text-transform: none; margin-bottom: .35rem; }
.metric .value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; }
.metric .value.accent { color: var(--accent); }
.metric .value.danger { color: var(--danger); }

@media (max-width: 640px) {
    .metric-tape { grid-template-columns: 1fr; }
    .metric { border-right: none; border-bottom: 1px solid var(--line); }
    .metric:last-child { border-bottom: none; }
}

/* ============ PANEL / SECCIÓN ============ */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.panel h3 { font-size: 1.05rem; margin-bottom: 1rem; }

/* ============ TABLA ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
table.data th {
    text-align: left;
    padding: .8rem 1rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: .78rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}
table.data td { padding: .85rem 1rem; border-bottom: 1px solid var(--line-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }

/* ============ ESTADOS / TIMBRE FISCAL ============ */
.stamp {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .74rem;
    padding: .28rem .65rem;
    border-radius: 999px;
    border: 1.5px solid currentColor;
}
.stamp.aprobado { color: var(--accent); }
.stamp.rechazado { color: var(--danger); }
.stamp.borrador { color: var(--text-faint); }
.stamp.anulado { color: var(--warn); }

.cae-box {
    border: 2px dashed var(--accent-dim);
    border-radius: var(--radius-m);
    padding: 1.25rem 1.5rem;
    background: rgba(47,217,168,.06);
    display: inline-block;
    transform: rotate(-1.2deg);
}
.cae-box .cae-num { font-family: var(--font-display); font-size: 1.4rem; letter-spacing: .04em; color: var(--accent); }
.cae-box .cae-label { color: var(--text-muted); font-size: .78rem; }

/* ============ ITEMS DE FACTURA (form dinámico) ============ */
.item-row {
    display: grid;
    grid-template-columns: 1fr 90px 130px 100px 40px;
    gap: .6rem;
    align-items: end;
    margin-bottom: .6rem;
}
.item-row .field { margin-bottom: 0; }
.item-remove {
    background: transparent; border: 1px solid var(--line); color: var(--danger);
    border-radius: var(--radius-s); height: 42px; cursor: pointer;
}
@media (max-width: 720px) {
    .item-row { grid-template-columns: 1fr 1fr; grid-template-areas: "desc desc" "cant precio" "iva remove"; }
}

.totales-box { text-align: right; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.totales-box .fila { display: flex; justify-content: flex-end; gap: 1.5rem; margin-bottom: .3rem; color: var(--text-muted); font-size: .88rem; }
.totales-box .fila.total { color: var(--text); font-family: var(--font-display); font-size: 1.2rem; }

/* ============ ALERTAS ============ */
.alert { padding: .85rem 1.1rem; border-radius: var(--radius-s); margin-bottom: 1.25rem; font-size: .9rem; }
.alert-exito { background: rgba(47,217,168,.1); border: 1px solid rgba(47,217,168,.35); color: var(--accent); }
.alert-advertencia { background: rgba(242,183,5,.1); border: 1px solid rgba(242,183,5,.35); color: var(--warn); }

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



/* --- 1. ADAPTACIÓN DE LOS PANELES Y TARJETAS DEL PANEL --- */
.panel {
    background-color: var(--bg-panel) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    transition: background-color 0.25s, border-color 0.25s, color 0.25s;
}

/* --- 2. CINTA DE MÉTRICAS (METRIC TAPE) --- */
.metric-tape {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.metric {
    background-color: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    padding: 1.25rem;
    transition: background-color 0.25s, border-color 0.25s;
}

    .metric .label {
        color: var(--text-muted) !important;
        font-size: 0.88rem;
        margin-bottom: 0.5rem;
        transition: color 0.25s;
    }

    .metric .value {
        color: var(--text-main) !important;
        font-size: 1.75rem;
        font-weight: bold;
        transition: color 0.25s;
    }

        /* Colores destacados para métricas especiales */
        .metric .value.accent {
            color: #0056b3 !important; /* Azul en modo claro */
        }

:root[data-theme="dark"] .metric .value.accent {
    color: #3b82f6 !important; /* Azul más brillante en modo oscuro para contraste */
}

.metric .value.danger {
    color: #dc3545 !important;
}

/* --- 3. ESTILIZADO DE TABLAS NATIVAS (.data) --- */
table.data {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main) !important;
    transition: color 0.25s;
}

    table.data th {
        background-color: var(--bg-app) !important;
        color: var(--text-muted) !important;
        border-bottom: 2px solid var(--border-color) !important;
        padding: 0.75rem;
        text-align: left;
        font-size: 0.88rem;
        transition: background-color 0.25s, border-bottom-color 0.25s, color 0.25s;
    }

    table.data td {
        padding: 0.75rem;
        border-bottom: 1px solid var(--border-color) !important;
        transition: border-bottom-color 0.25s;
    }

    /* Filas alternas (Striped) */
    table.data tbody tr:nth-child(even) {
        background-color: var(--table-striped) !important;
        transition: background-color 0.25s;
    }

    /* Enlaces dentro de la tabla */
    table.data td a {
        color: #0056b3;
        text-decoration: none;
        font-weight: 500;
    }

:root[data-theme="dark"] table.data td a {
    color: #3b82f6;
}

table.data td a:hover {
    text-decoration: underline;
}

