/* ═══════════════════════════════════════════════════════════
   NF-e Validator - Financial Editorial Aesthetic
   Refined, professional design for tax compliance
   ═══════════════════════════════════════════════════════════ */

body.page-nfe-validator {
    --paper: #FAF9F5;
    --paper-muted: #F0EEE6;
    --paper-deep: #E8E6DC;
    --surface: #FFFFFF;
    --ink: #141413;
    --ink2: #3D3D3A;
    --ink-muted: #5E5D59;
    --ink-faint: #B0AEA5;
    --accent-base: #0F766E;
    --accent-hover: #115E59;
    --accent-subtle: rgba(15, 118, 110, 0.08);
    --border-subtle: rgba(20, 20, 19, 0.10);
    --border-medium: rgba(20, 20, 19, 0.15);
    --font-display: "Sora", system-ui, sans-serif;
    --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-mono: "SF Mono", Monaco, Consolas, monospace;
    --bg-primary: var(--paper);
    --bg-elevated: var(--paper-muted);
    --bg-card: var(--surface);
    --text-primary: var(--ink);
    --text-secondary: var(--ink2);
    --text-tertiary: var(--ink-muted);
    --border: var(--border-subtle);
    --border-hover: var(--border-medium);
    --accent: var(--accent-base);
    --accent-hover: #115E59;
    --focus-ring: rgba(15, 118, 110, 0.28);
    background: var(--paper);
    color: var(--ink);
}

/* Page-scoped tokens (instead of :root) */
.nfe-validator-section {
    --fiscalia-teal: var(--accent-base);
    --fiscalia-teal-deep: var(--accent-hover);
    --fiscalia-teal-light: #2a9f93;
    --success-green: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --error-red: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.08);
    --warning-amber: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --surface-primary: var(--surface);
    --surface-secondary: var(--paper-muted);
    --surface-elevated: var(--surface);
    --text-primary: var(--ink);
    --text-secondary: var(--ink2);
    --text-tertiary: var(--ink-muted);
    --border-color: var(--border-subtle);
    --shadow-sm: 0 1px 2px rgba(20, 20, 19, 0.05);
    --shadow-md: 0 6px 18px rgba(20, 20, 19, 0.08);
    --shadow-lg: 0 12px 28px rgba(20, 20, 19, 0.12);

    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 2rem;
    animation: nfe-fadeIn 0.4s ease-out;
    font-family: var(--font-body);
}

@keyframes nfe-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────────────────────
   Header with Elegant Typography
   ───────────────────────────────────────────────────────── */
.nfe-header {
    margin-bottom: 3rem;
    text-align: center;
}

.nfe-header h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.nfe-description {
    color: var(--text-secondary);
    font-size: 1.0625rem;
    line-height: 1.7;
    max-width: 720px;
    margin: 0 auto;
}

.nfe-description strong {
    color: var(--fiscalia-teal-deep);
    font-weight: 600;
}

/* ─────────────────────────────────────────────────────────
   Upload Area - Premium Card Design
   ───────────────────────────────────────────────────────── */
.nfe-upload-container {
    background: var(--surface-elevated);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 4rem 3rem;
    text-align: center;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.nfe-upload-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 0%, rgba(15, 118, 110, 0.06), transparent 70%);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.nfe-upload-container:hover::before {
    opacity: 1;
}

.nfe-upload-container:hover {
    border-color: var(--fiscalia-teal);
    background: var(--surface-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.nfe-upload-container.dragover {
    border-color: var(--fiscalia-teal-deep);
    background: var(--surface-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.nfe-upload-container.has-file {
    border-color: var(--fiscalia-teal);
    border-style: solid;
    background: linear-gradient(135deg, var(--surface-elevated) 0%, rgba(15, 118, 110, 0.03) 100%);
}

.upload-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    color: var(--fiscalia-teal);
    opacity: 0.9;
    transition: all 0.3s ease;
}

.nfe-upload-container:hover .upload-icon {
    transform: translateY(-4px);
    opacity: 1;
}

.upload-text {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-family: var(--font-display);
}

.upload-filename {
    font-size: 0.9375rem;
    color: var(--fiscalia-teal-deep);
    font-weight: 600;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent-subtle);
    border-radius: 8px;
    display: inline-block;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* ─────────────────────────────────────────────────────────
   Validation Button - Premium CTA
   ───────────────────────────────────────────────────────── */
.validate-btn {
    background: var(--fiscalia-teal);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem 3rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 200ms ease, transform 120ms ease, box-shadow 200ms ease;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.18);
    position: relative;
    overflow: hidden;
    font-family: var(--font-display);
}

.validate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.validate-btn:hover:not(:disabled)::before {
    left: 100%;
}

.validate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: var(--fiscalia-teal-deep);
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.25);
}

