/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基本設定 */
body {
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* メイン */
.main {
    padding: 30px 0;
}

.main .container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    height: calc(100vh - 200px);
}

/* コントロールパネル */
.control-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 25px;
    overflow-y: auto;
    height: fit-content;
}

.panel-section {
    margin-bottom: 30px;
}

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

.panel-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
}

/* ファイルアップロード */
.file-upload-area {
    border: 3px dashed #bdc3c7;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.file-upload-area:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.file-upload-area.dragover {
    border-color: #2ecc71;
    background: #d5f4e6;
}

.file-upload-area i {
    font-size: 3rem;
    color: #7f8c8d;
    margin-bottom: 15px;
}

.file-upload-area p {
    color: #7f8c8d;
    font-size: 0.95rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #e8f5e8;
    border-radius: 8px;
    margin-top: 15px;
}

.file-info i {
    color: #27ae60;
}

.file-info span {
    flex: 1;
    font-weight: 500;
}

/* コントロールグループ */
.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.control-group label {
    min-width: 60px;
    font-weight: 500;
    color: #555;
}

.control-group input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.control-group span {
    min-width: 50px;
    text-align: right;
    font-weight: 500;
    color: #3498db;
}

/* ツールボタン */
.tool-buttons {
    display: grid;
    gap: 10px;
}

.btn-tool {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 15px;
    background: #ecf0f1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    color: #555;
}

.btn-tool:hover {
    background: #d5dbdb;
    color: #2c3e50;
}

.btn-tool.active {
    background: #3498db;
    color: white;
}

/* 座標読み取り */
.coordinate-section {
    margin-bottom: 15px;
}

.progress-container {
    margin-top: 15px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    width: 0%;
    transition: width 0.3s ease;
    animation: progressAnimation 2s infinite;
}

