/* Variables globales */
:root {
    --primary-blue: #3b82f6;
    --accent-dark: #2563eb;
    --text-gray: #4b5563;
    --bg-dark: #f0f2f5;
    --bg-darker: #ffffff;
    --text-light: #1a1b1e;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --danger-red: #ef4444;
}

/* Estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    min-height: 100vh;
    background-color: var(--bg-dark);
    overflow-x: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-darker);
    height: 60px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    position: sticky;
    top: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.logo-image {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.logo {
    color: var(--text-light);
    font-weight: bold;
    font-size: 1.2rem;
}

.search-bar {
    flex: 1;
    margin: 0 2rem;
    max-width: 400px;
}

.search-bar input {
    padding: 0.8rem;
    border: none;
    border-radius: 20px;
    width: 100%;
    background: var(--bg-dark);
    color: var(--text-light);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-button:hover {
    background-color: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Filtros */
.filters-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-darker);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-gray);
}

.filter-group select {
    padding: 0.6rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: white;
    color: var(--text-light);
    cursor: pointer;
    min-width: 200px;
    transition: all 0.3s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-refresh,
.btn-export,
.btn-consulta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-refresh {
    background-color: var(--primary-blue);
    color: white;
}

.btn-refresh:hover {
    background-color: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-export {
    background-color: var(--success-green);
    color: white;
}

.btn-export:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-consulta {
    background-color: #8b5cf6;
    color: white;
}

.btn-consulta:hover {
    background-color: #7c3aed;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-facturas {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-facturas:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(217, 119, 6, 0.35);
}

/* Contenedor principal */
.app-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    padding-bottom: 70px;
}

/* Estadísticas */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background-color: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    color: white;
}

.stat-info h3 {
    font-size: 2rem;
    color: var(--text-light);
    margin-bottom: 0.3rem;
}

.stat-info p {
    color: var(--text-gray);
    font-size: 0.9rem;
}

/* Lista de proveedores */
.content-container {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.clientes-list {
    padding: 1rem;
}

.cliente-card {
    background-color: var(--bg-dark);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.cliente-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cliente-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cliente-header:hover {
    background: linear-gradient(135deg, var(--accent-dark), #1e40af);
}

.cliente-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.cliente-icon {
    width: 45px;
    height: 45px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.cliente-details h3 {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

.cliente-details p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.cliente-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-weight: 600;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

/* Lista de artículos */
.articulos-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
}

.articulos-list.expanded {
    max-height: 800px;
    overflow-y: auto;
    overflow-x: auto;
    transition: max-height 0.5s ease-in;
}

/* Buscador de artículos por proveedor */
.cliente-search-bar {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: white;
    border-bottom: 2px solid var(--bg-dark);
    gap: 0.8rem;
}

.cliente-search-bar i {
    color: var(--primary-blue);
    font-size: 1.1rem;
}

.cliente-search-input {
    flex: 1;
    padding: 0.7rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.cliente-search-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.cliente-search-input::placeholder {
    color: #9ca3af;
}

/* Scrollbar para la lista de artículos */
.articulos-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.articulos-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.articulos-list::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: 4px;
}

.articulos-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

.articulos-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.articulos-table thead {
    background-color: var(--bg-dark);
}

.articulos-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-gray);
    border-bottom: 2px solid #e5e7eb;
}

.articulos-table td {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text-light);
}

.articulos-table tbody tr {
    transition: background-color 0.2s ease;
}

.articulos-table tbody tr:hover {
    background-color: var(--bg-dark);
}

.precio-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background-color: var(--success-green);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

.tipo-badge {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background-color: #e5e7eb;
    color: var(--text-gray);
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes highlightNew {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
    }
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Hamburger menu */
.hamburger-menu {
    position: fixed;
    bottom: 70px;
    right: 20px;
    z-index: 1000;
}

.hamburger-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-dark));
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.hamburger-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.dropdown-menu {
    display: none;
    position: absolute;
    bottom: 70px;
    right: 0;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    overflow: hidden;
}

.hamburger-menu:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 1rem;
}

.dropdown-item:hover {
    background-color: var(--bg-dark);
}

