/* === Terms Print Page === */
.terms-print-wrapper {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #111827;
}

.terms-print-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 1rem;
}

.terms-print-hint {
    max-width: 800px;
    margin: 0.5rem auto 0;
    padding: 0.5rem 2rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.terms-print-actions {
    max-width: 800px;
    margin: 1rem auto 3rem;
    padding: 0 2rem;
    display: flex;
    justify-content: center;
}

@media print {
    @page { margin: 1.5cm; size: A4; }
    .no-print { display: none !important; }
    .terms-language-note { display: none !important; }
    #blazor-error-ui { display: none !important; }
    .terms-print-wrapper { margin: 0; padding: 0; max-width: 100%; }
}

/* === Base Reset & Typography === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #e8432a;
    --primary-dark: #c9351e;
    --primary-light: #fef2f0;
    --accent: #f47920;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-focus: #e8432a;
    --bg: #f1f5f9;
    --bg-white: #ffffff;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --transition: 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === Header === */
.app-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* === Page Title === */
.page-title {
    text-align: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* === Container === */
.app-container {
    max-width: 780px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

/* === Form Sections === */
.form-section {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
}

.section-icon {
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.section-header h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text);
}

/* === Form Controls === */
.form-group {
    margin-bottom: 1.125rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.375rem;
    letter-spacing: 0.01em;
}

.form-group label.required::after {
    content: " *";
    color: var(--danger);
    font-weight: 700;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6875rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input::placeholder,
.form-group select::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(232, 67, 42, 0.12);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    border-color: #d1d5db;
    cursor: not-allowed;
    opacity: 1;
}

.form-group input.invalid,
.form-group select.invalid,
.form-group .invalid {
    border-color: var(--danger);
}

.validation-message {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
    font-weight: 500;
}


/* === Checkbox === */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.form-check input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.1rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.form-check label {
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.btn-primary {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: white;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #15803d, #166534);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-submit {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
}

/* === Form Actions === */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.required-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}

.required-hint::before {
    content: "* ";
    color: var(--danger);
    font-weight: 700;
}

/* === Alert === */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    animation: rotate 1.4s linear infinite;
}

.loading-overlay .spinner .path {
    stroke: var(--primary);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

.loading-overlay p {
    margin-top: 1rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* === Initial Loading === */
.loading-initial {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.loading-initial .spinner {
    width: 48px;
    height: 48px;
    animation: rotate 1.4s linear infinite;
}

.loading-initial .spinner .path {
    stroke: var(--primary);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

/* === Culture Selector === */
.culture-selector {
    position: relative;
    z-index: 220;
    display:none;
}

.culture-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.25rem;
    padding: 0.3125rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-white);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    transition: all var(--transition);
}

.culture-btn:hover {
    border-color: #bdb8cd;
    box-shadow: 0 4px 14px rgba(57, 48, 85, 0.12);
}

.culture-btn:focus-visible {
    outline: 2px solid #5c469c;
    outline-offset: 2px;
}

.culture-flag {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.culture-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #5c469c;
    letter-spacing: 0.01em;
}

.culture-arrow {
    font-size: 0.625rem;
    color: #8f88a8;
    transition: transform var(--transition);
}

.culture-btn.open .culture-arrow {
    transform: rotate(180deg);
}

.culture-overlay {
    position: fixed;
    inset: 0;
    z-index: 210;
    border: none;
    background: transparent;
    cursor: default;
}

.culture-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 12px 32px rgba(32, 23, 64, 0.18);
    z-index: 230;
    min-width: 190px;
    overflow: hidden;
    padding: 0.25rem;
}

.culture-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.55rem 0.625rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text);
    border-radius: 0.5rem;
    transition: background var(--transition), color var(--transition);
    text-align: left;
}

.culture-option:hover {
    background: #f7f5fc;
    color: #5c469c;
}

.culture-option.active {
    background: #f1edfb;
    color: #5c469c;
    font-weight: 600;
}

.culture-option-name {
    flex: 1;
}

.culture-check {
    font-size: 0.75rem;
    color: #5c469c;
}

/* === Success Page === */
.success-container {
    text-align: center;
    padding: 3rem 1.5rem;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.success-container h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.success-container p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* === Validation Banner === */
.validation-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #991b1b;
}

.validation-banner-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

/* === File Upload === */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload.has-file {
    border-color: var(--success);
    border-style: solid;
    background: #f0fdf4;
    cursor: default;
    flex-direction: row;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    overflow: hidden;
    min-width: 0;
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload-icon {
    font-size: 1.5rem;
    opacity: 0.6;
}

.file-upload p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.file-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.file-name {
    font-size: 0.8125rem;
    color: var(--success);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-remove {
    background: none;
    border: 1px solid #fecaca;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--danger);
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: all var(--transition);
}

.file-remove:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

.file-upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.fiscal-note {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    margin-top: 0.75rem;
}

.fiscal-note-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1.4;
}

.fiscal-note p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* === Info Block === */
.info-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.info-block--success {
    background: #f0fdf4;
    border-color: #86efac;
}

.info-block-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.info-block-header .info-block-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.info-block-header span:last-child {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}

.info-block ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-block ul li {
    position: relative;
    padding-left: 1.375rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.info-block ul li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.45em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

.info-block ul li strong {
    color: var(--text);
    font-weight: 600;
}

/* === Grid for form fields === */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row > .form-group {
    min-width: 0;
}

/* === Footer === */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 1rem;
}

/* === Autocomplete === */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-option {
    display: block;
    width: 100%;
    padding: 0.5rem 0.875rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition);
}

.autocomplete-option:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.autocomplete-code {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.1rem 0.375rem;
    border-radius: 3px;
    margin-right: 0.375rem;
    min-width: 28px;
    text-align: center;
}

/* === Responsive === */
@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .app-header {
        padding: 0 1rem;
        height: 56px;
    }

    .header-logo {
        height: 26px;
    }

    .app-container {
        margin: 1.25rem auto;
        padding: 0 1rem;
    }

    .form-section {
        padding: 1.25rem;
    }

    .page-title h1 {
        font-size: 1.375rem;
    }
}

/* === Animations === */
@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* === Info block note === */
.info-block-note {
    margin-top: 0.75rem;
    font-size: 0.825rem;
    color: #6b7280;
    font-style: italic;
}

/* === Terms language note (shown for non-Spanish users) === */
.terms-language-note {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 6px;
    padding: 0.6rem 0.875rem;
    margin-bottom: 1rem;
    font-size: 0.825rem;
    color: #713f12;
}

/* === Field hint === */
.field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
}

/* === Terms unread hint === */
.terms-unread-hint {
    color: #dc2626;
    font-size: 0.8rem;
    font-style: italic;
}

/* === Terms link === */
.terms-link {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

/* === Terms & Conditions Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}

.modal-container {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 820px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 0 0.25rem;
}

.modal-close-btn:hover {
    color: #111;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.7;
    color: #374151;
}

.modal-body h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

.modal-body h5 {
    font-size: 0.875rem;
    font-weight: 700;
    margin: 1.25rem 0 0.5rem;
    color: #111827;
}

.modal-body p {
    margin-bottom: 0.5rem;
}

.modal-body ul {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.modal-body ul li {
    margin-bottom: 0.25rem;
}

.terms-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 1rem;
    font-size: 0.825rem;
}

.terms-table th, .terms-table td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.terms-table th {
    background: #f9fafb;
    font-weight: 600;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* === Error UI === */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
