/* Merkur - Estilos específicos (base en velantia-base.css) */

.logo-upload-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.logo-preview {
    margin-bottom: 0.5rem;
}

.logo-preview img {
    display: block;
    margin-bottom: 0.25rem;
}

.logo-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0;
}

.totals {
    margin-top: 1rem;
    text-align: right;
}

.totals p {
    margin: 0.15rem 0;
}

.table.table-totals {
    margin-top: 1rem;
    margin-left: auto;
    width: max-content;
    max-width: 100%;
}

.table-totals td {
    white-space: nowrap;
    vertical-align: middle;
}

.table-totals td:first-child {
    text-align: right;
    padding-right: 1rem;
    background-color: #f9fafb;
}

.table-totals td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Estado factura badges */
.estado-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
}

.estado-badge.estado-borrador {
    background-color: #e5e7eb;
}

.estado-badge.estado-enviada {
    background-color: #fef3c7;
}

.estado-badge.estado-pagada {
    background-color: #d1fae5;
}

.estado-badge.estado-parcialmente_pagada {
    background-color: #cffafe;
}

.estado-badge.estado-vencida {
    background-color: #fed7aa;
}

.estado-badge.estado-impagada {
    background-color: #fecaca;
}

.estado-badge.estado-cancelada {
    background-color: #fee2e2;
}

.estado-badge.estado-aceptado {
    background-color: #d1fae5;
}

.estado-badge.estado-rechazado {
    background-color: #fee2e2;
}

.estado-badge.estado-convertido {
    background-color: #dbeafe;
}

.fecha-vencida {
    color: #dc2626;
    font-weight: 600;
}

.aeat-status-failed {
    color: #dc2626;
    font-weight: 700;
}

.aeat-status-warning {
    color: #ea580c;
    font-weight: 700;
}

.aeat-subsanacion-block-warning {
    border-left: 3px solid #ea580c;
    padding-left: 0.75rem;
}

.table-lines .col-center {
    text-align: center;
}

.table-lines .col-center input {
    text-align: center;
}

/* Alinear inputs en la misma línea de base: la celda de precio incluye el preview bajo el input */
.table-lines tbody td {
    vertical-align: top;
}

.table-lines tbody input:not([type="checkbox"]):not([type="radio"]) {
    box-sizing: border-box;
    vertical-align: bottom;
}

.btn-anadir-linea {
    margin-top: 1.1rem;
    margin-bottom: 1rem;
}

.btn-icon-add {
    text-decoration: none;
    transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-icon-add:hover {
    text-decoration: none;
    background-color: #1e3a8a;
    box-shadow: 0 8px 20px rgba(30, 58, 138, 0.22);
    transform: translateY(-1px);
}

.btn-icon-add:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}


.factura-detalle-card,
.cliente-detalle-card,
.presupuesto-detalle-card {
    padding: 1.25rem 1.35rem;
}

.factura-meta-block {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.factura-meta-block:last-of-type {
    border-bottom: 0;
    padding-bottom: 0;
}

.factura-meta-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.factura-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.85rem 1.25rem;
}

.factura-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background-color: #f9fafb;
}

.factura-meta-label {
    font-size: 0.78rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: #6b7280;
}

.factura-meta-value {
    color: #111827;
    line-height: 1.35;
    font-weight: 500;
}

