/* =============================================================================
   CLEAN STYLES - Only Used Elements
   ============================================================================= */

/* Global Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    line-height: 1.6;
    color: #333;
}

/* =============================================================================
   NAVIGATION STYLES
   ============================================================================= */

.header-nav {
    background: linear-gradient(135deg, #2e7bc6 0%, #1e5a96 100%);
    color: white;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px; /* Added spacing after top menu */
}

.nav-items {
    display: flex;
    gap: 35px;
    align-items: center;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    padding: 8px 12px;
    transition: all 0.3s ease;
    border-radius: 6px;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.iconox2 {
    width: 32px;  /* Enhanced icon size */
    height: 32px; /* Enhanced icon size */
    margin-bottom: 6px;
    fill: white;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* =============================================================================
   MAIN LAYOUT STYLES
   ============================================================================= */

.main-container {
    display: flex;
    min-height: calc(100vh - 100px); /* Adjusted for new spacing */
    background-color: #ffffff;
    gap: 20px; /* Added gap between sidebar and main content */
    padding: 0 20px; /* Added horizontal padding */
}

.sidebar {
    width: 200px;
    background-color: white;
    border-right: 1px solid #e0e0e0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    border-radius: 8px; /* Rounded corners */
    height: fit-content; /* Don't stretch to full height */
}

.planificador-header {
    background: linear-gradient(135deg, #2e7bc6 0%, #1e5a96 100%);
    color: white;
    padding: 15px 18px; /* Increased padding */
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 8px 8px 0 0; /* Rounded top corners */
    margin-bottom: 5px; /* Small gap before menu items */
}

.sidebar-menu {
    padding: 20px 0;
}

.menu-item {
    display: block;
    padding: 12px 18px;
    font-size: 13px;
    color: #495057;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    text-decoration: none;
}

.menu-item:hover {
    background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 100%);
    color: #2e7bc6;
    padding-left: 25px;
}

.menu-item.active {
    background: linear-gradient(90deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    font-weight: 600;
    border-left: 4px solid #2e7bc6;
}

/* Asegurar que los enlaces se vean igual que los divs */
a.menu-item {
    color: #495057;
}

a.menu-item:hover {
    color: #2e7bc6;
}

.main-content {
    flex: 1;
    padding: 0;
    background-color: white;
    border-radius: 8px; /* Rounded corners */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* Subtle shadow */
    height: fit-content; /* Don't stretch to full height */
}

.content-header {
    background: linear-gradient(135deg, #2e7bc6 0%, #1e5a96 100%);
    color: white;
    padding: 20px 25px; /* Increased padding for more spacing */
    font-size: 18px; /* Slightly larger font */
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 8px 8px 0 0; /* Rounded top corners */
    margin-bottom: 10px; /* Added space before content body */
}

.content-body {
    padding: 30px;
    background-color: white;
    border-radius: 0 0 8px 8px; /* Rounded bottom corners */
}

.description {
    margin-bottom: 25px;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.6;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left-color: #28a745;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left-color: #dc3545;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left-color: #17a2b8;
}

.resultado-envio {
    margin: 5px 0;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.filters-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-input {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    min-width: 120px;
    transition: all 0.3s ease;
}

.filter-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-clear-filters {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    margin-top: 18px; /* Alinear con los inputs */
}

.btn-clear-filters:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Responsive para filtros */
@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .filters-section {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .filter-group {
        flex: 1;
        min-width: 120px;
    }
    
    .facturas-counter {
        text-align: center;
        padding: 10px;
        background: #f8f9fa;
        border-radius: 6px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 15px;
    }
    
    .left-actions, .right-actions {
        width: 100%;
        justify-content: center;
    }
}

.facturas-counter {
    color: #666;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    color: #333;
    margin-bottom: 10px;
}

.empty-state p {
    color: #666;
    margin: 0;
}

/* Table Styles */
.facturas-table {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 25px;
}

.table-header, .table-row {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.table-header {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.table-row:hover {
    background: #f8f9fa;
}

.table-cell {
    flex: 1;
    padding: 0 10px;
}

.checkbox-cell {
    flex: 0 0 40px;
    display: flex;
    justify-content: center;
}

.checkbox-cell input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-disabled {
    color: #ccc;
    font-weight: bold;
}

/* Status badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Estado 1 - Pendiente */
.status-pending {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Estado 2 - Enviada */
.status-sent {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Estado 3 - Revisar */
.status-review {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Estado 4 - Cerrada */
.status-closed {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Estado desconocido */
.status-unknown {
    background: #e2e3e5;
    color: #495057;
    border: 1px solid #ced4da;
}

.status-local {
    background: #fff3cd;
    color: #856404;
}

/* =============================================================================
   BOTONES DE ACCIÓN EN TABLA
   ============================================================================= */

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-close {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.btn-close:hover {
    background: linear-gradient(135deg, #218838, #1ea085);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.3);
}

.action-info {
    color: #6c757d;
    font-size: 0.8rem;
    font-style: italic;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.left-actions {
    display: flex;
    gap: 15px;
}

.right-actions {
    display: flex;
    gap: 15px;
}

.btn-send-verifactu {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-send-verifactu:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.btn-send-verifactu:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-send-bulk {
    background: linear-gradient(135deg, #fd7e14, #e63946);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.btn-send-bulk:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(253, 126, 20, 0.3);
}

.btn-send-bulk:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Resultados de envío mejorados */
.envio-summary {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    color: #0066cc;
}

.resultados-detalle {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    background: #f8f9fa;
}

.resultado-envio {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    background: white;
    border-left: 4px solid #ddd;
}

.resultado-exito {
    border-left-color: #28a745;
    background: #f8fff9;
}

.resultado-error {
    border-left-color: #dc3545;
    background: #fff8f8;
}

.resultado-icon {
    font-size: 18px;
    line-height: 1;
    margin-top: 2px;
}

.resultado-info {
    flex: 1;
    min-width: 0;
}

.resultado-details {
    margin-top: 6px;
    font-size: 0.9em;
    color: #666;
}

.resultado-details code {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.resultado-error-msg {
    margin-top: 4px;
    color: #dc3545;
    font-size: 0.9em;
}

.url-link {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.url-link:hover {
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 80%;
    max-width: 800px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close:hover {
    transform: scale(1.2);
}

.factura-form {
    padding: 30px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.cliente-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.cliente-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

.total-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

.total-display {
    font-size: 1.2rem;
    color: #333;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* =============================================================================
   BOTÓN AÑADIR FACTURA - DISEÑO MINIMALISTA MODERNO
   ============================================================================= */

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    border: 2px solid transparent;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 13px;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
    transition: all 0.1s ease;
}

.btn-primary svg {
    width: 18px;
    height: 18px;
    transition: all 0.3s ease;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.btn-primary:hover svg {
    transform: rotate(90deg) scale(1.2);
}

.btn-primary:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

/* Animación de pulso sutil para llamar la atención */
@keyframes pulse-subtle {
    0% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2); }
    50% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
    100% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2); }
}

.btn-primary:not(:hover):not(:active) {
    animation: pulse-subtle 3s ease-in-out infinite;
}

/* =============================================================================
   DOWNLOAD XML BUTTON STYLES - REFINED MINIMAL
   Matches the app's minimal buttons while remaining distinct for download action
   ============================================================================= */

.btn-download-xml {
    background: #fff;
    color: #2c7be5;
    border: 1px solid rgba(44, 123, 229, 0.14);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.18s ease, transform 0.12s ease, background-color 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.04);
    line-height: 1;
}

.btn-download-xml svg { /* keep icon aligned and small */
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex: 0 0 16px;
    transition: transform 0.16s ease;
}

.btn-download-xml:hover {
    background: #f4f9ff;
    border-color: rgba(44, 123, 229, 0.28);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(44, 123, 229, 0.08);
}

.btn-download-xml:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(16, 24, 40, 0.06);
}

.btn-download-xml:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.12);
    border-color: rgba(44, 123, 229, 0.36);
}

.btn-download-xml[disabled], .btn-download-xml:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* subtle hover lift for the icon */
.btn-download-xml:hover svg { transform: translateY(2px); }
