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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

header {
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 24px;
    color: #2c3e50;
}

.queue-status {
    color: #666;
    font-size: 14px;
}

/* 上傳區域 */
.upload-section {
    margin-bottom: 30px;
}

.upload-box {
    background: white;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-box:hover {
    border-color: #4CAF50;
    background-color: #f9f9f9;
}

.upload-box.drag-over {
    border-color: #4CAF50;
    background-color: #e8f5e9;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

/* 按鈕 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    margin: 5px;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

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

.btn-danger:hover {
    background-color: #c82333;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 專案列表 */
.projects-section h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.projects-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.project-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

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

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.project-filename {
    font-weight: bold;
    color: #2c3e50;
    font-size: 16px;
}

.project-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.status-pending {
    background-color: #ffc107;
    color: #000;
}

.status-processing {
    background-color: #17a2b8;
    color: white;
}

.status-pending_review {
    background-color: #fd7e14;
    color: white;
}

.status-completed {
    background-color: #28a745;
    color: white;
}

.status-failed {
    background-color: #dc3545;
    color: white;
}

.project-info {
    color: #666;
    font-size: 13px;
    margin-bottom: 10px;
}

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

.progress-fill {
    height: 100%;
    background-color: #4CAF50;
    transition: width 0.3s;
}

.project-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.project-actions .btn {
    padding: 8px 12px;
    font-size: 13px;
    flex: 0 1 auto;
}

.project-actions .btn-primary {
    flex: 1 1 100%;
}

.project-actions .btn-secondary {
    flex: 0 1 auto;
    min-width: 70px;
}

/* 模態框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 500px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #000;
}

/* SVG 容器 */
.svg-container {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.svg-canvas {
    max-width: 100%;
    max-height: 600px;
    border: 1px solid #ccc;
    background: white;
    cursor: crosshair;
}

/* 房間列表 */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.room-card {
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.room-card:hover {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.room-card.has-poi {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.room-id {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.room-poi-name {
    color: #4CAF50;
    font-weight: bold;
}

.room-area {
    color: #666;
    font-size: 12px;
}

/* 表單 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.config-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}

.config-section h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

/* SVG 互動樣式 */
.room-polygon {
    fill: rgba(200, 200, 200, 0.1);
    stroke: #333;
    stroke-width: 2;
    cursor: pointer;
    transition: fill 0.3s;
}

.room-polygon:hover {
    fill: rgba(76, 175, 80, 0.2);
}

.room-polygon.selected {
    fill: rgba(76, 175, 80, 0.3);
    stroke: #4CAF50;
    stroke-width: 3;
}

.room-polygon.has-poi {
    fill: rgba(76, 175, 80, 0.15);
    stroke: #4CAF50;
}

/* 線段樣式 */
.segment-wall {
    stroke: #333;
    stroke-width: 2;
    stroke-linecap: round;
}

.segment-door {
    stroke: #ff9800;
    stroke-width: 3;
    stroke-linecap: round;
}

.segment-window {
    stroke: #2196f3;
    stroke-width: 3;
    stroke-linecap: round;
}

.poi-label {
    font-size: 14px;
    font-weight: bold;
    fill: #2c3e50;
    text-anchor: middle;
    pointer-events: none;
}

.room-label {
    font-size: 12px;
    fill: #666;
    text-anchor: middle;
    pointer-events: none;
}

/* 載入動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 響應式設計 */
@media (max-width: 768px) {
    .projects-list {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ==================== 編輯器樣式 ==================== */

.project-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mode-toggle {
    display: flex;
    gap: 10px;
}

.mode-toggle .btn {
    padding: 8px 16px;
}

/* 編輯工具列 */
.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f0f0;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.toolbar-group {
    display: flex;
    gap: 8px;
}

.editor-toolbar .btn {
    padding: 8px 14px;
    font-size: 13px;
}

.editor-toolbar .btn.active {
    background-color: #2c3e50;
    color: white;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #e67e22;
}

/* 狀態列 */
.editor-status {
    display: flex;
    justify-content: space-between;
    background: #2c3e50;
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 13px;
}

.editor-status span {
    margin-right: 20px;
}

/* 編輯模式 SVG */
.svg-canvas.editor-mode {
    cursor: default;
}

.svg-canvas.mode-select {
    cursor: pointer;
}

.svg-canvas.mode-set_origin {
    cursor: crosshair;
}

.svg-canvas.mode-set_scale {
    cursor: pointer;
}

/* 線段編輯模式樣式 */
.svg-canvas.editor-mode .segment {
    cursor: pointer;
    transition: stroke-width 0.2s;
}

.svg-canvas.editor-mode .segment:hover {
    stroke-width: 5;
}

.svg-canvas.editor-mode .segment.selected {
    stroke: #e74c3c !important;
    stroke-width: 5;
}

.svg-canvas.editor-mode .segment-wall {
    stroke: #333;
    stroke-width: 2;
    stroke-linecap: round;
}

.svg-canvas.editor-mode .segment-door {
    stroke: #ff9800;
    stroke-width: 3;
    stroke-linecap: round;
}

.svg-canvas.editor-mode .segment-window {
    stroke: #2196f3;
    stroke-width: 3;
    stroke-linecap: round;
}

/* 房間編輯模式樣式 */
.svg-canvas.editor-mode .room-polygon {
    transition: fill 0.2s, stroke 0.2s;
}

.svg-canvas.editor-mode .room-polygon:hover {
    fill: rgba(231, 76, 60, 0.2);
}

.svg-canvas.editor-mode .room-polygon.selected {
    fill: rgba(231, 76, 60, 0.3);
    stroke: #e74c3c;
    stroke-width: 3;
}

/* 原點標記 */
.origin-marker {
    pointer-events: none;
}

/* 縮放按鈕 */
.toolbar-group .btn[onclick*="zoom"],
.toolbar-group .btn[onclick*="resetView"] {
    min-width: 40px;
    font-weight: bold;
}

/* 平移提示 */
.svg-canvas.editor-mode {
    cursor: grab;
}

.svg-canvas.editor-mode:active {
    cursor: grabbing;
}

.svg-canvas.editor-mode.mode-set_origin {
    cursor: crosshair;
}

.svg-canvas.editor-mode.mode-select {
    cursor: pointer;
}

/* ==================== 批量選擇樣式 ==================== */

.batch-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f8f9fa;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
}

.batch-toolbar span {
    color: #495057;
    font-weight: 500;
}

.batch-toolbar .btn {
    padding: 6px 12px;
    font-size: 13px;
}

.project-checkbox {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.project-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.project-card.selected {
    border: 2px solid #4CAF50;
    background: #f0fff0;
}

.project-header {
    display: flex;
    align-items: center;
}

/* 房間勾選框樣式 */
.room-checkbox {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.room-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.room-card.selected {
    border: 2px solid #4CAF50;
    background: #f0fff0;
}

.room-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.room-header .room-id {
    cursor: pointer;
    flex: 1;
}

/* ==================== Intelli-Kompass 同步樣式 ==================== */

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

/* 同步 Modal */
.sync-info {
    background: #e3f2fd;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    color: #1565c0;
    font-weight: 500;
}

.floor-options {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal;
}

.radio-group input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #4CAF50;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4CAF50;
}

/* Select 樣式 */
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: #4CAF50;
}

.form-group select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    color: #999;
}

/* 同步結果 */
.sync-result-summary {
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.sync-result-summary.success {
    background: #d4edda;
    color: #155724;
}

.sync-result-summary.partial {
    background: #fff3cd;
    color: #856404;
}

.sync-result-summary h4 {
    margin-bottom: 10px;
    font-size: 18px;
}

.sync-result-summary p {
    margin: 5px 0;
}

.sync-result-details {
    max-height: 300px;
    overflow-y: auto;
}

.sync-result-details table {
    width: 100%;
    border-collapse: collapse;
}

.sync-result-details th,
.sync-result-details td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.sync-result-details th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.sync-result-details tr.success td:nth-child(2) {
    color: #28a745;
    font-weight: 500;
}

.sync-result-details tr.failed td:nth-child(2) {
    color: #dc3545;
    font-weight: 500;
}

.sync-result-details tr.failed {
    background: #fff5f5;
}

/* ==================== 樓層校準樣式 ==================== */

.modal-large {
    max-width: 1400px;
    width: 95%;
}

.calibration-container {
    display: flex;
    gap: 30px;
    min-height: 600px;
}

.calibration-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.calibration-preview .svg-container {
    flex: 1;
    margin: 0;
    min-height: 500px;
    position: relative;
}

.calibration-legend {
    display: flex;
    gap: 20px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.legend-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
}

.calibration-controls {
    width: 350px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.calibration-step {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.calibration-step h4 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 15px;
}

.calibration-step p {
    color: #666;
    font-size: 13px;
    margin-bottom: 12px;
}

.calibration-step .form-group {
    margin-bottom: 10px;
}

.calibration-step .form-group label {
    font-size: 13px;
    font-weight: 500;
}

.calibration-step .form-group input {
    padding: 6px 10px;
    font-size: 13px;
}

/* 原點標記樣式 */
.origin-marker-calibration {
    pointer-events: none;
}

.origin-marker-calibration circle {
    fill: #e74c3c;
}

.origin-marker-calibration line {
    stroke: #e74c3c;
    stroke-width: 2;
}

/* 比例尺線段樣式 */
.scale-line-calibration {
    stroke: #9b59b6;
    stroke-width: 3;
    stroke-dasharray: 8, 4;
    pointer-events: none;
}

/* 樓層外框樣式 */
.floor-boundary-polygon {
    fill: none;
    stroke: #ff6b00;
    stroke-width: 3;
    stroke-dasharray: 10, 5;
    pointer-events: none;
}

/* 走道樣式 */
.corridor-polygon {
    fill: rgba(33, 150, 243, 0.3);
    stroke: #2196F3;
    stroke-width: 2;
    pointer-events: none;
}

/* 校準模式房間樣式 */
.calibration-room-polygon {
    fill: rgba(76, 175, 80, 0.2);
    stroke: #4CAF50;
    stroke-width: 2;
    pointer-events: none;
}

/* 校準模式線段樣式 */
.calibration-segment {
    stroke: #999;
    stroke-width: 1;
    pointer-events: none;
}

@media (max-width: 1200px) {
    .calibration-container {
        flex-direction: column;
    }

    .calibration-controls {
        width: 100%;
    }

    .calibration-preview .svg-container {
        min-height: 400px;
    }
}
