/* ============================================================
   CNC 가공 견적 시스템 - 스타일시트
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #dc2626;
    --error-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ── 헤더 ── */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.version {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 400;
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ── 메인 레이아웃 ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

/* ── 카드 ── */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-header .icon {
    font-size: 20px;
}

.card-body {
    padding: 24px;
}

/* ── 파일 업로드 ── */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
    margin-bottom: 16px;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone.has-file {
    border-color: var(--success);
    background: var(--success-light);
    border-style: solid;
}

.upload-zone .upload-icon {
    font-size: 40px;
    margin-bottom: 12px;
    color: var(--gray-400);
}

.upload-zone.has-file .upload-icon {
    color: var(--success);
}

.upload-zone .upload-text {
    font-size: 14px;
    color: var(--gray-500);
}

.upload-zone .upload-text strong {
    color: var(--primary);
}

.upload-zone .file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
    margin-top: 4px;
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── 폼 ── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group label .hint {
    font-weight: 400;
    color: var(--gray-400);
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

select, input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    color: var(--gray-800);
    background: white;
    transition: border-color 0.2s;
    appearance: auto;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── 버튼 ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-loading {
    position: relative;
}

.btn-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── 결과 영역 ── */
.result-section {
    display: none;
}

.result-section.show {
    display: block;
}

/* ── 견적 결과 카드 ── */
.estimate-total {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    text-align: center;
}

.estimate-total .label {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.estimate-total .price {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
}

.estimate-total .unit-price {
    font-size: 14px;
    opacity: 0.8;
    margin-top: 8px;
}

.estimate-total .accuracy {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    margin-top: 12px;
}

/* ── 비용 내역 ── */
.cost-breakdown {
    list-style: none;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-item .cost-label {
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-item .cost-value {
    font-weight: 600;
    color: var(--gray-800);
}

.cost-item.discount .cost-value {
    color: var(--error);
}

.cost-item.total {
    border-top: 2px solid var(--gray-200);
    padding-top: 16px;
    margin-top: 4px;
    font-weight: 700;
    font-size: 16px;
}

/* ── 분석 결과 상세 ── */
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.analysis-item {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 14px;
}

.analysis-item .label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-400);
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.analysis-item .value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}

.analysis-item .unit {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 400;
}

.analysis-item .sub-detail {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 400;
    margin-top: 2px;
}

.analysis-item-wide {
    grid-column: 1 / -1;
}

.hole-details-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
}

.hole-details-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-400);
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-200);
}

.hole-details-table td {
    padding: 6px 8px;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

.hole-details-table tr:last-child td {
    border-bottom: none;
}

/* ── 피처 유형 뱃지 ── */
.badge-hole, .badge-cutout {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-hole {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge-cutout {
    background: var(--warning-light);
    color: #92400e;
}

/* ── 가공시간 분해 바 차트 ── */
.time-row {
    display: grid;
    grid-template-columns: 120px 1fr 60px 40px;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
}

.time-row:last-child {
    border-bottom: none;
}

.time-row.time-total {
    border-top: 2px solid var(--gray-300);
    padding-top: 8px;
    margin-top: 4px;
}

.time-label {
    color: var(--gray-700);
    white-space: nowrap;
}

.time-bar-wrap {
    height: 14px;
    background: var(--gray-100);
    border-radius: 7px;
    overflow: hidden;
}

.time-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: 7px;
    min-width: 2px;
    transition: width 0.4s ease;
}

.time-value {
    text-align: right;
    font-weight: 600;
    color: var(--gray-800);
}

.time-pct {
    text-align: right;
    font-size: 11px;
    color: var(--gray-400);
}

/* ── 참고사항 ── */
.notes {
    background: var(--warning-light);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.notes .notes-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.notes ul {
    list-style: none;
    font-size: 13px;
    color: var(--gray-600);
}

.notes ul li {
    padding: 2px 0;
}

.notes ul li::before {
    content: '• ';
    color: var(--warning);
    font-weight: bold;
}

/* ── 로딩 ── */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

/* ── 반응형 ── */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .upload-row {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .analysis-grid {
        grid-template-columns: 1fr;
    }
    .estimate-total .price {
        font-size: 28px;
    }
}
