* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navegación */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.nav-container h1 {
    font-size: 1.5rem;
    color: #ecf0f1;
    font-weight: 600;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 101;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background-color: #ecf0f1;
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
}

.nav-link {
    color: #ecf0f1;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
    display: block;
}

.nav-link:hover,
.nav-link.active {
    background-color: #34495e;
    transform: translateY(-1px);
}

/* Contenedor principal */
.container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 20px;
}

/* Formulario de factura */
.factura-form {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.05);
}

/* Header de empresa */
.header-empresa {
    border: 2px solid #2c3e50;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.empresa-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.empresa-left h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 700;
}

.empresa-left h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #34495e;
    font-weight: 600;
}

.empresa-left p {
    color: #5a6c7d;
    font-weight: 500;
}

.empresa-right {
    text-align: right;
}

.empresa-right p {
    margin-bottom: 0.3rem;
    color: #5a6c7d;
    font-weight: 500;
}

/* Minuta y fecha */
.minuta-fecha {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #fff;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

/* Sección cliente */
.cliente-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.cliente-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
}

/* Tabla de items */
.items-section {
    margin-bottom: 2rem;
}

.items-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
}

#itemsTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

#itemsTable th,
#itemsTable td {
    border: 1px solid #e1e8ed;
    padding: 0.75rem;
    text-align: center;
}

#itemsTable th {
    background-color: #2c3e50;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#itemsTable tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

#itemsTable tbody tr:hover {
    background-color: #e3f2fd;
}

#itemsTable input,
#itemsTable select {
    width: 100%;
    border: none;
    padding: 0.5rem;
    text-align: center;
    background: transparent;
    font-size: 0.9rem;
}

#itemsTable input[type="text"] {
    text-align: left;
}

#itemsTable input:focus,
#itemsTable select:focus {
    outline: 2px solid #3498db;
    border-radius: 4px;
    background-color: white;
}

.subtotal {
    font-weight: 600;
    color: #27ae60;
}

/* Botones */
.btn-add,
.btn-remove,
.btn-generate,
.btn-download,
.btn-refresh {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-height: 44px; /* Mínimo para touch targets */
}

.btn-add {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.btn-add:hover {
    background: linear-gradient(135deg, #219a52, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

.btn-remove {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    min-height: 40px;
}

.btn-remove:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-1px);
}

.btn-generate {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-size: 1.1rem;
    padding: 1.25rem 2.5rem;
    min-height: 56px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-generate:hover {
    background: linear-gradient(135deg, #2980b9, #21618c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-generate:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-preview {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    transition: all 0.3s ease;
    min-height: 40px;
}

.btn-preview:hover {
    background: linear-gradient(135deg, #138496, #117a8b);
    transform: translateY(-1px);
}

.btn-download {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    min-height: 40px;
}

.btn-download:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
}

.btn-delete {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    min-height: 40px;
}

.btn-delete:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
    transform: translateY(-1px);
}

.btn-refresh {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.btn-refresh:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    transform: translateY(-1px);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    min-height: 40px;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-1px);
}

.btn-lock {
    background: linear-gradient(135deg, #fd7e14, #e8590c);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    min-height: 40px;
    transition: all 0.3s ease;
}

.btn-lock:hover {
    background: linear-gradient(135deg, #e8590c, #d63384);
    transform: translateY(-1px);
}

.btn-unlock {
    background: linear-gradient(135deg, #20c997, #17a2b8);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    min-height: 40px;
    transition: all 0.3s ease;
}

.btn-unlock:hover {
    background: linear-gradient(135deg, #17a2b8, #138496);
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    min-height: 40px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
}

/* Totales */
.totales-section {
    border-top: 2px solid #2c3e50;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.75rem 0;
    color: #2c3e50;
}

/* Resumen */
.resumen-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #27ae60;
}

.total-final {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    text-align: center;
}

.total-final label {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 0.5rem;
}

.total-final input {
    font-size: 1.3rem;
    font-weight: 700;
    width: 200px;
    text-align: center;
    background: rgba(255,255,255,0.9);
    border: 2px solid rgba(255,255,255,0.3);
    color: #2c3e50;
}

/* Acciones del formulario */
.form-actions {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e1e8ed;
}

/* Facturas antiguas */
.facturas-antiguas {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.facturas-antiguas h2 {
    margin-bottom: 2rem;
    color: #2c3e50;
    font-weight: 600;
}

.search-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

#facturasTable {
    width: 100%;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

#facturasTable th,
#facturasTable td {
    border: 1px solid #e1e8ed;
    padding: 1rem;
    text-align: left;
}

#facturasTable th {
    background-color: #2c3e50;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

#facturasTable tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

#facturasTable tbody tr:hover {
    background-color: #e3f2fd;
}

.no-facturas {
    text-align: center;
    padding: 4rem;
    color: #6c757d;
}

.no-facturas p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90%;
    width: 800px;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e1e8ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-weight: 600;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: #000;
    background-color: rgba(0,0,0,0.1);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e1e8ed;
    text-align: right;
    background-color: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* Preview content */
#previewContent {
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

#previewContent .header {
    border: 2px solid #2c3e50;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    background-color: #f8f9fa;
}

#previewContent .header-left {
    float: left;
    width: 60%;
}

#previewContent .header-right {
    float: right;
    width: 35%;
    text-align: right;
}

#previewContent .clear {
    clear: both;
}

#previewContent .minuta-fecha {
    margin: 1.5rem 0;
}

#previewContent .minuta-fecha div {
    display: inline-block;
    margin-right: 3rem;
}

#previewContent .cliente {
    margin: 1.5rem 0;
}

#previewContent .cliente h3 {
    text-decoration: underline;
    margin-bottom: 1rem;
}

