* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.container {
    max-width: 1300px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    background: white;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    max-height: 95vh;
}

/* PANEL IZQUIERDO - FORMULARIO */
.left-panel {
    padding: 35px 40px;
    background: #ffffff;
    overflow-y: auto;
}

.header {
    margin-bottom: 25px;
}

.header h1 {
    font-size: 22px;
    font-weight: 400;
    color: #000000;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.header p {
    font-size: 12px;
    color: #666666;
    font-weight: 400;
}

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

.section-title {
    font-size: 11px; 
    color: #000000;
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

label {
    font-size: 10px;
    font-weight: 500;
    color: #333333;
    margin-bottom: 6px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="email"],
input[type="number"],
select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cccccc;
    border-radius: 0;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    background: white;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #000000;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.btn-submit {
    width: 100%;
    padding: 13px 24px;
    background: #000000;
    color: white;
    border: none;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 15px;
}

.btn-submit:hover {
    background: #333333;
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.right-panel .btn-submit {
    margin-top: 0;
    padding: 15px 24px;
    font-size: 12px;
}

.right-panel .loading {
    margin-top: 20px;
    padding: 15px;
}

.required {
    color: #d73a49;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #f0f0f0;
    border-top: 3px solid #000000;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* PANEL DERECHO - PREVIEW */
.right-panel {
    background: #f8f8f8;
    padding: 35px 40px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
}

.preview-header {
    text-align: center;
    margin-bottom: 25px;
}

.preview-title {
    font-size: 10px;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.preview-ticket {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-weight: 500;
}

.preview-ticket span {
    font-weight: 700;
    color: #000;
}

.preview-content {
    flex: 1;
}

.preview-section {
    background: white;
    padding: 20px;
    border: 1px solid #e0e0e0;
}

.preview-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.preview-section-title {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999999;
    font-weight: 600;
}

/* BOTÓN AGREGAR */
.btn-agregar {
    padding: 6px 12px;
    background: #000;
    color: #fff;
    border: none;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-agregar:hover {
    background: #333;
}

/* MENSAJE VACÍO */
.mensaje-vacio {
    text-align: center;
    padding: 30px 20px;
    color: #999;
    font-size: 12px;
    font-style: italic;
}

/* LÍNEAS DE PRODUCTOS */
#lineasContainer {
    margin-bottom: 15px;
}

.linea-producto {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.linea-producto:last-child {
    border-bottom: none;
}

.campo-descripcion {
    flex: 1;
    min-width: 0;
    padding: 6px 8px !important;
    font-size: 11px !important;
    border: 1px solid #ddd !important;
}

.campo-tipo {
    width: 65px !important;
    flex: none !important;
    padding: 6px 2px !important;
    font-size: 10px !important;
    border: 1px solid #ddd !important;
}

.campo-numero {
    width: 35px !important;
    flex: none !important;
    padding: 6px 4px !important;
    font-size: 11px !important;
    border: 1px solid #ddd !important;
    text-align: center;
}

.campo-precio {
    width: 85px !important;
    flex: none !important;
    padding: 6px 6px !important;
    font-size: 11px !important;
    border: 1px solid #ddd !important;
    text-align: right;
}

.campo-precio::-webkit-outer-spin-button,
.campo-precio::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.campo-precio[type=number] {
    -moz-appearance: textfield;
}

.campo-iva {
    width: 50px !important;
    flex: none !important;
    padding: 6px 6px !important;
    font-size: 11px !important;
    border: 1px solid #ddd !important;
    text-align: right;
}

.campo-total {
    width: 60px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #000;
}

.btn-eliminar {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-eliminar:hover {
    color: #000;
}

/* TOTALES */
.preview-totales {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    margin-top: 10px;
}

.preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
}

.preview-label {
    color: #666666;
    font-weight: 400;
    font-size: 11px;
}

.preview-value {
    color: #000000;
    font-weight: 500;
    font-size: 11px;
}

.preview-total {
    background: #000000;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    margin-bottom: 15px;
}

.preview-total-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.preview-total-amount {
    font-size: 15px;
    font-weight: 500;
}

.action-separator {
    height: 1px;
    background: #e0e0e0;
    margin: 0 0 20px 0;
}

/* ALERTAS */
.alert {
    padding: 12px 16px;
    margin-bottom: 15px;
    border-radius: 0;
    display: none;
    font-size: 11px;
    border-left: 3px solid;
}

.alert-success {
    background-color: #f0f8f0;
    border-left-color: #28a745;
    color: #0d5025;
}

.alert-error {
    background-color: #fff5f5;
    border-left-color: #d73a49;
    color: #86181d;
}

/* RESPONSIVE */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        max-height: none;
    }

    .right-panel {
        border-left: none;
        border-top: 1px solid #e0e0e0;
    }

    .left-panel,
    .right-panel {
        padding: 40px 30px;
    }
}

@media (max-width: 768px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .left-panel,
    .right-panel {
        padding: 30px 20px;
    }

    .header h1 {
        font-size: 20px;
    }
    
    .linea-producto {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 0;
    }
    
    .campo-descripcion {
        width: calc(100% - 83px) !important;
        flex: 0 0 calc(100% - 83px);
        order: 1;
    }
    
    .campo-tipo {
        width: 75px !important;
        flex: 0 0 75px;
        order: 2;
    }
    
    .campo-numero {
        width: 40px !important;
        flex: 0 0 100%;
        max-width: 40px;
        order: 3;
    }
    
    .campo-precio {
        flex: 1 !important;
        width: auto !important;
        min-width: 60px !important;
        order: 4;
    }
    
    .campo-iva {
        width: 55px !important;
        flex: 0 0 55px;
        order: 5;
    }
    
    .campo-total {
        width: 55px !important;
        flex: 0 0 55px;
        order: 6;
    }
    
    .btn-eliminar {
        order: 7;
        width: 24px !important;
        flex: 0 0 24px;
    }
}
