/**
 * Loa Fuentes — Hojas de estilo común del plugin.
 * Ubicación: /assets/css/common.css
 */

/* =========================================================================
 * 1. VARIABLES Y RESET
 * ========================================================================= */

:root {
    --lf-green:      #2d6a4f;
    --lf-green2:     #40916c;
    --lf-green-dark: #1b4332;

    --lf-dark:    #1a2620;
    --lf-muted:   #6b7a72;
    --lf-border:  #dde5df;
    --lf-cream:   #f5f8f6;
    --lf-white:   #ffffff;

    --lf-error-bg:       #fef2f0;
    --lf-error-border:   #fdb5ae;
    --lf-error-text:     #c0392b;
    --lf-success-bg:     #eef9f1;
    --lf-success-border: #a6d8b6;
    --lf-success-text:   #1e6b3a;

    --lf-font-sans:  'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --lf-font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --lf-font-mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

    --lf-radius-sm: 6px;
    --lf-radius-md: 8px;
    --lf-radius-lg: 14px;
    --lf-radius-xl: 16px;

    --lf-shadow-sm:    0 2px 8px rgba(45, 106, 79, 0.06);
    --lf-shadow-md:    0 4px 20px rgba(45, 106, 79, 0.10);
    --lf-shadow-hover: 0 6px 24px rgba(45, 106, 79, 0.14);

    --lf-transition: all 0.2s ease;

    --lf-topbar-h: 56px;
}

[id^="lf-"] *,
[id^="lf-"] *::before,
[id^="lf-"] *::after {
    box-sizing: border-box;
}

[id^="lf-"] {
    font-family: var(--lf-font-sans);
    color: var(--lf-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================================================
 * 2. LAYOUT
 * ========================================================================= */

.lf-screen {
    background: var(--lf-cream);
    min-height: calc(100vh - var(--lf-topbar-h));
    padding: 24px 32px;
}

.lf-screen--centered {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lf-screen__inner {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

@media (max-width: 560px) { .lf-screen { padding: 24px 20px; } }

.lf-page-header { margin-bottom: 24px; }

.lf-page-title {
    font-family: var(--lf-font-serif);
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 400;
    color: var(--lf-dark);
    line-height: 1.15;
    margin: 0 0 4px;
    letter-spacing: -0.3px;
}

.lf-page-title em { font-style: italic; color: var(--lf-green); }

.lf-page-subtitle {
    font-size: 14px;
    color: var(--lf-muted);
    margin: 0;
    line-height: 1.5;
}

.lf-card {
    background: var(--lf-white);
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-lg);
    padding: 28px;
    transition: var(--lf-transition);
}

.lf-card--narrow { max-width: 480px; margin: 0 auto; }
.lf-card--medium { max-width: 720px; margin: 0 auto; }

.lf-card--clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.lf-card--clickable:hover {
    border-color: var(--lf-green);
    box-shadow: var(--lf-shadow-hover);
    transform: translateY(-2px);
}

@media (max-width: 560px) { .lf-card { padding: 22px; } }

/* =========================================================================
 * 2.bis  PÁGINA EN 3 ZONAS FIJAS
 * ========================================================================= */

.lf-page-fixed {
    background: var(--lf-cream);
    height: calc(100vh - var(--lf-topbar-h));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lf-page-fixed__inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 28px;
}

.lf-page-fixed__top {
    flex: 0 0 auto;
    background: var(--lf-cream);
    padding-top: 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--lf-border);
}
.lf-page-fixed__top .lf-page-header { margin-bottom: 14px; }
.lf-page-fixed__top .lf-filters { margin-bottom: 0; }

.lf-page-fixed__middle {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-top: 14px;
    padding-bottom: 14px;
}

.lf-page-fixed__bottom {
    flex: 0 0 auto;
    background: var(--lf-white);
    border-top: 1px solid var(--lf-border);
    padding-top: 12px;
    padding-bottom: 14px;
}

.lf-page-fixed__bottom .lf-summary { margin-top: 0; }

@media (max-width: 560px) {
    .lf-page-fixed__inner { padding: 0 16px; }
}

/* =========================================================================
 * 3. BOTONES
 * ========================================================================= */

.lf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--lf-font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 11px 24px;
    border-radius: var(--lf-radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--lf-transition);
    line-height: 1.2;
}

.lf-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.lf-btn--primary { background: var(--lf-green); color: var(--lf-white); }
.lf-btn--primary:hover:not(:disabled) { background: var(--lf-green2); }

.lf-btn--secondary {
    background: transparent;
    color: var(--lf-green);
    border: 1.5px solid var(--lf-green);
}
.lf-btn--secondary:hover:not(:disabled) {
    background: var(--lf-green);
    color: var(--lf-white);
}

.lf-btn--ghost {
    background: transparent;
    color: var(--lf-muted);
    padding: 8px 14px;
}
.lf-btn--ghost:hover:not(:disabled) {
    color: var(--lf-dark);
    background: var(--lf-cream);
}

.lf-btn--sm { padding: 7px 16px; font-size: 13px; }
.lf-btn--lg { padding: 14px 32px; font-size: 15px; }
.lf-btn--block { display: flex; width: 100%; }

/* =========================================================================
 * 4. FORMULARIOS Y CAMPOS
 * ========================================================================= */

.lf-form { display: block; }

.lf-form__row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.lf-form__row > .lf-field { flex: 1 1 200px; }

.lf-field { margin-bottom: 14px; }

.lf-field__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--lf-muted);
    margin-bottom: 5px;
}

