:root {
    /* Main Colors (Light Modern) */
    --bg-primary: #f5f7fb;
    --accent-primary: #0ea5e9; /* turquesa-azulado */
    --text-primary: #0f172a; /* slate-900 */
    --text-secondary: #475569; /* slate-600 */
    
    /* Supporting Colors */
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --accent-hover: #38bdf8;
    --alt-bg: #f8fafc;
    
    /* Functional Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* Effects */
    --shadow: 0 8px 28px rgba(2, 6, 23, 0.08);
    --gradient-primary: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    --transition: all 0.3s ease;
    --invoice-border: #e5e7eb;
    --invoice-zebra: #f8fafc;
    --invoice-text: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    background-image: radial-gradient(circle at 25% 25%, rgba(14, 165, 233, 0.10) 0%, transparent 45%),
                      radial-gradient(circle at 75% 75%, rgba(34, 197, 94, 0.06) 0%, transparent 45%);
    background-attachment: fixed;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100px;
    height: 2px;
    background: var(--gradient-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

#logo-img {
    max-width: 200px;
    height: auto;
    border-radius: 8px;
}

.logo-text h1 {
    margin: 0;
    font-size: 24px;
    color: #0f172a;
}

.logo-text p {
    margin: 5px 0 0 0;
    font-size: 14px;
    color: #475569;
}

.document-info {
    text-align: right;
}

.document-number {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 5px 0;
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(8, 253, 216, 0.3);
    letter-spacing: 1px;
}

.date {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Form Styles */
.form-group {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.98rem;
    color: var(--text-primary);
    transition: var(--transition);
    box-shadow: inset 0 1px 2px rgba(2, 6, 23, 0.04);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(8, 253, 216, 0.2);
    background: rgba(8, 253, 216, 0.03);
}

/* Invoice (Light Modern) */
.invoice {
    background: #ffffff;
    color: var(--invoice-text);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border: 1px solid var(--invoice-border);
    font-family: 'Poppins', Arial, sans-serif;
}

.invoice-header {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--success-color) 100%);
    color: #fff;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    box-shadow: 0 6px 18px rgba(14,165,233,.25);
}

.invoice-brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.invoice-title {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: .2px;
}

.invoice-subtitle {
    font-size: 12px;
    opacity: .9;
}

.invoice-badge {
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.35);
    padding: 6px 10px;
    border-radius: 999px;
    margin-bottom: 6px;
}

.invoice-number {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .5px;
}

.invoice-grid {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.invoice-client {
    flex: 1;
}

.invoice-client-box {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--invoice-border);
    border-radius: 10px;
    padding: 10px;
}

.invoice-client-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
}

.invoice-summary {
    width: 220px;
}

.invoice-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 16px;
    border: 1px solid var(--invoice-border);
    border-radius: 12px;
    overflow: hidden;
}

.invoice-table thead th {
    text-align: left;
    background: #ecfeff;
    color: var(--accent-primary);
    border-bottom: 1px solid var(--invoice-border);
    padding: 10px 8px;
}

.invoice-table tbody td {
    padding: 10px 8px;
}

.invoice-table tbody tr:nth-child(odd) {
    background: var(--invoice-zebra);
}

.invoice-totals {
    display: flex;
    justify-content: flex-end;
}

.invoice-card {
    width: 280px;
    background: #f7f9ff;
    border: 1px solid #dfe3f6;
    border-left: 4px solid var(--accent-primary);
    border-radius: 12px;
    padding: 10px;
}

.invoice-line {
    display: flex;
    justify-content: space-between;
    padding: 4px 2px;
}

.invoice-total {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 2px;
    font-weight: 800;
    border-top: 1px dashed var(--invoice-border);
    color: var(--accent-primary);
    font-size: 18px;
}

/* Items Section */
.items-section {
    margin: 30px 0;
}

.items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 50px;
    gap: 18px;
    font-weight: 600;
    padding: 16px;
    background: #ffffff;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    letter-spacing: 0.5px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 50px;
    gap: 18px;
    align-items: center;
    padding: 16px;
    margin: 8px 0;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.item-row:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08);
}

.item-row input {
    width: 100%;
    padding: 8px 12px;
}

