/* ── 고객용 견적 페이지 CSS (estimate.php) ───────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:      #2563eb;   /* PHP로 오버라이드됨 */
    --brand-dark: #1d4ed8;
    --gold:       #e8a020;
    --text:       #1e293b;
    --muted:      #64748b;
    --border:     #e2e8f0;
    --bg:         #f8fafc;
    --white:      #ffffff;
    --danger:     #dc2626;
    --success:    #16a34a;
    --radius:     10px;
    --shadow:     0 2px 12px rgba(0,0,0,.08);
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── 헤더 ── */
.est-header {
    background: var(--brand);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.est-header img { height: 36px; border-radius: 6px; }
.est-header .company { font-size: 1.1rem; font-weight: 700; }
.est-header .tagline { font-size: .8rem; opacity: .8; }

/* ── 단계 표시 ── */
.est-steps {
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 20px 20px 0;
    max-width: 680px;
    margin: 0 auto;
}
.est-step {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: .8rem;
    color: var(--muted);
    border-bottom: 3px solid var(--border);
    position: relative;
}
.est-step.active   { color: var(--brand); border-color: var(--brand); font-weight: 700; }
.est-step.done     { color: var(--success); border-color: var(--success); }
.est-step .step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--border); color: var(--muted);
    font-size: .75rem; font-weight: 700; margin-bottom: 4px;
}
.est-step.active .step-num { background: var(--brand); color: #fff; }
.est-step.done   .step-num { background: var(--success); color: #fff; }

/* ── 본문 래퍼 ── */
.est-body {
    max-width: 860px;
    margin: 24px auto;
    padding: 0 16px 60px;
}

/* ── 카드 ── */
.est-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.est-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1rem;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: 8px;
}
.est-card-body { padding: 20px; }

/* ── 폼 공통 ── */
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-size: .95rem; font-family: inherit; color: var(--text);
    transition: border-color .15s;
    background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-control.error { border-color: var(--danger); }
.form-row { display: grid; gap: 12px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
@media(max-width:520px){ .form-row-2 { grid-template-columns: 1fr; } }

/* ── 체크박스 그룹 ── */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid var(--border); border-radius: 99px;
    cursor: pointer; font-size: .875rem; transition: all .15s;
    user-select: none;
}
.check-pill:hover { border-color: var(--brand); }
.check-pill input[type="checkbox"] { display: none; }
.check-pill.checked {
    background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}

/* ── 캡차 ── */
.captcha-wrap {
    display: flex; align-items: center; gap: 12px;
    background: #f1f5f9; padding: 12px 16px; border-radius: 8px;
}
.captcha-q { font-weight: 700; font-size: 1.1rem; font-family: monospace; }
.captcha-input { width: 80px; text-align: center; font-size: 1.1rem; }

/* ── 오류/안내 메시지 ── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; }
.alert-error   { background: #fef2f2; color: var(--danger);  border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1d4ed8;        border: 1px solid #bfdbfe; }
.alert-warn    { background: #fefce8; color: #92400e;        border: 1px solid #fde68a; }

/* ── 버튼 ── */
.btn-est {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 28px; border-radius: 8px; border: none;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: all .15s; text-decoration: none;
}
.btn-primary-est {
    background: var(--brand); color: #fff;
    width: 100%; font-size: 1.05rem;
}
.btn-primary-est:hover { background: var(--brand-dark); }
.btn-outline-est {
    background: transparent; color: var(--brand);
    border: 2px solid var(--brand);
}
.btn-outline-est:hover { background: var(--brand); color: #fff; }

/* ── 2단계: 아이템 레이아웃 ── */
.step2-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media(max-width:760px){ .step2-wrap { grid-template-columns: 1fr; } }

/* ── 아코디언 ── */
details.cat-section { margin-bottom: 12px; }
details.cat-section summary {
    cursor: pointer; padding: 13px 18px;
    background: var(--white); border: 1.5px solid var(--border);
    border-radius: var(--radius); font-weight: 700;
    display: flex; align-items: center; justify-content: space-between;
    list-style: none; transition: border-color .15s;
}
details.cat-section summary::-webkit-details-marker { display: none; }
details.cat-section[open] > summary { border-color: var(--brand); color: var(--brand); border-radius: var(--radius) var(--radius) 0 0; border-bottom: none; }
details.cat-section summary .cat-count { font-size: .75rem; color: var(--muted); font-weight: 400; }
details.cat-section summary::after { content: '﹀'; font-size: .85rem; color: var(--muted); }
details.cat-section[open] > summary::after { content: '︿'; color: var(--brand); }

.cat-items-table {
    background: var(--white); border: 1.5px solid var(--brand);
    border-top: none; border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}
.item-row {
    display: grid;
    grid-template-columns: 36px 1fr auto 100px auto;
    gap: 8px; align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: #f8fafc; }
.item-row.selected { background: #eff6ff; }
.item-check { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.item-name-col { font-size: .9rem; }
.item-name-col .item-unit { font-size: .75rem; color: var(--muted); margin-left: 4px; }
.item-price-col { font-size: .82rem; color: var(--muted); text-align: right; white-space: nowrap; }
.qty-input {
    width: 90px; padding: 6px 8px; border: 1.5px solid var(--border);
    border-radius: 6px; text-align: center; font-size: .9rem;
    font-family: inherit;
}
.qty-input:focus { outline: none; border-color: var(--brand); }
.qty-input:disabled { background: #f1f5f9; color: var(--muted); }
.line-sub { font-size: .82rem; font-weight: 600; text-align: right; white-space: nowrap;
            min-width: 70px; color: var(--muted); }
.line-sub.active { color: var(--brand); }
@media(max-width:520px){
    .item-row { grid-template-columns: 30px 1fr 80px; gap: 4px; }
    .item-price-col, .line-sub { display: none; }
}

/* ── 합계 박스 (sticky) ── */
.total-box {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px;
    position: sticky; top: 16px;
}
.total-box h3 { font-size: .95rem; color: var(--muted); margin-bottom: 12px; }
.total-items-list { font-size: .8rem; max-height: 220px; overflow-y: auto; margin-bottom: 14px; }
.total-item-row { display: flex; justify-content: space-between; padding: 4px 0;
                  border-bottom: 1px solid var(--border); }
.total-item-row:last-child { border-bottom: none; }
.grand-total {
    font-size: 1.4rem; font-weight: 800; color: var(--brand);
    text-align: right; margin: 12px 0;
    border-top: 2px solid var(--border); padding-top: 10px;
}
.grand-total small { font-size: .75rem; font-weight: 400; color: var(--muted); margin-left: 4px; }
.item-count-badge { font-size:.75rem; color:var(--muted); text-align:right; margin-bottom:6px; }

/* ── 제한/준비중 페이지 ── */
.unavail-page {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 60vh; text-align: center; padding: 40px 20px;
}
.unavail-icon { font-size: 3rem; margin-bottom: 16px; }
.unavail-title { font-size: 1.3rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.unavail-sub { color: var(--muted); }

/* ── 인쇄 ── */
@media print {
    .est-header, .est-steps, .btn-est, .total-box { display: none !important; }
}