.lf-field__label--required::after {
    content: ' *';
    color: var(--lf-green);
}

.lf-field__input,
.lf-field__select,
.lf-field__textarea {
    width: 100%;
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-md);
    font-family: var(--lf-font-sans);
    font-size: 14px;
    color: var(--lf-dark);
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--lf-cream);
}

.lf-field__input:focus,
.lf-field__select:focus,
.lf-field__textarea:focus {
    border-color: var(--lf-green);
    background: var(--lf-white);
}

.lf-field__input:disabled,
.lf-field__select:disabled,
.lf-field__textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.lf-field__textarea {
    resize: vertical;
    min-height: 80px;
    font-family: var(--lf-font-sans);
}

.lf-field__hint {
    display: block;
    font-size: 12px;
    color: var(--lf-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.lf-field__password-wrap { position: relative; }
.lf-field__password-wrap .lf-field__input { padding-right: 40px; }
.lf-field__password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--lf-muted);
    line-height: 1;
    padding: 0;
}
.lf-field__password-toggle:hover { color: var(--lf-dark); }

.lf-form__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* =========================================================================
 * 5. MENSAJES
 * ========================================================================= */

.lf-message {
    padding: 11px 14px;
    border-radius: var(--lf-radius-md);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 14px;
    border: 1px solid;
}

.lf-message--error {
    background: var(--lf-error-bg);
    border-color: var(--lf-error-border);
    color: var(--lf-error-text);
}

.lf-message--success {
    background: var(--lf-success-bg);
    border-color: var(--lf-success-border);
    color: var(--lf-success-text);
}

.lf-message--info {
    background: var(--lf-cream);
    border-color: var(--lf-border);
    color: var(--lf-muted);
}

/* =========================================================================
 * 6. PESTAÑAS
 * ========================================================================= */

.lf-tabs {
    display: flex;
    border-bottom: 2px solid var(--lf-border);
    margin-bottom: 24px;
    gap: 4px;
}

.lf-tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-family: var(--lf-font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--lf-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--lf-transition);
    position: relative;
    top: 2px;
}

.lf-tab:hover { color: var(--lf-dark); }

.lf-tab--active {
    color: var(--lf-green);
    border-bottom-color: var(--lf-green);
}

.lf-tab-panel { display: none; }
.lf-tab-panel--active { display: block; }

/* =========================================================================
 * 7. TOOLBAR Y TABLAS
 * ========================================================================= */

.lf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.lf-toolbar__title {
    font-family: var(--lf-font-serif);
    font-size: 20px;
    color: var(--lf-dark);
    margin: 0;
    font-weight: 500;
}

.lf-table-wrap {
    background: var(--lf-white);
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-lg);
    overflow: hidden;
}

.lf-table-scroll { overflow-x: auto; }

.lf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.lf-table thead th {
    background: var(--lf-cream);
    color: var(--lf-muted);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1.5px solid var(--lf-border);
    white-space: nowrap;
}

.lf-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--lf-border);
    color: var(--lf-dark);
    vertical-align: middle;
}

.lf-table tbody tr:last-child td { border-bottom: none; }
.lf-table tbody tr:hover td { background: var(--lf-cream); }