.validate-btn:focus-visible {
    outline: 2px solid var(--fiscalia-teal);
    outline-offset: 4px;
}

.validate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.validate-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.validate-btn.loading {
    color: transparent;
}

.validate-btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: nfe-spin 0.7s linear infinite;
}

@keyframes nfe-spin {
    to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────
   Results Section - Staggered Reveal
   ───────────────────────────────────────────────────────── */
.nfe-results {
    display: none;
    margin-top: 3rem;
}

.nfe-results.show {
    display: block;
}

.nfe-results > * {
    animation: nfe-slideUp 0.5s ease-out backwards;
}

.nfe-results > *:nth-child(1) { animation-delay: 0.05s; }
.nfe-results > *:nth-child(2) { animation-delay: 0.1s; }
.nfe-results > *:nth-child(3) { animation-delay: 0.15s; }
.nfe-results > *:nth-child(4) { animation-delay: 0.2s; }
.nfe-results > *:nth-child(5) { animation-delay: 0.25s; }

@keyframes nfe-slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─────────────────────────────────────────────────────────
   Result Header - Status Card
   ───────────────────────────────────────────────────────── */
.result-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: var(--surface-elevated);
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.result-status {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.result-status.valid {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}

.result-status.invalid {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
}

.result-status svg {
    width: 32px;
    height: 32px;
}

.result-info h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
}

.result-info p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin: 0;
    font-family: var(--font-body);
}

/* ─────────────────────────────────────────────────────────
   Summary Cards - Data Grid
   ───────────────────────────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.summary-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--fiscalia-teal), rgba(15, 118, 110, 0.3));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}

.summary-card:hover::before {
    transform: scaleX(1);
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.summary-card:focus-within {
    outline: 2px solid var(--fiscalia-teal);
    outline-offset: 4px;
}

.summary-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--fiscalia-teal-deep);
    margin-bottom: 0.5rem;
    line-height: 1;
    font-family: var(--font-display);
}

.summary-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─────────────────────────────────────────────────────────
   Validation Sections - Clean Card Layout
   ───────────────────────────────────────────────────────── */
.validation-section {
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.validation-section:focus-within {
    border-color: var(--border-hover);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.validation-section h4 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 1.5rem 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ─────────────────────────────────────────────────────────
   Item Validation - Left Border Accent
   ───────────────────────────────────────────────────────── */
.item-validation {
    border-left: 4px solid var(--border-color);
    padding-left: 1.25rem;
    margin-bottom: 1.75rem;
    transition: all 0.3s ease;
}

.item-validation:focus-within {
    border-left-color: var(--fiscalia-teal);
}

.item-validation.valid {
    border-left-color: var(--success-green);
}

.item-validation.invalid {
    border-left-color: var(--error-red);
}

.item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
    flex-wrap: wrap;
}

.item-badge {
    background: var(--fiscalia-teal);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.item-ncm {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.875rem;
    background: var(--surface-secondary);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
}

.item-description {
    color: var(--text-primary);
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.error-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0 0;
}

.error-item {
    padding: 0.875rem 1rem;
    background: var(--error-bg);
    border-radius: 8px;
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-left: 3px solid var(--error-red);
}

.error-field {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--error-red);
}

.warning-item {
    padding: 0.875rem 1rem;
    background: var(--warning-bg);
    border-radius: 8px;
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-left: 3px solid var(--warning-amber);
}

.warning-field {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--warning-amber);
}

/* ─────────────────────────────────────────────────────────
   Discrepancy Table - Professional Data Display
   ───────────────────────────────────────────────────────── */
