/* 重置與基礎樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00D4AA;
    --secondary-color: #0066FF;
    --accent-color: #FF6B35;
    --dark-bg: #0F1419;
    --card-bg: #1A1F2E;
    --border-color: #2D3748;
    --text-primary: #FFFFFF;
    --text-secondary: #A0AEC0;
    --success-color: #48BB78;
    --warning-color: #ED8936;
    --error-color: #F56565;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 工業風格網格背景 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0,212,170,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,212,170,0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

/* 導航欄 */
.navbar {
    background: rgba(26, 31, 46, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-status {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid;
}

.status-demo {
    background: rgba(237, 137, 54, 0.2);
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.status-debug {
    background: rgba(0, 102, 255, 0.2);
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.status-connected {
    background: rgba(72, 187, 120, 0.2);
    border-color: var(--success-color);
    color: var(--success-color);
}

/* 主要內容區域 */
.main-content {
    margin-top: 80px;
    padding: 2rem;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.main-content.hidden {
    display: none;
}

/* 登入遮罩層 */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-prompt {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.login-prompt h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.login-prompt p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* 卡片樣式 */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 30px rgba(0, 212, 170, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 網格佈局 */
.grid {
    display: grid;
    gap: 2rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* 按鈕樣式 */
.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 212, 170, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
}

.btn-secondary:hover {
    box-shadow: 0 8px 25px rgba(0, 102, 255, 0.4);
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.4);
}

.btn-warning {
    background: var(--warning-color);
}

.btn-warning:hover {
    box-shadow: 0 8px 25px rgba(237, 137, 54, 0.4);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* 表單元素 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

/* 選擇框特殊樣式 */
select.form-input {
    background: var(--card-bg);
    cursor: pointer;
}

select.form-input option {
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 0.5rem;
}

/* 儀表板指標 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.metric-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    display: block;
}

.metric-value.empty {
    color: var(--text-secondary);
    font-weight: normal;
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.metric-change {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.positive {
    color: var(--success-color);
}

.negative {
    color: var(--error-color);
}

/* 圖片上傳和標記區域 */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(0, 212, 170, 0.02);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(0, 212, 170, 0.05);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(0, 212, 170, 0.1);
}

.image-annotation-container {
    position: relative;
    display: inline-block;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.uploaded-image {
    max-width: 100%;
    max-height: 500px;
    display: block;
    object-fit: contain;
    width: auto;
    height: auto;
}

.annotation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.annotation-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: move;
    pointer-events: all;
    transform: translate(-50%, -50%);
}

.marker-fan {
    background: rgba(0, 102, 255, 0.8);
    border-color: var(--secondary-color);
    color: white;
}

.marker-ac {
    background: rgba(0, 212, 170, 0.8);
    border-color: var(--primary-color);
    color: white;
}

.marker-obstacle {
    background: rgba(255, 107, 53, 0.8);
    border-color: var(--accent-color);
    color: white;
}

.marker-sensor {
    background: rgba(72, 187, 120, 0.8);
    border-color: var(--success-color);
    color: white;
}

.annotation-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.marker-count {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 進度條 */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* IoT 感測器狀態 */
.sensor-list {
    display: grid;
    gap: 1rem;
}

.sensor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.sensor-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sensor-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

.sensor-offline {
    background: var(--error-color);
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 分析結果區域 */
.analysis-result {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    padding: 2rem;
    margin: 1rem 0;
}

.recommendations {
    margin-top: 1.5rem;
}

.recommendation-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

/* 載入動畫 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 通知樣式 */
.notification {
    position: fixed;
    top: 100px;
    right: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-color: var(--success-color);
}

.notification.error {
    border-color: var(--error-color);
}

/* Debug 控制台樣式移除 */

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .navbar {
        padding: 1rem;
    }
    
    .nav-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .annotation-controls {
        justify-content: center;
    }
}

/* 隱藏類別 */
.hidden {
    display: none !important;
}

/* 登入註冊彈窗 */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2001;
}

.auth-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form .btn {
    width: 100%;
    margin-top: 1rem;
}

/* 用戶資訊顯示 */
.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.user-menu {
    position: relative;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-width: 150px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    display: none;
}

.user-dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: rgba(0, 212, 170, 0.1);
}
.sensor-add-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.sensor-add-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 450px;
    width: 90%;
}

.qr-scanner-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    margin: 1rem 0;
    background: rgba(0, 212, 170, 0.02);
    cursor: pointer;
    transition: all 0.3s ease;
}

.qr-scanner-area:hover {
    border-color: var(--primary-color);
    background: rgba(0, 212, 170, 0.05);
}
.sensor-selection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.sensor-selection-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.sensor-option {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.sensor-option:hover {
    border-color: var(--primary-color);
    background: rgba(0, 212, 170, 0.1);
}