.lf-table .lf-col-num { text-align: right; font-variant-numeric: tabular-nums; }
.lf-table .lf-col-actions { text-align: right; white-space: nowrap; }
.lf-table .lf-row--inactive td { color: var(--lf-muted); }

.lf-table tbody tr.lf-row--emitida td  { background: rgba(64, 145, 108, 0.025); }
.lf-table tbody tr.lf-row--recibida td { background: rgba(90, 58, 138, 0.025); }
.lf-table tbody tr.lf-row--emitida:hover td  { background: #f3faf5; }
.lf-table tbody tr.lf-row--recibida:hover td { background: #f6f2fb; }

.lf-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0.4px;
}
.lf-pill--on  { background: #eef9f1; color: var(--lf-green); }
.lf-pill--off { background: var(--lf-cream); color: var(--lf-muted); }

.lf-icon-btn {
    background: transparent;
    border: 1px solid var(--lf-border);
    border-radius: 6px;
    padding: 5px 9px;
    cursor: pointer;
    font-size: 13px;
    color: var(--lf-muted);
    transition: var(--lf-transition);
    margin-left: 4px;
    line-height: 1;
}
.lf-icon-btn:hover {
    color: var(--lf-green);
    border-color: var(--lf-green);
    background: var(--lf-cream);
}

.lf-empty {
    padding: 40px 24px;
    text-align: center;
    color: var(--lf-muted);
    font-size: 14px;
}
.lf-empty__icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* =========================================================================
 * 8. FILTROS  (compactos: tipografía y paddings reducidos para entrar en 1 línea)
 * ========================================================================= */

.lf-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: var(--lf-white);
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-lg);
    padding: 10px 12px;
    margin-bottom: 16px;
}

.lf-filters .lf-field {
    margin-bottom: 0;
    min-width: 110px;
    flex: 1 1 110px;
}

.lf-filters .lf-field__label {
    font-size: 10px;
    margin-bottom: 3px;
    letter-spacing: 0.5px;
}

.lf-filters .lf-field__select,
.lf-filters .lf-field__input {
    font-size: 13px;
    padding: 6px 10px;
}

.lf-filters .lf-btn {
    font-size: 13px;
    padding: 7px 14px;
}

.lf-filters__actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

@media (max-width: 640px) {
    .lf-filters__actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
}

/* =========================================================================
 * 9. BADGES Y RESUMEN
 * ========================================================================= */

.lf-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 4px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.lf-badge--emitida {
    background: #eef9f1;
    color: var(--lf-green-dark);
    border: 1px solid #a6d8b6;
}

.lf-badge--recibida {
    background: #f1ecf9;
    color: #5a3a8a;
    border: 1px solid #c8b9e3;
}

.lf-badge--pending {
    background: #fff4e0;
    color: #b07203;
    border: 1px solid #f0d49a;
}

.lf-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 18px;
}

.lf-summary--4col {
    grid-template-columns: repeat(4, 1fr);
}

.lf-summary--5col {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

@media (max-width: 960px) {
    .lf-summary--5col { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
    .lf-summary--4col { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
    .lf-summary,
    .lf-summary--4col,
    .lf-summary--5col { grid-template-columns: 1fr; }
}

.lf-summary__item {
    background: var(--lf-white);
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-lg);
    padding: 12px 16px;
}

.lf-summary--5col .lf-summary__item { padding: 9px 12px; }

.lf-summary__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--lf-muted);
    margin-bottom: 4px;
}

.lf-summary--5col .lf-summary__label {
    font-size: 10px;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.lf-summary__value {
    font-family: var(--lf-font-serif);
    font-size: 22px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--lf-dark);
    line-height: 1.1;
}

.lf-summary--5col .lf-summary__value { font-size: 16px; }

