/* 全域樣式 */
* { box-sizing: border-box; }

body { font-family: 'Microsoft JhengHei', 'Noto Sans TC', sans-serif; }

/* 側邊欄 */
.sidebar { width: 260px; min-height: 100vh; background: linear-gradient(180deg, #1e3a5f 0%, #2d5a8e 100%); }
.sidebar-item { transition: all 0.2s; border-left: 3px solid transparent; }
.sidebar-item:hover, .sidebar-item.active { background: rgba(255,255,255,0.1); border-left-color: #60a5fa; }

/* 主內容區 */
.main-content { flex: 1; overflow-y: auto; max-height: 100vh; }

/* 卡片 */
.card { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* 按鈕 */
.btn-primary { background: #2563eb; color: white; border-radius: 8px; padding: 8px 16px; font-size: 14px; transition: all 0.2s; border: none; cursor: pointer; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #6b7280; color: white; border-radius: 8px; padding: 8px 16px; font-size: 14px; transition: all 0.2s; border: none; cursor: pointer; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #dc2626; color: white; border-radius: 8px; padding: 8px 16px; font-size: 14px; transition: all 0.2s; border: none; cursor: pointer; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: #16a34a; color: white; border-radius: 8px; padding: 8px 16px; font-size: 14px; transition: all 0.2s; border: none; cursor: pointer; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #d97706; color: white; border-radius: 8px; padding: 8px 16px; font-size: 14px; transition: all 0.2s; border: none; cursor: pointer; }
.btn-warning:hover { background: #b45309; }

/* 表單 */
.form-input { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 12px; font-size: 14px; transition: border-color 0.2s; }
.form-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-label { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 4px; display: block; }
.form-textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 12px; font-size: 14px; resize: vertical; min-height: 120px; transition: border-color 0.2s; }
.form-textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-select { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 12px; font-size: 14px; background: white; }
.form-select:focus { outline: none; border-color: #2563eb; }

/* AI 聊天 */
.chat-container { height: 400px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; background: #f9fafb; }
.chat-message { margin: 8px; padding: 10px 14px; border-radius: 10px; max-width: 85%; word-break: break-word; line-height: 1.6; }
.chat-user { background: #2563eb; color: white; margin-left: auto; }
.chat-assistant { background: white; color: #1f2937; border: 1px solid #e5e7eb; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.chat-assistant pre { white-space: pre-wrap; font-family: inherit; }

/* 章節導覽 */
.section-tab { cursor: pointer; padding: 8px 16px; border-radius: 8px; font-size: 13px; transition: all 0.2s; border: 1px solid transparent; }
.section-tab:hover { background: #eff6ff; border-color: #bfdbfe; }
.section-tab.active { background: #2563eb; color: white; }
.section-tab.completed { border-color: #16a34a; color: #16a34a; }
.section-tab.completed:hover { background: #f0fdf4; }

/* 預算表 */
.budget-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.budget-table th { background: #1e3a5f; color: white; padding: 10px 12px; text-align: left; font-weight: 600; }
.budget-table td { padding: 8px 10px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
.budget-table tr:hover td { background: #f9fafb; }
.budget-table .category-row td { background: #eff6ff; font-weight: 600; color: #1e40af; }
.budget-table .total-row td { background: #fef3c7; font-weight: 700; color: #92400e; }
.budget-input { border: 1px solid transparent; background: transparent; width: 100%; padding: 4px 6px; border-radius: 4px; font-size: 13px; }
.budget-input:focus { border-color: #2563eb; background: white; outline: none; }

/* 模態框 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-box { background: white; border-radius: 16px; max-width: 640px; width: 90%; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }

/* 通知 */
.toast { position: fixed; top: 20px; right: 20px; z-index: 2000; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s ease; max-width: 320px; }
.toast-success { background: #16a34a; color: white; }
.toast-error { background: #dc2626; color: white; }
.toast-info { background: #2563eb; color: white; }
.toast-warning { background: #d97706; color: white; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 登入頁面 */
.login-card { background: white; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); }

/* 徽章 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-community { background: #dbeafe; color: #1e40af; }
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-completed { background: #d1fae5; color: #065f46; }

/* 統計卡 */
.stat-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border-left: 4px solid; }
.stat-card-blue { border-left-color: #2563eb; }
.stat-card-green { border-left-color: #16a34a; }
.stat-card-orange { border-left-color: #d97706; }
.stat-card-purple { border-left-color: #7c3aed; }

/* 進度列 */
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 3px; transition: width 0.5s ease; }

/* 捲軸美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 表格編輯輸入框 */
.inline-edit { border: none; background: transparent; width: 100%; font-size: 13px; }
.inline-edit:focus { outline: 1px solid #2563eb; background: white; border-radius: 3px; }

/* 響應式 */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .modal-box { width: 95%; margin: 10px; }
}

/* Loading spinner */
.spinner { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 章節內容區 */
.section-content-area { border: 1px solid #e5e7eb; border-radius: 8px; background: white; }
.section-header { background: linear-gradient(135deg, #1e3a5f, #2563eb); color: white; padding: 12px 16px; border-radius: 8px 8px 0 0; }

/* AI 打字效果 */
.typing-cursor::after { content: '▊'; animation: blink 1s step-end infinite; }
@keyframes blink { from, to { opacity: 1; } 50% { opacity: 0; } }

/* 分隔線 */
.divider { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }

/* 拖放 */
.drag-over { border: 2px dashed #2563eb; background: #eff6ff; }

/* 提示文字 */
.help-text { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* 狀態指示 */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot-green { background: #16a34a; }
.status-dot-yellow { background: #d97706; }
.status-dot-red { background: #dc2626; }
