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

body {
    font-family: Arial, sans-serif;
    font-size: 10pt;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #d32f2f;
    margin-bottom: 30px;
}

.form-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.form-section h2 {
    color: #d32f2f;
    margin-bottom: 15px;
    border-bottom: 2px solid #d32f2f;
    padding-bottom: 5px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input[readonly] {
    background-color: #f5f5f5;
    color: #666;
}

.producto-item {
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    background: #f9f9f9;
}

.buttons {
    text-align: center;
    margin: 20px 0;
}

.buttons button {
    background: #d32f2f;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin: 0 5px;
    font-size: 16px;
}

.buttons button:hover {
    background: #b71c1c;
}

.remision-page {
    width: 21cm;
    min-height: 29.7cm;
    margin: 0 auto;
    background: white;
    padding: 1cm;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.page-break {
    page-break-before: always;
    height: 0;
}

.remision-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    border-bottom: 3px solid #d32f2f;
    padding-bottom: 8px;
    height: 120px;
}

.logo-section {
    flex: 0 0 300px;
    display: flex;
    align-items: flex-start;
    margin-top: 13px;
}

.logo {
    max-width: 300px;
    height: auto;
    object-fit: contain;
}

.remision-info {
    text-align: right;
    flex: 1;
}

.remision-info h3 {
    color: #d32f2f;
    font-size: 24px;
    margin-bottom: 10px;
}

.remision-info div:first-of-type {
    color: #d32f2f;
}

.patient-info {
    margin-bottom: 20px;
    line-height: 1.8;
    font-size: 9pt;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 9pt;
    table-layout: fixed;
}

.products-table th,
.products-table td {
    border-top: 0.5px solid #d32f2f;
    border-bottom: none;
    border-left: none;
    border-right: none;
    padding: 7px;
    text-align: center;
    font-size: 8pt;
    height: 50px;
    overflow: hidden;
    word-wrap: break-word;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.products-table th {
    background-color: #f5f5f5;
    font-weight: bold;
    text-align: center;
    border-top: none;
}

.products-table td {
    font-size: 7pt;
}

.products-table th:nth-child(1) { width: 6%; }  /* RENG */
.products-table th:nth-child(2) { width: 10%; } /* COD */
.products-table th:nth-child(3) { width: 6%; }  /* CANT */
.products-table th:nth-child(4) { width: 6%; }  /* PTDA */
.products-table th:nth-child(5) { width: 35%; } /* DESCRIPCIÓN */
.products-table th:nth-child(6) { width: 6%; }  /* UM */
.products-table th:nth-child(7) { width: 14%; } /* PRECIO */
.products-table th:nth-child(8) { width: 12%; } /* TOTAL */

.products-table td:nth-child(2) {
    white-space: pre-line;
    word-break: break-all;
}

.products-table td:nth-child(5) {
    text-align: left;
    font-size: 6.5pt;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
}

/* Remover todos los fondos primero */
.products-table td {
    background-color: transparent !important;
}

/* Aplicar fondo solo a columnas pares */
.products-table td:nth-child(2),
.products-table td:nth-child(4),
.products-table td:nth-child(6),
.products-table td:nth-child(8) {
    background-color: #d9d9d9 !important;
}



.totals-section {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    margin-bottom: 20px;
    border-top: 3px solid #d32f2f;
    padding-top: 10px;
}

.signatures {
    text-align: left;
    line-height: 1.6;
    width: 500px;
    font-size: 9pt;
}

.totals {
    text-align: right;
    line-height: 1.6;
    min-width: 200px;
}

.company-info {
    margin-top: 60px;
    font-size: 8pt;
    line-height: 1.4;
    display: flex;
    justify-content: space-between;
}

.company-details {
    flex: 1;
    text-align: left;
}

.company-info .signatures {
    width: 200px;
    text-align: center;
}

.signatures-section {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
    margin-bottom: 20px;
    font-size: 9pt;
}

.doctor-signature,
.manager-signature {
    text-align: center;
    min-width: 200px;
    line-height: 1.6;
}

#consultaModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    background: white;
    margin: 50px auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    max-height: 80vh;
    overflow-y: auto;
}

.remision-item {
    border: 1px solid #ddd;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remision-info {
    flex: 1;
}

.remision-actions {
    display: flex;
    gap: 10px;
}

.producto-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.save-producto {
    background: #4caf50;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.save-producto:hover {
    background: #45a049;
}

.remove-producto {
    background: #f44336;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.remove-producto:hover {
    background: #d32f2f;
}

@media print {
    body {
        background: white;
    }
    
    /* Ocultar todo excepto las remisiones */
    body > *:not(#preview) {
        display: none !important;
    }
    
    .container {
        display: none !important;
    }
    
    .buttons,
    #consultaModal {
        display: none !important;
    }
    
    #preview {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .remision-page {
        box-shadow: none;
        margin: 0;
        page-break-after: always;
    }
    
    .page-break {
        page-break-before: always;
    }
    
    .no-print {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .producto-buttons {
        gap: 5px;
    }
    
    .save-producto,
    .remove-producto {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    /* Las remisiones mantienen su tamaño carta en móviles */
    .remision-page {
        width: 21cm;
        min-height: 29.7cm;
        padding: 1cm;
        overflow-x: auto;
        margin: 0 auto;
    }
    
    /* Contenedor con scroll horizontal para remisiones */
    #preview {
        overflow-x: auto;
        padding: 10px;
    }
}