.remove-item {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.remove-item:hover {
    transform: scale(1.1);
}

/* Payment Info */
.payment-info {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
    margin: 30px 0;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
}

.payment-details {
    flex: 1;
    max-width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
}

.totals {
    flex: 1;
    max-width: 300px;
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.total-row:last-child {
    border-bottom: none;
}

.total {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-shadow: 0 0 10px rgba(8, 253, 216, 0.3);
}

/* Notes Section */
.notes {
    margin: 30px 0;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    border-left: 4px solid var(--accent-primary);
    position: relative;
    overflow: hidden;
}

.notes::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-primary);
}

.notes h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.notes p {
    margin-bottom: 10px;
}

.notes input[type="text"] {
    background: white;
    border: 1px dashed var(--border-color);
    padding: 5px 10px;
    margin: 0 5px;
    width: auto;
    display: inline-block;
    color: #000;
}

/* Placeholder visible en inputs de notas */
.notes input[type="text"]::placeholder {
    color: #555;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: rgba(8, 253, 216, 0.1);
    transition: var(--transition);
    z-index: -1;
}

.btn:hover::before {
    width: 100%;
}

.btn:hover {
    background: #f1f5f9;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: var(--bg-primary);
    font-weight: 600;
    border: none;
    box-shadow: 0 4px 15px rgba(8, 253, 216, 0.3);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(8, 253, 216, 0.4);
}

.btn.primary::before {
    display: none;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 18px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

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

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    width: 80%;
    max-width: 900px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h1,
.modal-content h2,
.modal-content h3,
.modal-content h4,
.modal-content h5,
.modal-content h6 {
    color: var(--accent-primary);
}

.close {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: var(--error-color);
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
        background: white !important;
        color: #000 !important;
    }
    
    #preview-content,
    #preview-content * {
        visibility: visible;
        color: #000 !important;
        background: white !important;
    }
    
    #preview-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 20px;
        box-shadow: none !important;
        border: none !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    .btn {
        display: none !important;
    }
    
    .container {
        box-shadow: none !important;
        border: none !important;
    }
}

/* Responsive Design */
.payment-details .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}

.payment-details label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.payment-details input,
.payment-details select {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.92rem;
}

.payment-details #metodo-pago {
    min-width: 0;
}

@media (max-width: 992px) {
    .container {
        padding: 20px;
    }
    
    header {
        flex-direction: column;
        gap: 20px;
    }
    
    .document-info {
        text-align: left;
        width: 100%;
    }
    
    .payment-info {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .payment-details,
    .totals {
        max-width: 100%;
    }
    
    .items-header,
    .item-row {
        grid-template-columns: 2fr 1fr 1fr 1fr 40px;
        font-size: 0.9rem;
    }
    
    .actions {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .btn {
        flex: 1 1 45%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .form-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .items-header,
    .item-row {
        grid-template-columns: 2fr 1fr 1fr 1fr 30px;
        font-size: 0.8rem;
        gap: 8px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px 15px;
    }
}

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

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(8, 253, 216, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(8, 253, 216, 0); }
    100% { box-shadow: 0 0 0 0 rgba(8, 253, 216, 0); }
}

@keyframes glow {
    0% { text-shadow: 0 0 5px rgba(8, 253, 216, 0.5); }
    50% { text-shadow: 0 0 20px rgba(8, 253, 216, 0.8); }
    100% { text-shadow: 0 0 5px rgba(8, 253, 216, 0.5); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.glow {
    animation: glow 2s infinite;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(16, 22, 36, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.small {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.text-right {
    text-align: right;
}

.text-accent {
    color: var(--accent-primary) !important;
}

.bg-accent {
    background: var(--gradient-primary) !important;
}

.mt-1 { margin-top: 5px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }

/* Custom Checkbox */
input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: var(--transition);
}

input[type="checkbox"]:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: var(--bg-primary);
    font-size: 14px;
    font-weight: bold;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Custom Select */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2308FDD8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    color: var(--text-primary);
}

/* Asegura que el texto sea legible en el desplegable del select */
select option,
select optgroup {
    background-color: #ffffff;
    color: #000000;
}

/* Tooltip */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 5px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: var(--border-color) transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 5px);
}

[data-tooltip]:hover::before {
    bottom: 100%;
}