#previewContent .tabla-items {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

#previewContent .tabla-items th {
    border: 1px solid #2c3e50;
    padding: 0.75rem;
    background-color: #2c3e50;
    color: white;
}

#previewContent .tabla-items td {
    border: 1px solid #2c3e50;
    padding: 0.75rem;
}

#previewContent .totales {
    margin: 1.5rem 0;
}

#previewContent .totales div {
    margin: 0.5rem 0;
}

#previewContent .total-final {
    font-weight: bold;
    font-size: 1.2rem;
}

/* Estilos para facturas bloqueadas */
.factura-bloqueada {
    background-color: #fff3cd !important;
    border-left: 4px solid #fd7e14;
}

.factura-bloqueada:hover {
    background-color: #ffeaa7 !important;
}

.estado-bloqueada {
    color: #fd7e14;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    background-color: rgba(253, 126, 20, 0.1);
    border-radius: 4px;
    font-size: 0.85rem;
}

.estado-normal {
    color: #28a745;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    background-color: rgba(40, 167, 69, 0.1);
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Modal de contraseña */
.password-modal {
    max-width: 400px !important;
    width: 90% !important;
}

.password-form {
    text-align: center;
}

.password-form p {
    margin-bottom: 1.5rem;
    color: #495057;
    font-size: 1rem;
}

.password-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-align: center;
    font-family: monospace;
    letter-spacing: 2px;
}

.password-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.password-error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Media Queries Responsive */
@media (max-width: 1024px) {
    .container {
        max-width: 95%;
        margin: 1rem auto;
    }
    
    .factura-form {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: #2c3e50;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding: 2rem 0;
        gap: 0;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-menu li {
        margin: 0.5rem 0;
    }
    
    .nav-link {
        padding: 1rem 2rem;
        margin: 0.25rem 1rem;
        border-radius: 8px;
    }
    
    .container {
        margin: 1rem auto;
        padding: 0 15px;
    }
    
    .factura-form {
        padding: 1.5rem;
        margin: 0;
        border-radius: 8px;
    }
    
    .header-empresa {
        padding: 1rem;
    }
    
    .empresa-info {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .empresa-right {
        text-align: left;
    }
    
    .minuta-fecha {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .cliente-section {
        padding: 1rem;
    }
    
    /* Tabla responsive */
    #itemsTable {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    #itemsTable th,
    #itemsTable td {
        padding: 0.5rem 0.25rem;
        min-width: 80px;
    }
    
    #itemsTable th:first-child,
    #itemsTable td:first-child {
        min-width: 60px;
    }
    
    #itemsTable th:nth-child(2),
    #itemsTable td:nth-child(2) {
        min-width: 150px;
    }
    
    #itemsTable input {
        font-size: 0.8rem;
        padding: 0.25rem;
    }
    
    #itemsTable input[type="text"] {
        min-width: 140px;
        background-color: white;
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    
    .btn-add,
    .btn-generate {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .btn-remove {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .totales-section {
        padding: 1rem;
    }
    
    .resumen-section {
        padding: 1rem;
    }
    
    .total-final {
        padding: 1rem;
        font-size: 1.1rem;
    }
    
    .total-final input {
        width: 150px;
        font-size: 1.1rem;
    }
    
    .search-section {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-input {
        width: 100%;
    }
    
    #facturasTable {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
    }
    
    #facturasTable th,
    #facturasTable td {
        padding: 0.5rem;
        min-width: 100px;
    }
    
    .btn-lock,
    .btn-unlock {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
        margin-right: 0.25rem;
        margin-bottom: 0.25rem;
    }
    
    .modal-content {
        width: 95%;
        max-height: 85%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .nav-container h1 {
        font-size: 1.2rem;
    }
    
    .factura-form {
        padding: 1rem;
    }
    
    .header-empresa {
        padding: 0.75rem;
    }
    
    .empresa-left h2 {
        font-size: 1.1rem;
    }
    
    .empresa-left h3 {
        font-size: 1rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 0.6rem;
        font-size: 0.95rem;
    }
    
    .cliente-section,
    .resumen-section,
    .totales-section {
        padding: 0.75rem;
    }
    
    #itemsTable {
        font-size: 0.8rem;
    }
    
    #itemsTable th,
    #itemsTable td {
        padding: 0.4rem 0.2rem;
        min-width: 70px;
    }
    
    #itemsTable th:nth-child(2),
    #itemsTable td:nth-child(2) {
        min-width: 160px;
    }
    
    #itemsTable input {
        font-size: 0.75rem;
        padding: 0.2rem;
    }
    
    #itemsTable input[type="text"] {
        min-width: 150px;
        background-color: white;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 0.4rem;
    }
    
    .btn-add,
    .btn-generate {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .btn-remove {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        min-height: 36px;
    }
    
    .total-final {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .total-final label {
        font-size: 1.1rem;
    }
    
    .total-final input {
        width: 120px;
        font-size: 1rem;
    }
    
    .modal-content {
        width: 98%;
        max-height: 90%;
        margin: 0.5rem;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .close {
        font-size: 24px;
        width: 36px;
        height: 36px;
    }
}

/* Mejoras adicionales para touch */
@media (hover: none) and (pointer: coarse) {
    .btn-add:hover,
    .btn-remove:hover,
    .btn-generate:hover,
    .btn-download:hover,
    .btn-preview:hover,
    .btn-delete:hover,
    .btn-refresh:hover,
    .btn-secondary:hover,
    .nav-link:hover,
    .close:hover {
        transform: none;
    }
    
    .form-group input:focus,
    .form-group select:focus,
    .search-input:focus {
        transform: none;
    }
}

/* Animaciones suaves */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}