/* FinCalc Pro - UI Upgrade Stylesheet */

/* --- Base Font & Colors --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8fafc; /* Lighter gray background */
    color: #1f2937; /* Darker text for better contrast */
}

/* --- Consistent Button Styling --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem; /* 12px 24px */
    border-radius: 0.5rem; /* 8px */
    font-weight: 700;
    font-size: 1rem; /* 16px */
    line-height: 1.5rem; /* 24px */
    border: 1px solid transparent;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

/* Primary Button (Next, Calculate) */
.btn-primary {
    background-color: #2563eb; /* A richer blue */
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #1d4ed8; /* Darker blue on hover */
}

/* Secondary Button (Previous) */
.btn-secondary {
    background-color: #e5e7eb; /* Light gray */
    color: #374151; /* Darker gray text */
    border-color: #d1d5db;
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

/* --- Form Element Styling --- */
input[type="number"],
select {
    border: 1px solid #d1d5db;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

input[type="number"]:focus,
select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    outline: none;
}

/* --- Layout & Card Styling --- */
#mortgage-calculator-container,
#tax-calculator-container,
#results-container {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

/* --- Typography --- */
h1 {
    color: #111827;
}

h2, h3 {
    color: #1f2937;
}

/* --- Specific Button Overrides in Mortgage Calculator --- */
/* We will use CSS to control the button sizes now */
#prev-btn, #next-btn {
    flex-grow: 0; /* Don't grow to fill space */
}

#calculate-btn.w-full {
     /* keep its full width when it's the only button */
}

/* Apply base styles to buttons */
#prev-btn, #next-btn, #calculate-btn, #calculate-tax-btn {
    /* This will be handled by adding classes in the next step, for now CSS is a good start */
}

/* [新規則] 控制所有Tooltip的最大寬度以適應手機 */
.tooltip-text {
    max-width: 280px; /* 設定一個最大寬度 */
    width: max-content; /* 讓寬度自適應內容，但不能超過max-width */
}

@media (max-width: 480px) {
    .tooltip-text {
        max-width: 80vw; /* 在小屏幕上，最大寬度為屏幕寬度的80% */
    }
}
/* [新規則] 統一 Tooltip 按鈕樣式 */
.tooltip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem; /* 20px */
    height: 1.25rem; /* 20px */
    border-radius: 9999px; /* 創建圓形 */
    background-color: #E5E7EB; /* 淺灰色背景 */
    color: #6B7280; /* 深灰色問號 */
    font-weight: 600;
    font-size: 0.875rem; /* 14px */
    line-height: 1;
    border: 1px solid #D1D5DB;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 0.25rem; /* 4px */
}

.tooltip-btn:hover {
    background-color: #D1D5DB; /* 懸停時加深背景色 */
}
:root {
    --primary-color: #3B82F6; --primary-color-dark: #2563EB;
    --secondary-color: #F3F4F6; --secondary-color-dark: #E5E7EB;
    --text-color-primary: #1F2937; --text-color-secondary: #6B7280;
    --border-color: #D1D5DB; --card-bg: #FFFFFF; --body-bg: #F9FAFB;
    --border-radius: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.calculator-card, .results-card {
    background-color: var(--card-bg); border-radius: var(--border-radius);
    box-shadow: var(--shadow-md); border: 1px solid var(--border-color);
}
.btn { padding: 0.75rem 1.5rem; border-radius: var(--border-radius); font-weight: 600; text-align: center; transition: all 0.2s ease; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-color-dark); }
.btn-secondary { background-color: var(--secondary-color); color: var(--text-color-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: var(--secondary-color-dark); }
.form-input, .form-select { width: 100%; padding: 0.625rem 0.75rem; border: 1px solid var(--border-color); border-radius: var(--border-radius); }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 768px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.button-group { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); margin-top: 1.5rem; }
.button-group #prev-btn { margin-right: auto; }

/* [修正問題#1] 移除 input[type=number] 的上下箭咀 */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

/* [修正問題#1] 「$」符號外置的樣式 */
.input-with-prefix {
    display: flex;
    align-items: center;
}
.input-with-prefix span {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-right: none;
    background-color: #F9FAFB;
    color: var(--text-color-secondary);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    height: 42px;
    box-sizing: border-box;
}
.input-with-prefix input {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* [修正問題#3] 確保Down Payment組合框對齊 */
.input-group {
    display: flex;
}
.input-group input {
    border-right: none;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}
.input-group select {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
        
/* [修正問題#4] 確保所有輸入框在 form-grid 中等寬 */
.form-grid .form-group, .form-grid .input-group {
    width: 100%;
}

/* [新規則] 統一 Placeholder 顏色 */
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
  color: #9CA3AF; /* gray-400 */
  opacity: 1; /* Firefox */
}

:-ms-input-placeholder { /* Internet Explorer 10-11 */
  color: #9CA3AF;
}

::-ms-input-placeholder { /* Microsoft Edge */
  color: #9CA3AF;
}

/* [新規則] 統一輸入框中 value="0" 的文字顏色 */
input[value="0"] {
  color: #9CA3AF; /* gray-400 */
}
input:focus[value="0"] {
    color: var(--text-color-primary); /* 當用戶點擊時，恢復正常文字顏色 */
}
