/* ============================================================
   CubeMaker - Light Theme (Homepage Style)
   데이터 구축 페이지 전용 컴포넌트 스타일
   ============================================================ */

/* === Build page scroll: only content-main scrolls === */
body.build-page { overflow: hidden; height: 100vh; }
body.build-page .content-main {
    overflow-y: auto;
    height: calc(100vh - 104px); /* header(56px) + tabs(48px) */
}

/* === Build Tabs (서브 네비게이션) === */
.build-tabs-container {
    background: #fff;
    border-bottom: 2px solid var(--hp-border, #e9ecef);
}
.build-tabs {
    display: flex;
    gap: 0;
    height: 46px;
    align-items: stretch;
}
.build-tab {
    color: var(--hp-text-secondary, #666);
    font-size: 14px;
    font-weight: 500;
    padding: 0 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.build-tab:hover {
    color: var(--hp-blue, #2a5298);
    background: rgba(42, 82, 152, 0.04);
}
.build-tab.active {
    color: var(--hp-blue, #2a5298);
    border-bottom-color: var(--hp-blue, #2a5298);
    font-weight: 600;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h4 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--hp-blue, #2a5298);
    margin: 0;
}

/* === Cards (라이트) === */
.cm-card {
    background: #fff;
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: all 0.2s;
}
.cm-card-header {
    background: var(--hp-bg, #f8f9fa);
    border-bottom: 1px solid var(--hp-border, #e9ecef);
    color: var(--hp-text, #333);
    font-weight: 600;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: 8px 8px 0 0;
}
.cm-card-body {
    padding: 16px;
}

/* === Format Tabs === */
.format-tabs {
    display: flex;
    gap: 2px;
    background: var(--hp-border, #e9ecef);
    padding: 3px;
    border-radius: 6px;
    width: fit-content;
    margin-bottom: 16px;
}
.format-tabs .nav-link {
    color: var(--hp-text-secondary, #666);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 20px;
    border-radius: 4px;
    border: none;
    background: transparent;
    transition: all 0.2s;
}
.format-tabs .nav-link:hover {
    color: var(--hp-text, #333);
    background: #fff;
}
.format-tabs .nav-link.active {
    color: #fff;
    background: var(--hp-blue, #2a5298);
}

/* === Tab Content Area === */
.tab-content-area {
    background: #fff;
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 8px;
    padding: 20px;
}

/* === Accordion (폼 섹션 토글) === */
.section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
    border-bottom: 1px solid var(--hp-border, #e9ecef);
    margin-bottom: 12px;
    user-select: none;
}
.section-toggle h6 {
    font-size: 13px;
    font-weight: 600;
    color: var(--hp-blue, #2a5298);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-toggle .chevron {
    color: #999;
    transition: transform 0.2s;
    font-size: 12px;
}
.section-toggle.collapsed .chevron {
    transform: rotate(-90deg);
}
.section-content {
    transition: max-height 0.3s ease;
    overflow: hidden;
}
.section-content.collapsed {
    max-height: 0 !important;
    margin: 0;
    padding: 0;
}

/* === Form Parameter Grid === */
.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.param-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.param-group .form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--hp-text-secondary, #666);
    margin-bottom: 2px;
}

/* === Upload Zone === */
.upload-zone {
    border: 2px dashed var(--hp-border, #e9ecef);
    border-radius: 8px;
    padding: 14px 20px;
    text-align: center;
    background: var(--hp-bg, #f8f9fa);
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}
.upload-zone:hover {
    border-color: var(--hp-blue, #2a5298);
    background: rgba(42, 82, 152, 0.04);
}
.upload-zone.active {
    border-color: var(--hp-blue, #2a5298);
    background: rgba(42, 82, 152, 0.06);
}
.upload-zone .upload-icon {
    font-size: 20px;
    color: #999;
    margin-bottom: 2px;
}
.upload-zone .upload-text {
    font-size: 13px;
    color: var(--hp-text-secondary, #666);
}
.upload-zone .upload-hint {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}
.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Toggle chip group */
.toggle-chip-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.toggle-chip-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 14px;
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 6px;
    transition: all 0.2s;
    color: var(--hp-text-secondary, #666);
}
.toggle-chip-group label:has(input:checked) {
    border-color: var(--hp-blue, #2a5298);
    background: rgba(42, 82, 152, 0.06);
    color: var(--hp-blue, #2a5298);
    font-weight: 600;
}
.toggle-chip-group input[type="radio"] {
    margin: 0;
}

/* Upload badge */
.upload-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 8px;
}
.upload-badge.basic {
    background: rgba(42, 82, 152, 0.1);
    color: var(--hp-blue, #2a5298);
}
.upload-badge.app {
    background: rgba(23, 162, 184, 0.1);
    color: #17a2b8;
}

/* === File List === */
.file-list {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}
.file-list-item {
    font-size: 12px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}
.file-list-item i {
    color: #999;
    font-size: 11px;
}

/* === Action Button === */
.btn-action {
    background: linear-gradient(135deg, var(--hp-blue, #2a5298), var(--hp-blue-dark, #1e3c72));
    border: none;
    color: #fff;
    font-weight: 600;
    padding: 10px 28px;
    font-size: 14px;
    border-radius: 6px;
}
.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(42, 82, 152, 0.3);
    color: #fff;
}

/* === DB Config Row === */
.db-config-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.db-field {
    position: relative;
}

/* === Active DB Mini Status === */
.db-connection-mini {
    margin: 12px 0 10px;
    padding: 6px 10px;
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 999px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #666;
    line-height: 1;
    max-width: 100%;
}
.db-mini-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}
.db-mini-dot.connected {
    background: #28a745;
    box-shadow: 0 0 4px rgba(40, 167, 69, 0.45);
}
.db-mini-dot.disconnected {
    background: #dc3545;
}
.db-mini-label {
    color: #555;
    font-weight: 600;
    white-space: nowrap;
}
.db-mini-text {
    color: #777;
    font-family: Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.db-mini-btn {
    border: 1px solid #d7dce2;
    background: #f8f9fa;
    color: #555;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
    margin-left: 2px;
}
.db-mini-btn:hover {
    background: #eef2f7;
}
.db-mini-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

/* === Progress Card === */
.progress-card {
    background: #fff;
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 20px;
}
.progress-header {
    padding: 12px 16px;
    background: var(--hp-bg, #f8f9fa);
    border-bottom: 1px solid var(--hp-border, #e9ecef);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.progress-header .task-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--hp-blue, #2a5298);
    display: flex;
    align-items: center;
    gap: 8px;
}
.progress-header .task-id {
    font-size: 11px;
    color: #999;
    font-family: 'Consolas', monospace;
    background: var(--hp-border, #e9ecef);
    padding: 2px 8px;
    border-radius: 10px;
}
.progress-body {
    padding: 16px;
}
.progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.progress-step {
    font-size: 13px;
    font-weight: 500;
    color: var(--hp-text, #333);
}
.progress-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--hp-blue, #2a5298);
    font-family: 'Consolas', monospace;
}

/* Progress bar override */
.progress-card .progress {
    height: 4px;
    background: var(--hp-border, #e9ecef);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}
.progress-card .progress-bar {
    background: linear-gradient(90deg, var(--hp-blue, #2a5298), var(--hp-blue-light, #3d6cb9));
    border-radius: 2px;
    transition: width 0.3s ease;
}
.progress-card .progress-bar.bg-success {
    background: linear-gradient(90deg, #28a745, #20c997) !important;
}
.progress-card .progress-bar.bg-danger {
    background: #dc3545 !important;
}

/* Log area */
#progressLog {
    background: #f1f3f5;
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 6px;
    padding: 12px;
    height: 200px;
    overflow-y: auto;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 11px;
    line-height: 1.7;
    color: #495057;
}
#progressLog .log-line {
    white-space: pre-wrap;
    word-break: break-all;
    padding: 1px 0;
}

/* Complete section */
.progress-complete {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--hp-border, #e9ecef);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === Tables === */
.tileset-row {
    cursor: pointer;
    transition: background 0.2s;
}
.tileset-row:hover {
    background: rgba(42, 82, 152, 0.04) !important;
}
.tileset-row.active {
    background: rgba(42, 82, 152, 0.08) !important;
    border-left: 3px solid var(--hp-blue, #2a5298);
}

/* Badges */
.badge.type-app {
    background: rgba(23, 162, 184, 0.12);
    color: #17a2b8;
}
.badge.type-basic {
    background: rgba(42, 82, 152, 0.12);
    color: var(--hp-blue, #2a5298);
}

/* === Stats Panel === */
.stats-table {
    width: 100%;
}
.stats-table td {
    padding: 6px 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--hp-border, #e9ecef);
}
.stats-table td:first-child {
    color: #999;
    font-size: 12px;
    width: 40%;
}
.stats-table td:last-child {
    font-weight: 500;
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

/* === Viewer === */
#cesiumContainer {
    width: 100%;
    height: calc(100vh - 104px);
    border-radius: 0;
}
.viewer-sidebar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--hp-border, #e9ecef);
    border-radius: 8px;
    padding: 16px;
    width: 260px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.viewer-sidebar h6 {
    font-size: 13px;
    font-weight: 600;
    color: var(--hp-blue, #2a5298);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.viewer-sidebar hr {
    border-color: var(--hp-border, #e9ecef);
    margin: 12px 0;
}

/* Viewer tileset items */
.tileset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    gap: 8px;
}
.tileset-item .tileset-name {
    font-size: 12px;
    color: var(--hp-text, #333);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
.tileset-item.active {
    background: rgba(42, 82, 152, 0.08);
    border-radius: 4px;
    padding: 6px 4px;
}
.tileset-item.active .tileset-name {
    color: var(--hp-blue, #2a5298);
    font-weight: 600;
}
.tileset-item.active .btn {
    background: var(--hp-blue, #2a5298);
    color: #fff;
    border-color: var(--hp-blue, #2a5298);
}

/* Right-side measurement toolbar */
.viewer-toolbar-right {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 5px;
    border: 1px solid var(--hp-border, #e9ecef);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}
.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 46px;
    border: none;
    background: transparent;
    color: var(--hp-text-secondary, #666);
    font-size: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 4px 2px;
    gap: 2px;
}
.toolbar-btn i {
    font-size: 17px;
}
.toolbar-btn:hover {
    background: rgba(42, 82, 152, 0.08);
    color: var(--hp-blue, #2a5298);
}
.toolbar-btn.measure-active {
    background: var(--hp-blue, #2a5298) !important;
    color: #fff !important;
    box-shadow: 0 1px 4px rgba(42, 82, 152, 0.3);
}
.toolbar-divider {
    height: 1px;
    background: var(--hp-border, #e9ecef);
    margin: 2px 6px;
}

/* Measurement result floating panel */
.viewer-measure-result {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    color: var(--hp-text, #333);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--hp-border, #e9ecef);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    display: none;
}

.viewer-sidebar .form-range {
    height: 20px;
    accent-color: var(--hp-blue, #2a5298);
}
.viewer-sidebar .form-range::-webkit-slider-runnable-track {
    background: #ccc;
    height: 4px;
    border-radius: 2px;
}
.viewer-sidebar .form-range::-moz-range-track {
    background: #ccc;
    height: 4px;
    border-radius: 2px;
}

/* === Status Indicator === */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.connected { background: #28a745; box-shadow: 0 0 6px rgba(40, 167, 69, 0.5); }
.status-dot.disconnected { background: #dc3545; }

/* === Responsive === */
@media (max-width: 768px) {
    .param-grid { grid-template-columns: repeat(2, 1fr); }
    .viewer-sidebar { width: calc(100% - 24px); }
    .build-tabs { overflow-x: auto; }
    .db-connection-mini {
        display: flex;
        border-radius: 8px;
    }
}