.lf-summary__value--positive { color: var(--lf-green); }
.lf-summary__value--negative { color: #c0392b; }

.lf-summary__hint {
    display: block;
    font-size: 11px;
    color: var(--lf-muted);
    margin-top: 4px;
    line-height: 1.35;
}

.lf-summary--5col .lf-summary__hint {
    font-size: 10px;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================================
 * 10. UPLOAD DE ARCHIVOS
 * ========================================================================= */

.lf-file-box {
    border: 1.5px dashed var(--lf-border);
    border-radius: var(--lf-radius-md);
    padding: 14px;
    background: var(--lf-cream);
    transition: var(--lf-transition);
}
.lf-file-box:hover {
    border-color: var(--lf-green);
    background: var(--lf-white);
}
.lf-file-box input[type="file"] {
    width: 100%;
    font-family: var(--lf-font-sans);
    font-size: 13px;
    color: var(--lf-dark);
}
.lf-file-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--lf-border);
}
.lf-file-current__name {
    font-size: 13px;
    color: var(--lf-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lf-file-link {
    color: var(--lf-green);
    text-decoration: none;
    font-size: 16px;
}
.lf-file-link:hover { color: var(--lf-green2); }

/* =========================================================================
 * 11. MODALES
 * ========================================================================= */

.lf-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 38, 32, 0.5);
    backdrop-filter: blur(3px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow-y: auto;
}
.lf-modal-overlay.is-open { display: flex; }

.lf-modal {
    background: var(--lf-white);
    border: 1.5px solid var(--lf-border);
    border-radius: var(--lf-radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 560px;
    position: relative;
    margin: auto;
}

.lf-modal--wide { max-width: 720px; }

.lf-modal__header { margin-bottom: 20px; }

.lf-modal__title {
    font-family: var(--lf-font-serif);
    font-size: 22px;
    font-weight: 500;
    color: var(--lf-dark);
    margin: 0;
    line-height: 1.2;
}

.lf-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--lf-muted);
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: var(--lf-transition);
}
.lf-modal__close:hover {
    color: var(--lf-dark);
    background: var(--lf-cream);
}

.lf-modal--fullscreen {
    max-width: 960px;
    width: 100%;
    max-height: 96vh;
    padding: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--lf-white);
}

.lf-modal--fullscreen.lf-modal--xl {
    max-width: 1280px;
}

.lf-modal--fullscreen .lf-modal__header {
    flex-shrink: 0;
    background: var(--lf-white);
    border-bottom: 1px solid var(--lf-border);
    padding: 6px 20px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.lf-modal--fullscreen .lf-modal__title {
    font-size: 15px;
    margin: 0;
}

.lf-modal--fullscreen .lf-modal__close {
    position: static;
    transform: none;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    font-size: 18px;
}

.lf-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 20px;
    background: var(--lf-cream);
}

.lf-modal--fullscreen .lf-field { margin-bottom: 10px; }
.lf-modal--fullscreen .lf-form__row { gap: 12px; }
.lf-modal--fullscreen .lf-field__label { margin-bottom: 3px; }
.lf-modal--fullscreen .lf-field__hint { margin-top: 3px; }

.lf-modal__footer {
    flex-shrink: 0;
    background: var(--lf-white);
    border-top: 1px solid var(--lf-border);
    padding: 10px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.lf-modal--fullscreen .lf-modal__msg { margin-bottom: 10px; }

.lf-grid--2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.lf-grid--3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 720px) {
    .lf-grid--2col { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 1100px) {
    .lf-grid--3col { grid-template-columns: 1fr; gap: 0; }
}

.lf-modal--fullscreen .lf-calc-box { margin-top: 0; }

@media (max-width: 560px) {
    .lf-modal { padding: 24px; }
    .lf-modal--fullscreen .lf-modal__header,
    .lf-modal--fullscreen .lf-modal__footer { padding: 10px 14px; }
    .lf-modal__body { padding: 14px; }
}

/* =========================================================================
 * 12. CAJA DE CÁLCULO
 * ========================================================================= */

.lf-calc-box {
    background: var(--lf-cream);
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-md);
    padding: 12px 14px;
    margin: 10px 0;
    font-size: 13px;
}

.lf-calc-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 0;
}

.lf-calc-row--total {
    border-top: 1px solid var(--lf-border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 700;
    color: var(--lf-dark);
}

.lf-calc-label { color: var(--lf-muted); }
.lf-calc-value { font-variant-numeric: tabular-nums; }

/* =========================================================================
 * 13. UTILIDADES
 * ========================================================================= */

.lf-mt-0  { margin-top: 0 !important; }
.lf-mb-0  { margin-bottom: 0 !important; }
.lf-mb-8  { margin-bottom: 8px; }
.lf-mb-16 { margin-bottom: 16px; }
.lf-mb-24 { margin-bottom: 24px; }

.lf-text-center { text-align: center; }
.lf-text-muted  { color: var(--lf-muted); }
.lf-text-small  { font-size: 13px; }

.lf-divider {
    height: 1px;
    background: var(--lf-border);
    border: 0;
    margin: 20px 0;
}