.discrepancy-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.discrepancy-table:focus-within {
    border-color: var(--border-hover);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.discrepancy-table th {
    background: var(--surface-secondary);
    padding: 1rem 0.875rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.75rem;
}

.discrepancy-table td {
    padding: 1rem 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.discrepancy-table tr:last-child td {
    border-bottom: none;
}

.discrepancy-table tbody tr {
    transition: background 0.2s ease;
}

.discrepancy-table tbody tr:hover {
    background: var(--surface-secondary);
}

.value-expected {
    color: var(--success-green);
    font-family: var(--font-mono);
    font-weight: 600;
}

.value-calculated {
    color: var(--error-red);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ─────────────────────────────────────────────────────────
   CORRECTION SECTION - HERO TREATMENT
   This is the main value proposition!
   ───────────────────────────────────────────────────────── */
#correction-section {
    background: var(--success-bg);
    border: 2px solid var(--success-green);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.15);
    position: relative;
    overflow: hidden;
}

#correction-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(5, 150, 105, 0.08) 0%, transparent 70%);
    border-radius: 50%;
}

#correction-section h4 {
    font-size: 1.5rem;
    color: #065f46;
    margin-bottom: 1.5rem;
}

.correction-success-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.correction-icon {
    width: 48px;
    height: 48px;
    background: var(--success-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.correction-icon svg {
    width: 28px;
    height: 28px;
}

.correction-message {
    flex: 1;
}

.correction-message h5 {
    margin: 0 0 0.25rem 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #065f46;
}

.correction-message p {
    margin: 0;
    font-size: 0.9375rem;
    color: #059669;
}

.corrections-list {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.corrections-list h6 {
    margin: 0 0 1rem 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.corrections-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.corrections-list li {
    padding: 0.75rem 1rem;
    background: var(--surface-secondary);
    border-radius: 8px;
    margin-bottom: 0.625rem;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.corrections-list li::before {
    content: '\2192';
    color: var(--success-green);
    font-weight: 700;
    font-size: 1.25rem;
}

.corrections-list code {
    font-family: var(--font-mono);
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--fiscalia-teal-deep);
    font-weight: 600;
}

.download-xml-btn {
    background: var(--success-green);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    font-family: var(--font-display);
}

.download-xml-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.download-xml-btn:hover::before {
    left: 100%;
}

.download-xml-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.35);
    background: #047857;
}

.download-xml-btn:focus-visible {
    outline: 2px solid var(--success-green);
    outline-offset: 4px;
}

.download-xml-btn:active {
    transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────
   Empty State - Welcoming
   ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-tertiary);
}

.empty-state svg {
    width: 96px;
    height: 96px;
    margin: 0 auto 1.5rem;
    opacity: 0.4;
    color: var(--fiscalia-teal);
}

.empty-state p {
    font-size: 1.0625rem;
    color: var(--text-secondary);
}

/* ─────────────────────────────────────────────────────────
   NF-e Code Suggestions Panel
   ───────────────────────────────────────────────────────── */
.show-codes-btn {
    background: var(--fiscalia-teal);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: var(--font-display);
}

.show-codes-btn:hover {
    background: var(--fiscalia-teal-deep);
    transform: translateY(-1px);
}

.show-codes-btn:focus-visible {
    outline: 2px solid var(--fiscalia-teal);
    outline-offset: 3px;
}

.nfe-codes-row td {
    padding: 0 !important;
    background: var(--surface-secondary);
}

.nfe-codes-panel {
    padding: 1.5rem;
    border-top: 2px solid var(--fiscalia-teal);
}

.nfe-codes-panel h4 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nfe-codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.nfe-code-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.nfe-code-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    letter-spacing: 0.3px;
}

.nfe-code-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fiscalia-teal);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.5rem;
    font-family: var(--font-display);
}

.nfe-code-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.nfe-legal-basis {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.nfe-legal-basis strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.nfe-notes {
    padding: 1rem;
    background: #FFF8E1;
    border-left: 3px solid #FFA000;
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.nfe-notes strong {
    color: #F57C00;
}

/* ─────────────────────────────────────────────────────────
   Responsive Design
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .nfe-validator-section {
        padding: 2rem 1rem;
    }

    .nfe-header h2 {
        font-size: 2rem;
    }

    .nfe-upload-container {
        padding: 3rem 2rem;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .summary-value {
        font-size: 2rem;
    }

    .result-header {
        flex-direction: column;
        text-align: center;
    }

    .validation-section,
    #correction-section {
        padding: 1.5rem;
    }

    .discrepancy-table {
        font-size: 0.75rem;
    }

    .discrepancy-table th,
    .discrepancy-table td {
        padding: 0.75rem 0.5rem;
    }

    .download-xml-btn {
        width: 100%;
        justify-content: center;
    }
}
