﻿/*
  Mafiz Visual System
  Estilo corporativo minimalista, sin degradados.
  Guia rapida:
  - Fondo general suave
  - Superficies blancas
  - Contraste alto en texto
  - Estados consistentes en badges y alerts
*/

/* ========================================================================== */
/* 1) Design Tokens                                                           */
/* ========================================================================== */
:root {
    --font-family: "Manrope", "Segoe UI", sans-serif;

    /* Base palette */
    --bg-app: #f3f5f7;
    --bg-subtle: #eef2f6;
    --surface: #ffffff;
    --surface-muted: #f8fafc;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #4b5565;
    --text-inverse: #f8fafc;

    /* Borders and shadows */
    --border: #d5dbe3;
    --border-strong: #c2cad4;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.08);

    /* Brand and semantic */
    --brand-600: #0059b3;
    --brand-700: #00478f;
    --neutral-900: #1d2939;

    --success-700: #067647;
    --success-100: #ecfdf3;
    --success-300: #abefc6;

    --error-700: #b42318;
    --error-100: #fef3f2;
    --error-300: #fecdca;

    --warning-700: #9a6700;
    --warning-100: #fffaeb;
    --warning-300: #fedf89;

    --info-700: #1849a9;
    --info-100: #eff4ff;
    --info-300: #c7d7fe;

    --paid-700: #0f7a5f;
    --paid-100: #ecfbf5;
    --paid-300: #b6efd8;

    --unpaid-700: #7a271a;
    --unpaid-100: #fff4ed;
    --unpaid-300: #ffd5c2;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Table */
    --table-hover: #f8fafc;

    /* Focus */
    --focus-ring: rgba(0, 89, 179, 0.18);
}

/* ========================================================================== */
/* 2) Reset + Base                                                            */
/* ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.45;
}

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

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

h1 {
    font-size: 1.45rem;
    font-weight: 700;
}

h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

h3 {
    font-size: 1rem;
    font-weight: 700;
}

/* ========================================================================== */
/* 3) Auth and Guest Layout                                                   */
/* ========================================================================== */
.auth-page,
.guest-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-shell,
.guest-shell {
    width: 100%;
    max-width: 460px;
}

.guest-shell--wide {
    max-width: 1040px;
}

.auth-card,
.guest-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
}

