/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    overflow-x: hidden;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.header p {
    font-size: 1rem;
    opacity: 0.9;
}

/* Formulario principal */
.invoice-form {
    padding: 20px;
}

/* Información de la empresa */
.company-info {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 5px solid #3498db;
}

.logo-placeholder {
    min-width: 120px;
    height: 120px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.company-details h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.company-details p {
    margin-bottom: 5px;
    color: #34495e;
}

.contact-info {
    margin-top: 15px;
}

.contact-info p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.contact-info i {
    color: #3498db;
    width: 16px;
}

/* Header de factura */
.invoice-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.invoice-number {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #3498db;
}

.invoice-number label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #2c3e50;
}

.invoice-date {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
}

.invoice-date label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #2c3e50;
}

.date-picker {
    width: 100%;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    min-width: 0;
    box-sizing: border-box;
}

/* Información del cliente */
.client-info {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #2c3e50;
}

/* Inputs generales */
input[type="text"], 
input[type="number"],
input[type="date"] {
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

input[type="text"]:focus, 
input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Sección de productos */
.products-section {
    margin-bottom: 25px;
}

.products-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.table-container {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th {
    background: #34495e;
    color: white;
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid #ecf0f1;
}

td input {
    width: 100%;
    border: 1px solid #ddd;
    padding: 8px;
    border-radius: 5px;
}

.total-item {
    font-weight: bold;
    color: #27ae60;
    text-align: right;
}

/* Botones */
.btn-add {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.btn-add:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    background: #c0392b;
}

/* Total */
.total-section {
    margin-bottom: 25px;
}

.total-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    background: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 10px;
}

.total-label {
    font-size: 1.2rem;
    font-weight: bold;
}

.total-amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: #f1c40f;
}

/* Firmas */
.signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 25px;
}

.signature-box {
    text-align: center;
}

.signature-line {
    height: 60px;
    border-bottom: 2px solid #34495e;
    margin-bottom: 10px;
}

.signature-box label {
    font-weight: bold;
    color: #2c3e50;
}

/* Nota de servicio */
.service-note {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px;
    background: #f39c12;
    color: white;
    border-radius: 10px;
}

.service-note h2 {
    font-size: 1.5rem;
    letter-spacing: 2px;
}

/* Botones de acción */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

.action-buttons button {
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-preview {
    background: #3498db;
    color: white;
}

.btn-preview:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-generate {
    background: #e74c3c;
    color: white;
}

.btn-generate:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.btn-clear {
    background: #95a5a6;
    color: white;
}

.btn-clear:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.close:hover {
    color: #000;
}

#previewContent {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

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

.modal-footer .btn-generate {
    padding: 10px 20px;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        border-radius: 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .company-info {
        flex-direction: column;
        text-align: center;
    }
    
    .logo-placeholder {
        align-self: center;
    }
    
    .invoice-header {
        grid-template-columns: 1fr;
    }
    
    .client-info {
        grid-template-columns: 1fr;
    }
    

    
    .signatures {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 8px 5px;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .invoice-form {
        padding: 15px;
    }
    
    .company-info {
        padding: 15px;
    }
    
    .company-details h2 {
        font-size: 1.3rem;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 6px 3px;
    }
    
    .total-container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Estilos para impresión/PDF */
@media print {
    body * {
        visibility: hidden;
    }
    
    #previewContent, #previewContent * {
        visibility: visible;
    }
    
    #previewContent {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    
    .modal {
        position: static !important;
        background: white !important;
    }
    
    .modal-content {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    .close, .download-pdf-btn {
        display: none !important;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.invoice-form > section {
    animation: fadeIn 0.6s ease-out;
}

/* Efectos hover mejorados */
.input-group input:hover {
    border-color: #bdc3c7;
}

button:active {
    transform: translateY(0);
}

/* Indicadores visuales */
.required {
    border-left: 3px solid #e74c3c;
}

.valid {
    border-left: 3px solid #27ae60;
}
/* Estilos adicionales para modal mejorado */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

#previewContent {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

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

.modal-footer .btn-generate {
    padding: 10px 20px;
    font-size: 0.9rem;
}