/* Force-remove any injected trailing separators from global/theme CSS. */
.factura-detalle-card .factura-meta-value::after,
.factura-detalle-card .factura-meta-value::before,
.factura-detalle-card .factura-meta-value > span::after,
.factura-detalle-card .factura-meta-value > span::before,
.factura-detalle-card .factura-meta-value > code::after,
.factura-detalle-card .factura-meta-value > code::before,
.factura-detalle-card .factura-meta-value > a::after,
.factura-detalle-card .factura-meta-value > a::before,
.factura-detalle-card .factura-meta-item::after,
.factura-detalle-card .factura-meta-item::before,
.factura-detalle-card .factura-meta-item > span::after,
.factura-detalle-card .factura-meta-item > span::before,
.factura-detalle-card .factura-meta-item > code::after,
.factura-detalle-card .factura-meta-item > code::before,
.factura-detalle-card .factura-meta-item > a::after,
.factura-detalle-card .factura-meta-item > a::before,
.factura-detalle-card .factura-meta-block span::after,
.factura-detalle-card .factura-meta-block span::before,
.factura-detalle-card .factura-meta-block code::after,
.factura-detalle-card .factura-meta-block code::before,
.factura-detalle-card .factura-meta-block a::after,
.factura-detalle-card .factura-meta-block a::before,
.factura-detalle-card .factura-meta-value *::after {
    content: "" !important;
    display: none !important;
}

.factura-meta-value code {
    font-size: 0.83rem;
    background-color: #eef2ff;
    border-radius: 0.3rem;
    padding: 0.15rem 0.3rem;
}

.factura-meta-code {
    word-break: break-all;
}

.factura-meta-extra {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.65rem 0.75rem;
    border: 1px dashed #cbd5e1;
    border-radius: 0.5rem;
    background-color: #f8fafc;
}

.detalle-lineas-table {
    margin-top: 1.6rem;
}

.detalle-lineas-title {
    margin-top: 1.4rem;
    margin-bottom: 0.7rem;
}