.auth-card__header {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.auth-logo {
    width: 118px;
    height: auto;
    max-width: 100%;
    display: block;
}

.auth-card__header p,
.guest-card p,
.auth-footnote {
    color: var(--text-secondary);
}

.guest-card--invitation {
    display: grid;
    gap: 24px;
}

.guest-hero {
    display: grid;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.guest-kicker {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 4px 10px;
    border: 1px solid var(--info-300);
    background: var(--info-100);
    color: var(--info-700);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.guest-logo {
    width: 132px;
    height: auto;
    display: block;
}

.guest-section {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.guest-section__header {
    display: grid;
    gap: 4px;
}

.guest-section__header p {
    font-size: 0.92rem;
}

.guest-section--dates {
    border-color: var(--info-300);
    background: linear-gradient(180deg, #f5f8ff 0%, #eef4ff 100%);
}

.guest-section--dates .guest-section__header h2 {
    color: var(--info-700);
}

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

.guest-dates-note {
    margin: 0;
    color: var(--info-700);
    font-size: 0.84rem;
}

.guest-dates-summary {
    display: grid;
    gap: 4px;
    border-radius: 10px;
    border: 1px solid var(--info-300);
    background: #ffffff;
    padding: 12px 14px;
}

.guest-dates-summary__label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #4b6ab8;
}

.guest-dates-summary strong {
    color: #1c3f8d;
    font-size: 1rem;
    line-height: 1.3;
}

.guest-section--readonly input[readonly] {
    background: #eef2f6;
    color: #475467;
    border-color: #d0d5dd;
}

.guest-section input:disabled {
    background: #eef2f6;
    color: #475467;
    border-color: #d0d5dd;
    cursor: not-allowed;
}

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

.guest-proposal-item {
    border: 1px solid #d5dbe3;
    border-radius: 10px;
    background: #ffffff;
    padding: 10px;
    display: grid;
    gap: 6px;
}

.guest-proposal-item.is-adjusted {
    border-color: #9cc2ff;
    background: #f5f9ff;
}

.guest-proposal-item header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.guest-proposal-item header span {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1f2937;
}

.guest-proposal-badge {
    border-radius: 999px;
    border: 1px solid #b2ccff;
    background: #eef4ff;
    color: #1849a9;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.guest-proposal-request {
    margin: 0;
    color: #6b7280;
    font-size: 0.78rem;
}

.guest-proposal-final {
    margin: 0;
    color: #111827;
    font-size: 0.84rem;
    font-weight: 600;
}

.guest-section--print {
    background: #ffffff;
}

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

.guest-print-item {
    border: 1px solid #d5dbe3;
    border-radius: 10px;
    padding: 12px;
    display: grid;
    gap: 6px;
    background: #ffffff;
}

.guest-print-item span {
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5c6b78;
    font-weight: 700;
}

.guest-print-item strong {
    font-size: 0.96rem;
    color: #101828;
    line-height: 1.3;
}

.auth-footnote {
    font-size: 0.86rem;
}

/* ========================================================================== */
/* 4) Panel Shell                                                             */
/* ========================================================================== */
.panel-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: var(--neutral-900);
    color: var(--text-inverse);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__brand img {
    width: 36px;
    height: 36px;
}

.sidebar__brand strong {
    display: block;
    font-size: 1rem;
}

.sidebar__brand small {
    color: #c8d0da;
    font-size: 0.75rem;
}

.sidebar__meta {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.sidebar__meta .label {
    color: #c8d0da;
    text-transform: uppercase;
    font-size: 0.72rem;
}

.sidebar__meta .value {
    display: block;
    margin-top: 4px;
    font-size: 0.86rem;
    font-weight: 600;
}

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

.sidebar__link {
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: #e6ebf2;
    font-size: 0.92rem;
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar__link.is-active {
    background: var(--brand-600);
    color: #ffffff;
    font-weight: 600;
}

.panel-main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
}

.topbar__title {
    flex: 1;
}

.topbar__title p {
    color: var(--text-secondary);
    font-size: 0.86rem;
    margin-top: 4px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    cursor: pointer;
}

.icon-btn span {
    height: 2px;
    width: 100%;
    background: #334155;
}

.panel-content {
    padding: 20px;
    display: grid;
    align-content: start;
    gap: 16px;
}

/* ========================================================================== */
/* 5) Surfaces: cards, sections, metrics                                      */
/* ========================================================================== */
.card,
.metric-card,
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card,
.section {
    padding: 16px;
}

.card__header,
.section__header {
    margin-bottom: 12px;
}

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

.metric-card {
    padding: 14px;
    display: grid;
    gap: 6px;
}

.metric-card h3,
.metric-card small {
    color: var(--text-secondary);
}

.metric-card strong {
    font-size: 1.35rem;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.quick-links a {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
}

/* ========================================================================== */
/* 6) Forms                                                                   */
/* ========================================================================== */
.form-grid,
.form-stack {
    display: grid;
    gap: 12px;
}

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

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

.form-stack {
    grid-template-columns: 1fr;
}

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

.field span {
    color: #344054;
    font-size: 0.82rem;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text-primary);
    background: #ffffff;
}

.field input::placeholder,
.field textarea::placeholder {
    color: #8a95a5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid var(--focus-ring);
    border-color: var(--brand-600);
}

.field input.is-invalid,
.field select.is-invalid,
.field textarea.is-invalid {
    border-color: var(--error-700);
    outline: 2px solid rgba(180, 35, 24, 0.12);
}

.field--inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field--inline input {
    width: auto;
}

.field--inline span {
    margin: 0;
}

.field--full {
    grid-column: 1 / -1;
}

/* ========================================================================== */
/* 7) Buttons                                                                 */
/* ========================================================================== */
.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.btn--block {
    width: 100%;
}

.btn--sm {
    padding: 7px 10px;
    font-size: 0.8rem;
}

.btn--primary {
    background: var(--brand-600);
    color: #ffffff;
}

.btn--primary:hover {
    background: var(--brand-700);
}

.btn--secondary {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn--secondary:hover {
    border-color: var(--border-strong);
}

.btn--excel {
    background: #217346;
    border-color: #1a5f3a;
    color: #ffffff;
}

.btn--excel:hover {
    background: #1a5f3a;
    border-color: #14502f;
}

.btn--ghost {
    background: #ffffff;
    border-color: var(--border);
    color: var(--text-primary);
}

.btn--ghost:hover {
    background: var(--surface-muted);
}

.btn--danger {
    background: var(--error-700);
    color: #ffffff;
}

.btn--danger:hover {
    background: #9f1f15;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.button-row .btn {
    min-width: 180px;
}

/* ========================================================================== */
/* 8) Tables                                                                  */
/* ========================================================================== */
.table-wrap {
    overflow: auto;
}

.table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    font-size: 0.88rem;
}

.table th {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: 0.75rem;
}

.table tbody tr:hover {
    background: var(--table-hover);
}

.table td[data-label] {
    position: relative;
}

/* ========================================================================== */
/* 9) Status Badges                                                           */
/* ========================================================================== */
.status,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 3px 10px;
    border: 1px solid transparent;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.01em;
}

/* Pendiente */
.status--pending,
.badge--pendiente {
    background: var(--warning-100);
    color: var(--warning-700);
    border-color: var(--warning-300);
}

/* Aprobado */
.status--approved,
.badge--aprobado {
    background: var(--success-100);
    color: var(--success-700);
    border-color: var(--success-300);
}

/* Rechazado */
.status--rejected,
.badge--rechazado {
    background: var(--error-100);
    color: var(--error-700);
    border-color: var(--error-300);
}

/* Confirmado */
.status--confirmed,
.badge--confirmado {
    background: #edfdf8;
    color: #08735e;
    border-color: #9ee8d7;
}

/* En revision */
.status--review,
.status--processing,
.badge--revision {
    background: var(--info-100);
    color: var(--info-700);
    border-color: var(--info-300);
}

/* Pagado */
.status--paid,
.badge--pagado {
    background: var(--paid-100);
    color: var(--paid-700);
    border-color: var(--paid-300);
}

/* No pagado */
.status--unpaid,
.badge--no-pagado {
    background: var(--unpaid-100);
    color: var(--unpaid-700);
    border-color: var(--unpaid-300);
}

/* ========================================================================== */
/* 10) Alerts                                                                 */
/* ========================================================================== */
.alert {
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.alert--info {
    background: var(--info-100);
    color: var(--info-700);
    border-color: var(--info-300);
}

.alert--success {
    background: var(--success-100);
    color: var(--success-700);
    border-color: var(--success-300);
}

.alert--warning {
    background: var(--warning-100);
    color: #b54708;
    border-color: var(--warning-300);
}

.alert--error {
    background: var(--error-100);
    color: var(--error-700);
    border-color: var(--error-300);
}

/* ========================================================================== */
/* 11) Modal                                                                  */
/* ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 70;
}

.modal-backdrop.is-open {
    display: flex;
}

.modal {
    width: min(640px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.modal__header,
.modal__body,
.modal__footer {
    padding: 16px;
}

.modal__header {
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal__body {
    display: grid;
    gap: 10px;
}

.modal__footer {
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========================================================================== */
/* 12) Empty State + Toast                                                    */
/* ========================================================================== */
.empty-state {
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    background: #ffffff;
    display: grid;
    justify-items: center;
    gap: 8px;
}

.empty-state__icon {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-weight: 700;
}

.empty-state h3 {
    margin-bottom: 0;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.toast-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    display: grid;
    gap: 8px;
}

.toast {
    min-width: 260px;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    font-size: 0.88rem;
}

.toast[data-kind="success"] {
    border-color: var(--success-300);
}

.toast[data-kind="error"] {
    border-color: var(--error-300);
}

/* ========================================================================== */
/* 13) Responsive                                                             */
/* ========================================================================== */
@media (max-width: 1200px) {
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid--4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .panel-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 40;
    }

    .panel-shell[data-sidebar-state="open"] .sidebar {
        transform: translateX(0);
    }

    .split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .panel-content {
        padding: 14px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

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

    .table {
        min-width: 520px;
    }

    .auth-card,
    .guest-card {
        padding: 20px;
    }

    .guest-proposal-grid {
        grid-template-columns: 1fr;
    }

    .guest-print-grid {
        grid-template-columns: 1fr;
    }

    .guest-dates-grid {
        grid-template-columns: 1fr;
    }

    .guest-shell--wide {
        max-width: 100%;
    }

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

    .table--responsive thead {
        display: none;
    }

    .table--responsive tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 10px;
        background: #ffffff;
        overflow: hidden;
    }

    .table--responsive tbody td {
        display: grid;
        grid-template-columns: 128px 1fr;
        gap: 10px;
        align-items: center;
        border-bottom: 1px solid var(--border);
        padding: 10px 12px;
    }

    .table--responsive tbody td:last-child {
        border-bottom: 0;
    }

    .table--responsive tbody td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        font-weight: 700;
    }
}

@media print {
    .guest-print-actions {
        display: none !important;
    }

    .guest-page {
        background: #ffffff;
        padding: 0;
    }

    .guest-card--printable {
        border: 0;
        box-shadow: none;
        padding: 0;
    }
}
