/**
 * 檔案用途：前端視覺樣式 v1.4.6
 * 包含：動態品牌色、多色矩陣 RWD、進階加工 Checkbox 卡片、報價列佈局防禦 (Rule 3)。
 */

:root {
    --primary-color: #e62117;
    --primary-gradient: linear-gradient(135deg, #e62117, #b11b15);
    --primary-shadow: rgba(230, 33, 23, 0.15);
    --secondary-color: #1d2327;
    --text-muted: #646970;
    --bg-light: #f6f7f7;
    --border-radius: 16px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.12);
}

#ifjc-quoter-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 40px;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* === Premium Stepper === */
.ifjc-stepper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 50px;
    position: relative;
    padding: 0 10px;
}

.ifjc-stepper .step {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 2;
    cursor: default;
}

.ifjc-stepper .step-icon {
    width: 44px;
    height: 44px;
    background: #fff;
    border: 2px solid #e2e4e7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    color: #a0a5aa;
    transition: all 0.3s ease;
    font-size: 20px;
}

.ifjc-stepper .step.active .step-icon {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 0 5px var(--primary-shadow);
}

.ifjc-stepper .step.completed .step-icon {
    background: #4caf50;
    border-color: #4caf50;
    color: #fff;
}

.ifjc-stepper .step-label {
    font-size: 13px;
    font-weight: 600;
    color: #8c8f94;
    transition: color 0.3s;
}

.ifjc-stepper .step.active .step-label {
    color: var(--secondary-color);
}

.step-progress-bar {
    position: absolute;
    top: 22px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: #e2e4e7;
    z-index: 1;
}

.step-progress-bar .bar-fill {
    height: 100%;
    width: 12.5%;
    background: var(--primary-color);
    transition: width 0.4s ease;
}

/* === 共用區塊 === */
.ifjc-step-content {
    display: none;
    animation: slideUp 0.4s ease;
}

.ifjc-step-content.active {
    display: block;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ifjc-field-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
}

h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--primary-color);
    margin-right: 12px;
    border-radius: 2px;
}

/* === 黏底報價列 (Issue #6) === */
.ifjc-sticky-price-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to right, var(--secondary-color), #2c3338);
    color: #fff;
    padding: 16px 25px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    margin: 30px -40px -40px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.ifjc-sticky-price-bar .price-label {
    font-size: 13px;
    opacity: 0.7;
}

.ifjc-sticky-price-bar .price-value {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
}

/* === 顏色選取器 === */
.ifjc-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.color-item-wrapper {
    cursor: pointer;
    position: relative;
}

.color-item-wrapper input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.color-card {
    text-align: center;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 12px;
    transition: all 0.2s;
    background: #fff;
    height: 100%;
}

.color-card .swatch {
    display: flex;
    width: 50px;
    height: 50px;
    margin: 0 auto 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    align-items: center;
    justify-content: center;
}

.color-card .check-icon {
    color: #fff;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.color-card .name {
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.color-item-wrapper input:checked+.color-card {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    background: #fdf7f7;
}

.color-item-wrapper input:checked+.color-card .check-icon {
    opacity: 1;
}

/* === 多色數量矩陣 === */
.color-qty-row {
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.color-qty-row .row-header {
    width: 130px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
}

.color-qty-row .row-header .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.color-qty-row .row-inputs {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
}

.input-unit {
    text-align: center;
}

.input-unit label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    display: block;
    margin-bottom: 3px;
}

.input-unit input {
    width: 100%;
    text-align: center;
    padding: 8px 4px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.input-unit input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* === 加工項目 (Issue #5: Premium Checkbox Cards) === */
.print-group {
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
}

.print-option-item {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e8e8e8;
    padding: 16px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 14px;
    min-height: 56px;
    -webkit-tap-highlight-color: transparent;
}

.print-option-item:hover {
    border-color: #ccc;
    background: #fafafa;
}

.print-option-item:active {
    transform: scale(0.98);
}

/* 隱藏原生 checkbox，用自訂外觀 */
.print-option-item input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 6px;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0 !important;
}

.print-option-item input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.print-option-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.option-content {
    flex: 1;
}

.option-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary-color);
    display: block;
}

