/* 3D検査デモアプリのスタイル */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 60px;
    --header-height: 56px;
    --primary-color: #2c3e50;
    --primary-light: #34495e;
    --accent-color: #3498db;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    overflow-x: hidden;
}

/* アプリコンテナ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* サイドバー */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 20px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

.sidebar-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
}

.sidebar.collapsed .sidebar-subtitle {
    display: none;
}

/* サイドバーナビゲーション */
.sidebar-nav {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    margin: 2px 8px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.sidebar-nav .nav-link i {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.sidebar-nav .nav-link span {
    margin-left: 12px;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-nav .nav-link span {
    display: none;
}

.sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 12px;
}

/* サイドバーフッター */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar.collapsed .sidebar-footer small {
    display: none;
}

/* メインラッパー */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar.collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* メインヘッダー */
.main-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.sidebar-toggle {
    color: var(--primary-color);
    padding: 5px;
    margin-right: 15px;
}

.sidebar-toggle:hover {
    color: var(--accent-color);
}

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

/* メインコンテンツ */
.main-content {
    flex: 1;
    padding: 20px;
    background: #f8f9fa;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        width: var(--sidebar-width);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .sidebar-nav .nav-link span {
        display: inline;
    }
}

/* ドロップゾーンのスタイル */
.drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover {
    border-color: #0d6efd;
    background-color: #f8f9ff;
}

.drop-zone.drag-over {
    border-color: #0d6efd;
    background-color: #e7f1ff;
    transform: scale(1.02);
}

.drop-zone input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-text {
    pointer-events: none;
}

.drop-zone-text i {
    font-size: 2rem;
    color: #6c757d;
    margin-bottom: 10px;
}

.drop-zone-text p {
    margin: 10px 0 5px 0;
    font-weight: 500;
    color: #495057;
}

.drop-zone.has-file {
    border-color: #198754;
    background-color: #f8fff9;
}

.drop-zone.has-file .drop-zone-text i {
    color: #198754;
}

/* ファイル情報表示 */
.file-info {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #e7f1ff;
    border-radius: 4px;
    font-size: 0.9rem;
    display: none;
}

.file-info.show {
    display: block;
}

.file-info .file-name {
    font-weight: 600;
    color: #0d6efd;
}

.file-info .file-size {
    color: #6c757d;
    font-size: 0.8rem;
}

/* 3Dビューアー */
.viewer-container {
    height: 600px;
    background-color: #1a1a1a;
    border-radius: 0 0 8px 8px;
    position: relative;
    overflow: hidden;
}

#viewer3d {
    width: 100%;
    height: 100%;
    position: relative;
}

#viewer3d canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    position: relative;
    z-index: 2;
}

/* プログレスオーバーレイ */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    min-width: 350px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.progress-content .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* 統計情報カード */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #0d6efd;
    display: block;
}

.stat-label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 5px;
}

.stat-item.highlight {
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.stat-item.highlight .stat-value {
    color: #fd7e14;
}

/* カラーマップ凡例 */
.color-legend {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.color-scale {
    height: 20px;
    background: linear-gradient(to right,
            #0000ff 0%,
            #00ffff 25%,
            #00ff00 50%,
            #ffff00 75%,
            #ff0000 100%);
    border-radius: 4px;
    margin: 10px 0;
}

.color-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6c757d;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .viewer-container {
        height: 400px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .progress-content {
        margin: 20px;
        min-width: auto;
    }
}

/* アニメーション */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

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

/* ボタンアニメーション */
.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* カードアニメーション */
.card {
    transition: all 0.3s ease;
    border: 1px solid #dee2e6;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* エラーアラート */
#errorAlert {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* カラーマップ設定 */
.color-map-preview {
    height: 30px;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid #dee2e6;
    background: linear-gradient(to right,
        #0000ff 0%,
        #00ffff 25%,
        #00ff00 50%,
        #ffff00 75%,
        #ff0000 100%);
}

/* 3D機能コントロール */
.btn-group .btn {
    transition: all 0.2s ease;
}

.btn-group .btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* 断面表示・測定ツールコントロール */
#crossSectionControls .card,
#measureControls .card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
}

#crossSectionControls .card-header,
#measureControls .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* 測定結果表示 */
#measureResults .measurement-item {
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* 3Dビューアー内の測定マーカー */
.measurement-marker {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #ff0000;
    border: 2px solid #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
}

.measurement-line {
    position: absolute;
    height: 2px;
    background-color: #ff0000;
    transform-origin: left center;
    z-index: 9;
    pointer-events: none;
}

.measurement-label {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    z-index: 11;
    pointer-events: none;
    white-space: nowrap;
}

/* アニメーション関連 */
.animation-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.animation-progress {
    flex: 1;
    height: 4px;
    background-color: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.animation-progress-bar {
    height: 100%;
    background-color: #0d6efd;
    transition: width 0.1s ease;
}

/* レスポンシブ対応の拡張 */
@media (max-width: 768px) {
    #crossSectionControls,
    #measureControls {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        right: auto !important;
    }
    
    #crossSectionControls .card,
    #measureControls .card {
        width: 90vw !important;
        max-width: 300px !important;
    }
    
    #viewerControls .d-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    #viewerControls .btn-group {
        width: 100%;
    }
}

/* 新しいレイアウト用スタイル */

/* アップロード＋プレビューブロック */
.upload-preview-block {
    height: 100%;
}

.upload-preview-block .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.upload-preview-block .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* プレビューコンテナ */
.preview-container {
    position: relative;
    height: 300px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    flex: 1;
}

.viewer-mini {
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    position: relative;
}

.viewer-mini canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.preview-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1a1a1a;
    z-index: 1;
}

.preview-message.hidden {
    display: none;
}

/* 比較開始ボタン */
#compareBtn {
    padding: 12px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#compareBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
}

/* 検査結果エリア */
#comparisonResultArea {
    border-top: 2px solid #dee2e6;
    margin: 20px 0px 50px 0px;
    padding: 50px;
    animation: slideIn 0.5s ease-out;
}

/* ホバーツールチップ */
.hover-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.hover-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.9);
}

.hover-tooltip .distance-value {
    font-size: 16px;
    font-weight: 700;
    color: #ffd700;
    margin-right: 4px;
}

.hover-tooltip .distance-label {
    font-size: 12px;
    color: #aaa;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .preview-container {
        height: 250px;
    }
    
    .upload-preview-block .card {
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) {
    .preview-container {
        height: 200px;
    }
    
    #compareBtn {
        width: 100%;
        max-width: 300px;
    }
}