.dropdown-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.5rem 0;
}

/* Navigation bar */
.navigation-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 5px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-item {
    color: var(--text-gray);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.9em;
    transition: color 0.3s ease;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-blue);
}

.nav-item i {
    font-size: 1.5em;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    max-width: 700px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: var(--text-gray);
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--text-light);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-gray);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 1rem;
}

/* ============================================================================ */
/* MODALES PERSONALIZADOS */
/* ============================================================================ */

.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.custom-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 450px;
    width: 90%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.custom-modal-header {
    padding: 2rem;
    text-align: center;
    color: white;
}

.custom-modal-header i {
    font-size: 3.5rem;
}

.custom-modal-body {
    padding: 2rem 2rem 1rem 2rem;
    text-align: center;
}

.custom-modal-body p {
    font-size: 1.1rem;
    color: var(--text-gray);
    line-height: 1.6;
}

.custom-modal-footer {
    padding: 1rem 2rem 2rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.custom-modal-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.custom-modal-btn {
    background-color: var(--primary-blue);
    color: white;
}

.custom-modal-btn:hover {
    background-color: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.custom-modal-btn-secondary {
    background-color: #e5e7eb;
    color: var(--text-gray);
}

.custom-modal-btn-secondary:hover {
    background-color: #d1d5db;
}

/* Toast notifications */
.sync-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sync-toast.success {
    background-color: #10b981;
    color: white;
}

.sync-toast.error {
    background-color: #ef4444;
    color: white;
}

.sync-toast.info {
    background-color: #3b82f6;
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-wrap: wrap;
        height: auto;
        padding: 1rem;
    }

    .search-bar {
        order: 3;
        margin: 1rem 0 0 0;
        max-width: 100%;
    }

    .filters-container {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .articulos-list.expanded {
        max-height: 400px;
    }

    .articulos-table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .articulos-table thead,
    .articulos-table tbody,
    .articulos-table tr,
    .articulos-table th,
    .articulos-table td {
        display: block;
    }

    .articulos-table thead {
        display: none;
    }

    .articulos-table tr {
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        background: white;
        white-space: normal;
    }

    .articulos-table td {
        text-align: right;
        padding: 0.5rem 0;
        border: none;
        position: relative;
        padding-left: 50%;
        min-height: 30px;
    }

    .articulos-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        text-align: left;
        font-weight: bold;
        color: var(--text-gray);
    }

    .cliente-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .hamburger-menu {
        bottom: 60px;
    }

    .app-container {
        padding: 1rem;
    }

    .cliente-search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .custom-modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1rem;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .articulos-list.expanded {
        max-height: 350px;
    }

    .articulos-table td {
        font-size: 0.8rem;
        padding: 0.4rem 0;
        padding-left: 45%;
    }

    .articulos-table td::before {
        font-size: 0.75rem;
    }

    .precio-badge,
    .precio-base,
    .tipo-badge {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

/* Estilos para precios base */
.precio-base {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background-color: #e5e7eb;
    color: var(--text-gray);
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.95rem;
}

/* Ajustar ancho de columnas en tabla */
.articulos-table th:nth-child(1),
.articulos-table td:nth-child(1) {
    width: 12%;
}

.articulos-table th:nth-child(2),
.articulos-table td:nth-child(2) {
    width: 25%;
}

.articulos-table th:nth-child(3),
.articulos-table td:nth-child(3) {
    width: 12%;
}

/* Contenedor de búsqueda con autocompletado */
.search-select-container {
    position: relative;
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: -1px;
}

.search-result-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: var(--bg-dark);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item.no-results {
    cursor: default;
    color: var(--text-gray);
    text-align: center;
    font-style: italic;
}

.search-result-item.no-results:hover {
    background-color: white;
}

.result-code {
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 0.2rem;
}

.result-name {
    color: var(--text-light);
    margin-bottom: 0.2rem;
}

.result-detail {
    font-size: 0.85rem;
    color: var(--text-gray);
}

.selected-item {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background-color: var(--bg-dark);
    border: 1px solid var(--primary-blue);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.selected-text {
    flex: 1;
    color: var(--text-light);
}

.selected-text strong {
    color: var(--primary-blue);
}

.btn-clear {
    background: none;
    border: none;
    color: var(--danger-red);
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.btn-clear:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Estilos del formulario */
.precio-form {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-gray);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group select:disabled,
.form-group input:disabled,
.form-group textarea:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

.form-help {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-gray);
    font-size: 0.85rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.form-preview {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.1));
    border-radius: 8px;
    border-left: 4px solid var(--primary-blue);
}

.form-preview h3 {
    margin-bottom: 0.8rem;
    color: var(--text-gray);
    font-size: 0.95rem;
}

.form-preview p {
    margin: 0.5rem 0;
    font-size: 1rem;
}

.precio-final-preview {
    color: var(--primary-blue);
    font-size: 1.2rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: #e5e7eb;
    color: var(--text-gray);
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

/* Botón flotante para añadir */
.btn-add-float {
    position: fixed;
    bottom: 130px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 999;
}

.btn-add-float:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Ajustar posición en móvil para evitar superposición */
@media (max-width: 768px) {
    .btn-add-float {
        bottom: 140px;
        right: 15px;
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    .cliente-header {
        flex-wrap: wrap;
        gap: 0.8rem;
    }

    .toggle-icon {
        order: 2;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions button {
        width: 100%;
        justify-content: center;
    }

    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .actions-cell {
        display: flex;
        gap: 0.3rem;
        justify-content: center;
    }

    .btn-icon {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .search-results {
        max-height: 200px;
    }

    .result-code,
    .result-name {
        font-size: 0.9rem;
    }

    .result-detail {
        font-size: 0.75rem;
    }

    .hamburger-menu {
        bottom: 60px;
    }
}

@media (max-width: 480px) {
    .btn-add-float {
        bottom: 130px;
        right: 10px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* Botones de acción en tabla */
.btn-icon {
    padding: 0.5rem 0.7rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 0.2rem;
    font-size: 0.9rem;
}

.btn-edit {
    background-color: var(--primary-blue);
    color: white;
}

.btn-edit:hover {
    background-color: var(--accent-dark);
    transform: translateY(-2px);
}

.btn-delete {
    background-color: var(--danger-red);
    color: white;
}

.btn-delete:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
}

.actions-cell {
    white-space: nowrap;
}

/* Modal más ancho para el formulario */
.modal-content {
    max-width: 800px;
}

/* Scrollbar personalizado para resultados de búsqueda */
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

/* ════════════════════════════════════════════════════════════════════════
   MODALES DE BÚSQUEDA HISTÓRICA (Entradas F_ENT/F_LEN, Facturas F_FRE/F_LFR)
   Estilos importados/adaptados de gestionentradas.css — namespace propio
   (:root con nombres distintos, y .form-group escapado bajo .modal-form-body
   para no chocar con el .form-group del modal principal de precios).
   ════════════════════════════════════════════════════════════════════════ */
:root {
    --blue-dark:   #1e3a5f;
    --blue-mid:    #2563eb;
    --blue-light:  #dbeafe;
    --green:       #10b981;
    --green-light: #d1fae5;
    --amber:       #f59e0b;
    --red:         #ef4444;
    --red-light:   #fee2e2;
    --surface:     #ffffff;
    --border:      #e2e8f0;
    --text:        #1a202c;
    --text-mid:    #4a5568;
    --shadow-md:   0 4px 20px rgba(0,0,0,.12);
    --shadow-lg:   0 8px 40px rgba(0,0,0,.18);
    --radius:      12px;
}

.modal-overlay {
    position: fixed; inset: 0; z-index: 20000;
    background: rgba(15,23,42,.55); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: fadeOverlay .15s ease;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 760px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .2s ease;
    overflow: hidden;
}
@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-form-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1.5px solid var(--border);
    flex-shrink: 0;
}
.modal-form-header h2 { font-size: 1.1rem; color: var(--blue-dark); display: flex; align-items: center; gap: .5rem; }

.modal-form-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.modal-form-body::-webkit-scrollbar { width: 5px; }
.modal-form-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Escapado bajo .modal-form-body para no pisar el .form-group del modal principal de precios */
.modal-form-body .form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 0; }
.modal-form-body .form-group input {
    padding: .7rem .85rem; border: 1.5px solid var(--border); border-radius: 8px;
    font-size: .9rem; transition: border-color .15s ease;
}
.modal-form-body .form-group input:focus { outline: none; border-color: var(--blue-mid); }
.form-label {
    font-size: .8rem; font-weight: 700; color: var(--text-mid);
    display: flex; align-items: center; gap: .35rem; text-transform: uppercase; letter-spacing: .04em;
}
.form-label i { color: var(--blue-mid); }

.modal-close {
    background: none; border: none; cursor: pointer;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-mid); font-size: 1rem; transition: .18s;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

/* ── Resultados de búsqueda histórica ── */
.hist-resultados {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.hist-resultados::-webkit-scrollbar { width: 5px; }
.hist-resultados::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.hist-empty {
    display: flex; flex-direction: column; align-items: center; gap: .5rem;
    padding: 2.5rem 1rem; color: #9ca3af; text-align: center;
}
.hist-empty i { font-size: 2.2rem; opacity: .35; }
.hist-empty p { font-size: .9rem; font-weight: 600; }

.hist-summary {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; color: var(--text-mid); font-weight: 600; padding-bottom: .2rem;
}
.hist-summary i { color: var(--green); }

.hist-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-left: 5px solid var(--blue-mid);
    border-radius: 12px;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.hist-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: #cbd5e1; border-left-color: var(--blue-mid); }
.hist-card.open { border-color: var(--blue-mid); border-left-color: var(--green); box-shadow: var(--shadow-md); }

.hist-card-top {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.1rem 1.25rem 1.1rem 1.35rem;
    cursor: pointer;
    background: #fbfcfe;
    border-radius: 10px 10px 0 0;
}
.hist-card-top:hover { background: #f1f5f9; }
.hist-card-main { display: flex; align-items: center; gap: .9rem; min-width: 0; flex: 1 1 auto; }

.hist-avatar {
    flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-mid), var(--blue-dark));
    color: #fff; font-weight: 700; font-size: .95rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(37,99,235,.35);
}
.hist-caret { color: var(--blue-mid); font-size: .85rem; margin-top: 1px; transition: transform .2s ease; flex-shrink: 0; }
.hist-card.open .hist-caret { transform: rotate(90deg); color: var(--green); }

.hist-card-main > div { min-width: 0; }
.hist-proveedor {
    font-weight: 800; font-size: 1.05rem; color: var(--blue-dark); line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-meta { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .4rem; }
.hist-meta-item {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .82rem; font-weight: 600; color: var(--text-mid);
}
.hist-meta-item i { color: var(--blue-mid); font-size: .76rem; }

.hist-total {
    flex-shrink: 0;
    display: inline-flex; align-items: center;
    font-weight: 800; font-size: 1.2rem; color: #065f46;
    background: var(--green-light);
    padding: .4rem .85rem;
    border-radius: 999px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hist-lineas { padding: .2rem 1.25rem 1.1rem; display: flex; flex-direction: column; gap: .5rem; background: #fff; border-radius: 0 0 10px 10px; }
.hist-linea {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .65rem .85rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
}
.hist-linea.match { background: var(--blue-light); border-color: #93c5fd; }
.hist-linea-art { display: flex; align-items: center; gap: .6rem; min-width: 0; font-size: .9rem; color: var(--text); }
.hist-linea-cod {
    flex-shrink: 0; font-weight: 700; font-size: .78rem; color: var(--blue-mid);
    background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px;
}
.hist-linea.match .hist-linea-cod { background: var(--blue-mid); color: #fff; border-color: var(--blue-mid); }
.hist-linea-des { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-linea-datos { display: flex; gap: .75rem; font-size: .84rem; font-weight: 600; color: var(--text-mid); white-space: nowrap; flex-shrink: 0; }
.hist-linea-datos strong { color: var(--text); font-weight: 800; }

/* Más aire entre tarjetas y menos densidad general de la lista */
.hist-resultados { gap: .85rem; }
.modal-card { max-width: 820px; }