@keyframes progressAnimation {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.progress-text {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin: 0;
}

.coordinate-results {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.coordinate-results h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1rem;
}

.coordinate-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.coordinate-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.coordinate-item:last-child {
    margin-bottom: 0;
}

.coordinate-info {
    flex: 1;
}

.coordinate-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.coordinate-value {
    color: #007bff;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    margin-top: 2px;
}

.coordinate-confidence {
    font-size: 0.8rem;
    color: #6c757d;
}

.coordinate-actions {
    display: flex;
    gap: 5px;
}

.btn-coordinate {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.btn-edit {
    background: #ffc107;
    color: #212529;
}

.btn-edit:hover {
    background: #e0a800;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.coordinate-controls {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.coordinate-controls .btn-secondary,
.coordinate-controls .btn-primary {
    flex: 1;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.7rem;
    background: #6c757d;
    color: white;
    border-radius: 10px;
    margin-left: 5px;
}

/* 測定結果 */
.measurement-results {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ecf0f1;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
}

.no-results {
    color: #95a5a6;
    font-style: italic;
    text-align: center;
}

.measurement-item {
    background: white;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.measurement-item:last-child {
    margin-bottom: 0;
}

.measurement-item .label {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 5px;
}

.measurement-item .value {
    font-size: 1.1rem;
    color: #27ae60;
    font-weight: 600;
}

/* マップコンテナ */
.map-container {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    height: 100%;
}

.map {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

/* マップエラー表示 */
.map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 500px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

.error-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 500px;
    margin: 20px;
}

.error-content i {
    font-size: 3rem;
    color: #e74c3c;
    margin-bottom: 20px;
}

.error-content h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.error-content p {
    color: #7f8c8d;
    margin-bottom: 20px;
    line-height: 1.6;
}

.error-steps {
    text-align: left;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.error-steps h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1rem;
}

.error-steps ol {
    margin-left: 20px;
    color: #555;
}

.error-steps li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.error-steps a {
    color: #3498db;
    text-decoration: none;
}

.error-steps a:hover {
    text-decoration: underline;
}

.btn-demo {
    background: #f39c12;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.btn-demo:hover {
    background: #e67e22;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

/* デモモード表示 */
.demo-mode {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 500px;
    background: linear-gradient(135deg, #fff9e6, #fef5e0);
}

.demo-content {
    text-align: center;
    padding: 40px;
    background: white;
    border: 2px solid #f39c12;
    border-radius: 12px;
    max-width: 400px;
    margin: 20px;
}

.demo-content i {
    font-size: 3rem;
    color: #f39c12;
    margin-bottom: 20px;
}

.demo-content h3 {
    color: #e67e22;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.demo-content p {
    color: #8e5b0a;
    margin-bottom: 10px;
    line-height: 1.6;
}

.demo-note {
    font-size: 0.9rem;
    font-style: italic;
    color: #a66c00 !important;
}

.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-toggle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #555;
    transition: all 0.3s ease;
}

.btn-toggle:hover {
    background: #3498db;
    color: white;
    transform: scale(1.05);
}

/* ボタンスタイル */
.btn-primary {
    background: #3498db;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.btn-icon {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background: #e74c3c;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 50px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #ecf0f1;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.modal-body {
    padding: 25px;
    flex: 1;
    overflow: auto;
    text-align: center;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

#pdfCanvas {
    max-width: 100%;
    max-height: 60vh;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* 座標値読み取り機能 */
.coordinate-tools {
    display: grid;
    gap: 10px;
    margin-bottom: 15px;
}

.coordinate-status {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    margin-bottom: 15px;
}

.status-text {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
}

.coordinate-results {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    max-height: 300px;
    overflow-y: auto;
}

.coordinates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.coordinates-header h4 {
    margin: 0;
    font-size: 0.95rem;
    color: #2c3e50;
}

.btn-small {
    padding: 6px 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s ease;
}

.btn-small:hover {
    background: #219a52;
}

.coordinates-list {
    padding: 15px;
}

.coordinate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.coordinate-item:last-child {
    border-bottom: none;
}

.coordinate-text {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #2c3e50;
    flex: 1;
}

.coordinate-confidence {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-left: 10px;
}

.coordinate-actions {
    display: flex;
    gap: 5px;
}

.btn-mini {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.3s ease;
}

.btn-accept {
    background: #27ae60;
    color: white;
}

.btn-accept:hover {
    background: #219a52;
}

.btn-reject {
    background: #e74c3c;
    color: white;
}

.btn-reject:hover {
    background: #c0392b;
}

/* 座標設定モーダル */
.coordinate-input-section {
    padding: 20px 0;
}

.coordinate-input-group {
    margin-bottom: 20px;
}

.input-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.input-row label {
    min-width: 130px;
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}

.input-row input[type="number"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
}

.input-row input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.coordinate-info {
    background: #e8f5e8;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #d5f4e6;
}

.coordinate-info p {
    margin: 0;
    color: #2d5016;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.coordinate-info i {
    color: #27ae60;
    margin-top: 2px;
}

/* OCR処理中のスタイル */
.ocr-processing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
}

.ocr-processing .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ffeaa7;
    border-top: 2px solid #f39c12;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ocr-progress {
    font-size: 0.9rem;
    color: #856404;
}

/* 座標値ハイライト表示 */
.coordinate-highlight {
    position: absolute;
    border: 2px solid #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
    pointer-events: none;
    z-index: 100;
}

.coordinate-popup {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 101;
    pointer-events: none;
}

/* レスポンシブデザイン */
@media (max-width: 1024px) {
    .main .container {
        grid-template-columns: 300px 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .main .container {
        grid-template-columns: 1fr;
        gap: 20px;
        height: auto;
    }
    
    .map-container {
        height: 60vh;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .control-panel {
        order: 2;
    }
    
    .map-container {
        order: 1;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .control-panel {
        padding: 20px;
    }
    
    .file-upload-area {
        padding: 20px;
    }
    
    .file-upload-area i {
        font-size: 2rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}