/* ============================
   發票小助手 - Styles
   ============================ */

/* === Root Variables === */
:root {
    --tofu-yellow: #fff9e6;
    --tofu-border: #e6d5a7;
    --tofu-accent: #f39800;
    --orange-500: #f97316;
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-800: #1e40af;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --orange-200: #fed7aa;
    --orange-800: #9c4221;
    --red-300: #fca5a5;
    --red-500: #ef4444;
}

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

body {
    background-color: #fdfaf2;
    font-family: 'Noto Sans TC', sans-serif;
    color: #4a4a4a;
    padding: 2rem 1rem;
}

/* === Layout === */
.container {
    max-width: 80rem;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--orange-800);
    letter-spacing: -0.025em;
}

.header .subtitle {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* === Main Grid (responsive) === */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .main-grid {
        grid-template-columns: repeat(12, 1fr);
    }
    .form-panel {
        grid-column: span 5;
    }
    .preview-panel {
        grid-column: span 7;
    }
}

.form-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* === Card === */
.card {
    background: white;
    border: 2px solid var(--tofu-border);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(230, 213, 167, 0.2);
    padding: 1.5rem;
}

/* === Form Grid === */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.mode-tabs {
    grid-column: span 2;
    display: flex;
    gap: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-400);
    margin-bottom: 0.25rem;
    padding: 0 0.25rem;
}

/* === Tab Buttons === */
.tab-btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid var(--orange-500);
    background: white;
    color: var(--orange-500);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--orange-500);
    color: white;
}

/* === Input Box === */
.input-box {
    width: 100%;
    border: 1px solid var(--tofu-border);
    border-radius: 8px;
    padding: 8px 12px;
    outline: none;
    transition: all 0.2s;
    font-size: 0.85rem;
    appearance: textfield;
    -moz-appearance: textfield;
    font-family: inherit;
}

.input-box::-webkit-outer-spin-button,
.input-box::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-box:focus {
    border-color: var(--tofu-accent);
    background-color: #fffef9;
}

.input-box.text-center { text-align: center; }
.input-box.text-right  { text-align: right; }
.input-box.font-mono   { font-family: monospace; }
.input-box.tracking-widest { letter-spacing: 0.1em; }

/* 未稅 - 預設不可輸入風格 */
.input-box.price-untaxed {
    background-color: var(--gray-50);
    border-color: var(--gray-200);
}

/* 未稅 - 應稅時可輸入，改成跟含稅一樣的橘色 */
.input-box.price-untaxed.editable {
    background-color: transparent;
    border-color: var(--orange-200);
}

/* 含稅 - 橘色邊框 */
.input-box.price-taxed {
    border-color: var(--orange-200);
}

/* 停用狀態 */
.input-box:disabled {
    background-color: var(--gray-100) !important;
    border-color: var(--gray-300) !important;
    color: var(--gray-400);
    cursor: not-allowed;
}

/* === Buyer Section === */
.buyer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    transition: opacity 0.3s;
}

/* === Items Section === */
.items-section {
    border-top: 1px solid var(--gray-100);
    padding-top: 1.5rem;
    margin-bottom: 1rem;
}

.items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.items-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-700);
}

.btn-add {
    background: var(--tofu-accent);
    color: white;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
}

.btn-add:hover  { transform: scale(1.05); }
.btn-add:active { transform: scale(0.95); }

/* === Items Grid === */
.items-col-header {
    display: grid;
    grid-template-columns: 3.5fr 1.5fr 3fr 3fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0 0.25rem;
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-400);
    text-align: center;
}

.items-col-header > div:first-child {
    text-align: left;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.item-row {
    display: grid;
    grid-template-columns: 3.5fr 1.5fr 3fr 3fr 1fr;
    gap: 0.5rem;
    align-items: center;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--red-300);
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}

.remove-btn:hover {
    color: var(--red-500);
}

/* === Summary Box === */
.summary-box {
    background-color: var(--blue-50);
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--blue-100);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.summary-line .value {
    font-family: monospace;
    font-weight: 700;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--blue-800);
    padding-top: 0.5rem;
    border-top: 1px solid var(--blue-200);
}

.summary-total .value {
    font-family: monospace;
}

/* === Preview === */
.preview-container {
    background: white;
    padding: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--gray-300);
    position: relative;
    overflow: hidden;
}

.preview-container svg {
    width: 100%;
    height: auto;
}

/* === SVG Styles === */
.inv-text {
    font-family: 'Noto Serif TC', serif;
    fill: #2c5282;
}

.inv-label {
    fill: #3182ce;
    font-size: 14px;
}

.inv-line {
    stroke: #3182ce;
    stroke-width: 0.8;
}

.brush-font {
    font-family: 'Ma Shan Zheng', 'Noto Serif TC', serif;
}
