/* ========================================
   Point Cloud Viewer - Styles (Light Theme)
   ======================================== */

:root {
    --bg-light: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    
    --header-height: 56px;
    --sidebar-width: 360px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.5;
}

/* ========================================
   Layout
   ======================================== */

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    height: calc(100vh - var(--header-height));
}

/* ========================================
   Header
   ======================================== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-primary);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.point-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.point-count strong {
    color: var(--accent-primary);
}

.file-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    max-height: calc(100vh - var(--header-height));
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    padding-bottom: 2rem;
    display: block;
    flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========================================
   Panel
   ======================================== */

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1rem;
}

.panel:last-child {
    margin-bottom: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.panel-title:hover {
    background-color: var(--bg-card-hover);
}

.panel-title svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.panel-title .panel-title-text {
    flex: 1;
}

.panel-title .panel-toggle {
    color: var(--text-muted);
    transition: transform 0.3s;
    flex-shrink: 0;
}

.panel.collapsed .panel-toggle {
    transform: rotate(-90deg);
}

.panel-content {
    padding: 0 1rem 1rem 1rem;
    transition: all 0.3s ease;
}

.panel.collapsed .panel-content {
    display: none;
}

/* ========================================
   Drop Zone (Legacy - kept for compatibility)
   ======================================== */

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.drop-zone svg {
    color: var(--text-muted);
}

.drop-zone p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.drop-zone .hint {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ========================================
   Drop Overlay (全画面ドラッグ＆ドロップ)
   ======================================== */

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.15);
    border: 3px dashed var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.drop-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.drop-overlay-content svg {
    color: var(--accent-primary);
}

.drop-overlay-content p {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 500;
}

/* ========================================
   File Input Wrapper
   ======================================== */

.file-input-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.file-input-wrapper .btn-full {
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
}

/* ========================================
   Progress
   ======================================== */

.progress-container {
    margin-top: 1rem;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ========================================
   Controls
   ======================================== */

.control-group {
    margin-bottom: 1rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Button Group */
.btn-group {
    display: flex;
    gap: 0.5rem;
}

.btn-toggle {
    flex: 1;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-toggle.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Color Button */
.btn-color {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-color:hover {
    transform: scale(1.1);
}

.btn-color.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Slider */
.slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Select */
.select {
    width: 100%;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
}

.select:focus {
    border-color: var(--accent-primary);
}

.select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-full {
    width: 100%;
}

/* ========================================
   Info Panel
   ======================================== */

.info-content {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.info-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
}

.info-grid dt {
    color: var(--text-muted);
}

.info-grid dd {
    color: var(--text-primary);
    text-align: right;
}

/* ========================================
   Viewport
   ======================================== */

.viewport-container {
    flex: 1;
    position: relative;
    background: #e2e8f0;
    overflow: hidden;
}

.viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.viewport.hidden {
    display: none;
}

.viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Controls Hint */
.viewport-controls-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
    box-shadow: var(--shadow);
}

/* Camera Reset Button */
.btn-camera-reset {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.btn-camera-reset:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* ========================================
   Section Viewport
   ======================================== */

.section-viewport {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 250px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.section-viewport.hidden {
    display: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
}

.btn-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--accent-danger);
}

#sectionCanvas {
    flex: 1;
    width: 100%;
    background: #f1f5f9;
}

/* ========================================
   Cross Section Controls
   ======================================== */

.cross-section-controls {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.cross-section-controls.hidden {
    display: none;
}

/* ========================================
   Control Hint
   ======================================== */

.control-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========================================
   Drawing Mode Indicator
   ======================================== */

.viewport.drawing-mode {
    cursor: crosshair;
}

.viewport.drawing-mode::after {
    content: '断面ラインを描画中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ========================================
   Height Filter Controls
   ======================================== */

.height-filter-controls {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.height-filter-controls.hidden {
    display: none;
}

/* ========================================
   Utilities
   ======================================== */

.hidden {
    display: none !important;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .viewport-controls-hint {
        display: none;
    }
    
    .point-info {
        display: none;
    }
}
