/* Photo OCR - 樣式表 */

/* 全域設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4A90E2;
    --secondary-color: #50E3C2;
    --danger-color: #E74C3C;
    --text-color: #2C3E50;
    --bg-color: #F5F7FA;
    --card-bg: #FFFFFF;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 容器 */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* 標題區 */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    color: #7F8C8D;
    font-size: 0.95rem;
}

/* 模式選擇器 */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid transparent;
    background: var(--bg-color);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

/* 相機區域 */
.camera-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* 上方相機控制按鈕區 */
.camera-control-top {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* 下方相機控制按鈕區 */
.camera-control-bottom {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

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

.control-btn.success {
    background: #27AE60;
    color: white;
}

.control-btn.secondary {
    background: #95A5A6;
    color: white;
}

.control-btn.file-btn {
    background: var(--secondary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.control-btn:active {
    transform: translateY(0);
}

.camera-container {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    min-height: 200px;
}

#video {
    width: 100%;
    display: block;
    max-height: 400px;
    object-fit: cover;
}

/* 載入指示器 */
.loading {
    text-align: center;
    padding: 40px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 結果區域 */
.result-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.result-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.result-content {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
}

.result-item {
    margin-bottom: 15px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.result-item strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 5px;
}

.confidence {
    color: var(--secondary-color);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* 動作按鈕 */
.result-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--primary-color);
    color: white;
}

.action-btn.secondary {
    background: #95A5A6;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* 錯誤區域 */
.error-section {
    background: #FADBD8;
    border: 2px solid var(--danger-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

#errorMessage {
    color: var(--danger-color);
    margin-bottom: 15px;
    font-weight: 500;
}

/* 頁尾 */
.footer {
    text-align: center;
    padding: 20px;
    color: #95A5A6;
    font-size: 0.85rem;
    background: var(--card-bg);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* 響應式設計 */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .mode-selector {
        flex-direction: column;
    }

    .mode-btn {
        width: 100%;
    }

    .result-actions {
        flex-direction: column;
    }
}

/* 工具提示 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.8rem;
    z-index: 100;
}