.factura-notas-block {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.workflow-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.workflow-current {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.workflow-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.workflow-actions form {
    margin: 0;
}

.workflow-history-title {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    color: #4b5563;
}

.workflow-history-list {
    margin: 0;
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: #374151;
}

.estado-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.estado-actions-label {
    text-transform: none;
    letter-spacing: 0;
}

.estado-workflow-row {
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.estado-workflow-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.workflow-control-btn {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    color: #374151;
    background: #fff;
    user-select: none;
    transition: all 0.15s ease;
}

.workflow-control-btn:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.workflow-control-btn::-webkit-details-marker {
    display: none;
}

.workflow-inline-actions {
    margin-top: 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.workflow-inline-actions form {
    margin: 0;
}

.workflow-history-dropdown {
    margin-top: 0.4rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.45rem;
    background: #ffffff;
    min-width: 520px;
    max-width: 620px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    font-size: 0.78rem;
}

.workflow-popover {
    position: relative;
}

.workflow-popover[open] .workflow-inline-actions,
.workflow-popover[open] .workflow-history-dropdown {
    position: absolute;
    z-index: 20;
}

.workflow-popover[open] .workflow-inline-actions {
    top: 1.5rem;
    right: 0;
    padding: 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.45rem;
    background: #ffffff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    min-width: 300px;
}

.workflow-popover[open] .workflow-history-dropdown {
    top: 2rem;
    right: 0;
}

.workflow-history-list {
    font-size: 0.76rem;
    line-height: 1.25;
}

.workflow-history-list li {
    white-space: nowrap;
}

.workflow-final-state {
    margin: 0;
    font-size: 0.78rem;
    color: #6b7280;
}

.workflow-action-btn {
    width: 100%;
    border: 1px solid #dbe3f0;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #0f172a;
    font-size: 0.83rem;
    font-weight: 500;
    padding: 0.45rem 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.workflow-action-btn:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
    transform: translateY(-1px);
}

.workflow-action-btn-danger {
    border-color: #fecaca;
    color: #b91c1c;
    background: #fff5f5;
}

.workflow-action-btn-danger:hover {
    border-color: #fca5a5;
    background: #fee2e2;
}

.workflow-hidden-forms {
    display: none;
}

.input-readonly {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #d1d5db;
}

.estado-label-tooltip {
    position: relative;
    display: inline-flex;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.estado-label-tooltip-icon {
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 0.68rem;
    line-height: 0.95rem;
    text-align: center;
    font-weight: 700;
    background: #fff;
}

.estado-label-tooltip-content--compact {
    min-width: 18rem;
    max-width: 22rem;
}

.estado-label-tooltip-content {
    position: absolute;
    left: 0;
    top: 1.3rem;
    z-index: 30;
    min-width: 430px;
    max-width: 560px;
    padding: 0.55rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.45rem;
    background: #fff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    display: none;
    font-size: 0.76rem;
    color: #334155;
}

.estado-label-tooltip:hover .estado-label-tooltip-content {
    display: block;
}

.estado-label-tooltip.is-open .estado-label-tooltip-content {
    display: block;
}

.estado-label-tooltip-title {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.78rem;
}

.estado-label-tooltip-list {
    margin: 0;
    padding-left: 1rem;
}

.estado-label-tooltip-list li {
    white-space: nowrap;
    line-height: 1.25;
}

.workflow-editor-actions {
    position: relative;
}

.workflow-editor-actions > summary {
    cursor: pointer;
    list-style: none;
    border: 1px solid #dbe3f0;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #0f172a;
    font-size: 0.83rem;
    font-weight: 500;
    padding: 0.45rem 0.8rem;
    transition: all 0.15s ease;
}

.workflow-editor-actions > summary:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.workflow-editor-actions > summary::-webkit-details-marker {
    display: none;
}

.workflow-editor-actions-menu {
    display: none;
}

.workflow-editor-actions[open] .workflow-editor-actions-menu {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: absolute;
    left: 0;
    top: 2.2rem;
    z-index: 20;
    min-width: 320px;
    padding: 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.45rem;
    background: #fff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
}

@media (max-width: 768px) {
    .factura-detalle-card,
    .cliente-detalle-card,
    .presupuesto-detalle-card {
        padding: 1rem;
    }

    .factura-meta-grid {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .factura-meta-item {
        padding: 0.6rem 0.65rem;
    }
}

.precio-cell {
    position: relative;
}

.precio-cell .precio-formula {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.precio-result {
    display: block;
    font-size: 0.75rem;
    margin-top: 0.2rem;
    line-height: 1.25;
    min-height: 0.95rem;
}

.precio-result:empty {
    visibility: hidden;
}

/* Configuracion - estilo homogeneo */
.config-surface {
    border: 1.5px solid #e2e8f0;
    border-radius: 0.85rem;
    padding: 1.25rem 1.35rem;
    background: #fafbfc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.config-surface:hover {
    border-color: #cbd5e1;
}

.config-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 0.65rem;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.15rem 1.35rem;
}

.pdf-style-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.pdf-style-option {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0.55rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pdf-style-option input[type="radio"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
    /* No interceptar hover: el tooltip del título y el clic siguen funcionando vía <label>. */
    pointer-events: none;
}

.pdf-style-option__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.55rem;
    background: #fff;
    pointer-events: none;
    user-select: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.pdf-style-option input[type="radio"]:checked + .pdf-style-option__body {
    border-color: #2563eb;
    background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12);
}

.pdf-style-option:hover .pdf-style-option__body {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.pdf-style-option input[type="radio"]:focus-visible + .pdf-style-option__body {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.pdf-style-option__title {
    position: relative;
    z-index: 1;
    font-size: 0.875rem;
    color: #0f172a;
    cursor: help;
    pointer-events: auto;
}

.pdf-style-option__desc {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.35;
}

.pdf-style-option__thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    border: 1px solid #e2e8f0;
    border-radius: 0.45rem;
    overflow: hidden;
    background: #f8fafc;
}

.pdf-style-option__thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pdf-style-option__thumb-placeholder {
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #64748b;
    font-size: 0.78rem;
    padding: 0.4rem;
}

.config-grid .form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.25rem;
    display: block;
}

.config-grid input,
.config-grid select {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #fff;
}

.config-main-card {
    border: 1.5px solid #e2e8f0;
    border-radius: 0.85rem;
    padding: 1.25rem 1.35rem;
    background: #fafbfc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.config-main-card:hover {
    border-color: #cbd5e1;
}

@media (max-width: 560px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
    .pdf-style-options {
        grid-template-columns: 1fr;
    }
}
