/* Refinance Calculator Styles - Modern Clean Theme */

.refin-calc-container {
    max-width: var(--refin-container-max-width, 600px);
    margin: 40px auto;
    padding: 40px 30px;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.refin-calc-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 0;
    border-bottom: none;
}

.refin-calc-header h2 {
    color: #1e293b;
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
}

/* Form Sections */
.refin-calc-section {
    margin-bottom: 0;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    border: none;
}

.refin-calc-section h3 {
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 0;
}

.refin-calc-row {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.refin-calc-field {
    display: flex;
    flex-direction: column;
}

.refin-calc-field label {
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
    font-weight: 500;
}

.refin-calc-field small {
    font-size: 12px;
    color: #6b7280;
    margin-top: 5px;
}

.refin-calc-field input {
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    color: #1f2937;
    transition: all 0.2s ease;
    font-family: inherit;
}

.refin-calc-field select,
.refin-calc-select {
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    color: #1f2937;
    transition: all 0.2s ease;
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 40px;
}

.refin-calc-field input:focus,
.refin-calc-field select:focus,
.refin-calc-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.refin-calc-field input:hover,
.refin-calc-field select:hover,
.refin-calc-select:hover {
    border-color: #9ca3af;
}

.refin-calc-conditional-fields {
    transition: opacity 0.3s ease;
}

/* Ensure conditional fields show/hide properly */
#original_loan_fields {
    display: block;
}

#remaining_balance_fields {
    display: none;
}

/* Override any theme styles that might interfere */
.refin-calc-conditional-fields[style*="display: block"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.refin-calc-conditional-fields[style*="display: none"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Buttons */
.refin-calc-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
}

.refin-calc-btn {
    padding: 14px 32px;
    font-size: 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: inherit;
}

.refin-calc-btn-primary {
    background-color: #1e3a5f;
    color: #ffffff;
}

.refin-calc-btn-primary:hover {
    background-color: #2c4f7c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

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

.refin-calc-btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

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

/* Results Section */
.refin-calc-results {
    margin-top: 48px;
    border-top: none;
    background-color: #f9fafb;
    border-radius: 8px;
}

/* APR Summary Section */
.refin-calc-apr-summary {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.refin-calc-apr-summary h3 {
    color: #1e293b;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px 0;
}

.refin-calc-apr-text {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 20px;
    color: #4b5563;
}

.refin-calc-apr-text strong {
    color: #1f2937;
    font-weight: 600;
}

.refin-calc-apr-text .refin-positive {
    color: #059669;
    font-weight: 600;
}

.refin-calc-apr-text .refin-negative {
    color: #dc2626;
    font-weight: 600;
}

/* Quick Stats */
.refin-calc-quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.refin-stat-item {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.refin-stat-item.refin-highlight-green {
    background-color: #ecfdf5;
    border-color: #10b981;
}

.refin-stat-item.refin-highlight-red {
    background-color: #fef2f2;
    border-color: #ef4444;
}

.refin-stat-label {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
}

.refin-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.refin-stat-value-large {
    font-size: 24px;
    font-weight: 700;
    color: #059669;
    margin-bottom: 4px;
}

.refin-highlight-red .refin-stat-value-large {
    color: #dc2626;
}

/* Comparison Table */
.refin-calc-comparison-table {
    margin-bottom: 32px;
    overflow-x: auto;
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.refin-calc-comparison-table .refin-calc-table {
    width: 100%;
    border-collapse: collapse;
}

.refin-calc-comparison-table .refin-calc-table thead {
    background-color: #1e3a5f;
    color: white;
}

.refin-calc-comparison-table .refin-calc-table thead th {
    padding: 14px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    border: none;
}

.refin-calc-comparison-table .refin-calc-table thead th:first-child {
    text-align: left;
}

.refin-calc-comparison-table .refin-calc-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    text-align: center;
    color: #4b5563;
    font-size: 14px;
}

.refin-calc-comparison-table .refin-calc-table tbody td:first-child {
    text-align: left;
    background-color: #f9fafb;
    font-weight: 500;
    color: #1f2937;
}

.refin-calc-comparison-table .refin-calc-table tbody tr:last-child td {
    border-bottom: none;
}

.refin-calc-comparison-table .refin-calc-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Summary Cards */
.refin-calc-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.refin-calc-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.refin-calc-card h4 {
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.refin-calc-comparison {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.refin-calc-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #f9fafb;
    border-radius: 6px;
}

.refin-calc-stat.refin-savings {
    background-color: #ecfdf5;
    font-weight: 600;
}

.refin-label {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

.refin-value {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.refin-value.refin-highlight {
    color: #3b82f6;
}

.refin-value.refin-positive {
    color: #059669;
}

.refin-value.refin-negative {
    color: #dc2626;
}

/* Charts */
.refin-calc-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.refin-calc-chart-container {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.refin-calc-chart-container h3 {
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.refin-calc-chart-container canvas {
    max-height: 300px;
}

/* Amortization Tables */
.refin-calc-tables {
    margin-top: 40px;
}

.refin-calc-table-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    border-bottom: 2px solid #e5e7eb;
    background-color: #ffffff;
    border-radius: 8px 8px 0 0;
    padding: 0 16px;
}

.refin-table-tab {
    padding: 14px 24px;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.2s ease;
    position: relative;
    top: 2px;
}

.refin-table-tab:hover {
    color: #1f2937;
}

.refin-table-tab.active {
    border-bottom-color: #c59a5c;
}

.refin-calc-table-container {
    display: none;
}

.refin-calc-table-container.active {
    display: block;
}

.refin-calc-table-wrapper {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
    background-color: #ffffff;
}

.refin-calc-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
}

.refin-calc-table thead {
    background-color: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.refin-calc-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: none;
}

.refin-calc-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
    font-size: 14px;
}

.refin-calc-table tbody tr:last-child td {
    border-bottom: none;
}

.refin-calc-table tbody tr:hover {
    background-color: #f9fafb;
}

.refin-calc-table .refin-yearly-row {
    background-color: #fef3c7;
    font-weight: 600;
}

/* Loading Overlay */
.refin-calc-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 1000;
}

.refin-calc-spinner {
    border: 4px solid #e5e7eb;
    border-top: 4px solid #1e3a5f;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: refin-spin 1s linear infinite;
}

@keyframes refin-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.refin-calc-loading p {
    margin-top: 20px;
    font-size: 16px;
    color: #1f2937;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .refin-calc-container {
        padding: 24px 16px;
        margin: 20px auto;
    }
    
    .refin-calc-row {
        flex-direction: column;
    }
    
    .refin-calc-summary {
        grid-template-columns: 1fr;
    }
    
    .refin-calc-charts {
        grid-template-columns: 1fr;
    }
    
    .refin-calc-buttons {
        flex-direction: column;
    }
    
    .refin-calc-btn {
        width: 100%;
    }
    
    .refin-calc-table-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .refin-calc-container {
        padding: 20px 12px;
    }
    
    .refin-calc-header h2 {
        font-size: 24px;
    }
    
    .refin-calc-section {
        padding: 15px;
    }
    
    .refin-calc-card {
        padding: 15px;
    }
}