.option-price {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 2px;
}

.manual-badge {
    font-size: 10px;
    background: #fff3e0;
    color: #f57c00;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    display: inline-block;
}

/* 尺寸輸入框 */
.dimension-inputs {
    background: #fff;
    border: 1px dashed #ddd;
    border-top: none;
    padding: 15px;
    border-radius: 0 0 12px 12px;
    margin-top: -5px;
    animation: fadeInDown 0.3s ease-out;
}

.ifjc-dim-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 5px;
}

.ifjc-dim-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* iOS Switch */
.ifjc-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.ifjc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:after {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:checked+.slider:after {
    transform: translateX(22px);
}

/* === 客製化說明分頁 (Info Tab) === */
.ifjc-info-tab-content {
    padding: 20px 0;
}

.ifjc-info-section {
    margin-bottom: 30px;
}

.ifjc-info-section h4 {
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
    margin-bottom: 15px;
}

.ifjc-pill {
    display: inline-flex;
    align-items: center;
    background: #f6f7f7;
    padding: 6px 14px;
    border-radius: 99px;
    margin: 4px;
    font-size: 13px;
    font-weight: 500;
}

.ifjc-pill .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #ddd;
    margin-right: 8px;
    flex-shrink: 0;
}

.ifjc-print-summary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-group {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    border: 1px solid #eee;
    padding: 12px 16px;
    border-radius: 10px;
    flex-wrap: wrap;
}

.category-badge {
    background: var(--secondary-color);
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.positions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 14px;
    color: #444;
}

.pos-item {
    border-bottom: 1px dashed #ddd;
    padding-bottom: 2px;
}

.ifjc-price-table {
    width: 100%;
    border-collapse: collapse;
}

.ifjc-price-table th,
.ifjc-price-table td {
    padding: 10px 15px;
    border: 1px solid #eee;
    text-align: left;
}

.ifjc-price-table th {
    background: #f6f7f7;
}

/* === 簡易報價單 (Quotation Slip) === */
.ifjc-quote-summary-slip {
    animation: fadeIn 0.4s ease;
    border: 1px solid #e0e0e0 !important;
    background: #fff !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.ifjc-quote-summary-slip table {
    width: 100%;
    border-collapse: collapse;
}

.ifjc-quote-summary-slip th {
    background: #f8f9fa;
    color: #1d2327;
    font-weight: 700;
    border-bottom: 2px solid #eee;
}

.ifjc-quote-summary-slip td {
    padding: 12px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.ifjc-quote-summary-slip tr:last-child td {
    border-bottom: none;
}

/* 導覽按鈕 */
.ifjc-navigation {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
    flex-direction: column;
}

.ifjc-navigation button {
    padding: 14px 30px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

button.next-step,
button.submit-quote {
    background: var(--primary-gradient);
    color: #fff;
    flex-grow: 1;
}

button.prev-step {
    background: #f0f0f1;
    color: #50575e;
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* === 動畫 === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === RWD (Issue #4) === */
@media (max-width: 768px) {
    #ifjc-quoter-container {
        padding: 15px;
        margin: 15px auto;
        border-radius: 12px;
    }

    .ifjc-stepper .step-label {
        display: none;
    }

    .ifjc-stepper .step-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .print-group {
        padding: 15px;
    }

    .color-card .swatch {
        width: 40px;
        height: 40px;
    }

    .color-qty-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .color-qty-row .row-header {
        margin-bottom: 10px;
        width: 100%;
    }

    .ifjc-sticky-price-bar {
        margin: 20px -15px -15px;
        padding: 12px 15px;
        border-radius: 10px 10px 0 0;
    }

    .ifjc-sticky-price-bar .price-value {
        font-size: 20px;
    }

    .ifjc-navigation button {
        padding: 12px 15px;
        font-size: 14px;
    }

    h2 {
        font-size: 17px;
    }
}