:root {
    --primary: #0a4d68;
    --primary-light: #088395;
    --secondary: #05bfdb;
    --accent: #ffd800;
    --success: #00b09b;
    --bg-dark: #001220;

    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);

    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #cbd5e1;

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
}

/* Background */
.background-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('https://images.unsplash.com/photo-1586528116311-ad8ed74514f4?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80') center/cover no-repeat;
    z-index: -2;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(10, 77, 104, 0.85) 0%, rgba(0, 18, 32, 0.85) 100%);
    z-index: -1;
}

/* Layout Container */
.app-container {
    width: 100%;
    max-width: 1300px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInDown 0.8s ease-out;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    background: linear-gradient(135deg, var(--secondary), var(--primary-light));
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 15px rgba(5, 191, 219, 0.4);
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.app-header p {
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: 300;
}

.actions {
    display: flex;
    gap: 1rem;
}

/* Top Info Bar */
.top-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 18, 32, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.currency-rates {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.rate-item {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rate-item i {
    color: var(--secondary);
    font-size: 1.3rem;
}

.bcv-link {
    color: #0aff0a;
    text-decoration: none;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    border: 1px solid #0aff0a;
    border-radius: 6px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.bcv-link:hover {
    background: #0aff0a;
    color: var(--bg-dark);
    box-shadow: 0 0 10px rgba(10, 255, 10, 0.5);
}

/* Fluorescent Clock */
.clock-container {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.fluorescent {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: #4ffb4f;
    text-shadow: 0 0 5px #0aff0a, 0 0 10px #0aff0a, 0 0 20px #028a0f;
    letter-spacing: 2px;
}

.fluorescent-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #a3e635;
    font-weight: 600;
    text-shadow: 0 0 5px #84cc16;
    text-transform: capitalize;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(to right, #00b09b, #96c93d);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 176, 155, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 176, 155, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.btn-calculate {
    background: var(--primary);
    color: white;
    width: 100%;
    justify-content: center;
    padding: 1rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.btn-calculate:hover {
    background: var(--primary-light);
}

/* Main Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 2rem;
    animation: fadeIn 1s ease-out;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.8rem;
    box-shadow: var(--glass-shadow);
}

.card-header {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.card-header h2 {
    font-size: 1.3rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form Styles */
.valuation-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(8, 131, 149, 0.15);
}

.input-wrapper .prefix,
.input-wrapper .suffix {
    background: #f1f5f9;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    border-right: 1px solid var(--border-color);
}

.input-wrapper .suffix {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.input-wrapper input {
    flex: 1;
    border: none;
    padding: 0.75rem;
    font-size: 1rem;
    outline: none;
    width: 100%;
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.result-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 0;
    overflow: hidden;
    background: transparent;
    box-shadow: none;
    border: none;
}

.summary-box {
    background: var(--glass-bg);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.summary-box:hover {
    transform: translateY(-5px);
}

.summary-box.highlight {
    background: linear-gradient(135deg, var(--primary), var(--bg-dark));
    color: white;
}

.summary-box h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.summary-box.highlight h3 {
    color: #cbd5e1;
}

.summary-box .amount {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.summary-box.highlight .amount {
    color: var(--accent);
}

.summary-box .amount-bs {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

.summary-box.highlight .amount-bs {
    color: white;
}

/* Table breakdown */
.table-responsive {
    overflow-x: auto;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.breakdown-table th {
    background: #f8fafc;
    color: var(--text-main);
    font-weight: 600;
    text-align: right;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.breakdown-table th:first-child {
    text-align: left;
}

.breakdown-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid #e2e8f0;
}

.breakdown-table td:first-child {
    text-align: left;
    font-weight: 500;
}

.sub-row td {
    color: var(--text-muted);
}

.tax-row td {
    color: var(--primary);
}

.tax-row td:first-child {
    padding-left: 2rem;
    position: relative;
}

.tax-row td:first-child::before {
    content: "↳";
    position: absolute;
    left: 0.8rem;
    color: var(--text-muted);
}

.total-row {
    background: #f1f5f9;
}

.total-row td {
    font-weight: 700;
    color: var(--text-main);
}

.breakdown-table tfoot td {
    padding: 1.2rem 1rem;
    border-top: 2px solid var(--text-main);
    font-weight: 700;
    font-size: 1.1rem;
}

.grand-total {
    color: var(--primary);
}

/* Footer */
.app-footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-top: auto;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Print Specific */
@media print {
    body {
        background: white;
        color: black;
    }

    .background-image,
    .background-overlay,
    .app-header .actions,
    .no-print,
    .app-footer {
        display: none !important;
    }

    .content-grid {
        display: block;
    }

    .glass-card {
        border: none;
        box-shadow: none;
        background: white;
        padding: 0;
    }

    #report-container {
        width: 100%;
    }

    .summary-box {
        border: 1px solid #ccc;
        background: white;
        color: black;
    }

    .summary-box.highlight {
        background: #f0f0f0;
        color: black;
    }

    .summary-box.highlight .amount {
        color: black;
    }

    .summary-box.highlight h3,
    .summary-box.highlight .amount-bs {
        color: black;
    }

    /* We inject a custom header for print */
    .results-section::before {
        content: "Módulo de Valoración Aduanal - Reporte";
        display: block;
        font-size: 1.8rem;
        font-weight: bold;
        text-align: center;
        margin-bottom: 2rem;
        border-bottom: 2px solid black;
        padding-bottom: 10px;
    }
}

/* Custom UI Fixes */
#btn-reset {
    background: #000 !important;
    color: #ffd800 !important;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

#btn-reset i {
    color: #ffd800 !important;
}

#btn-reset:hover {
    background: #333 !important;
}

/* History List Styles */
.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
}

.history-list li {
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.history-date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-desc {
    font-weight: 600;
    color: var(--primary);
    display: block;
    margin-bottom: 0.2rem;
}

/* Modals for Arancel Database */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 18, 32, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.custom-modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.custom-modal .modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.tag-regimen {
    background: #ef4444;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    margin-right: 3px;
    display: inline-block;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .input-section {
        max-width: 600px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .header-content {
        flex-direction: column;
    }

    .top-info-bar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .clock-container {
        text-align: center;
    }

    .currency-rates {
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .result-summary {
        grid-template-columns: 1fr;
    }

    .actions {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        justify-content: center;
    }

    .desktop-actions {
        display: none !important;
    }

    .mobile-actions {
        display: flex !important;
        flex-direction: column;
        gap: 15px;
        margin-top: 25px;
        padding: 15px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        width: 100%;
    }
}

.mobile-actions {
    display: none;
}