:root {
  --primary-green: #4CAF50;
  --primary-blue: #2196F3;
  --bg-color: #F3F4F6;
  --text-color: #1F2937;
  --border-color: #E5E7EB;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #e0e0e0;
  margin: 0;
  display: flex;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
}

/* 手機容器 */
.app-container {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* 標題列 */
.header {
  background-color: #1F2937;
  color: white;
  padding: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 10;
}
.header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header .subtitle {
  font-size: 12px;
  color: #9CA3AF;
  margin-top: 4px;
  margin-left: 28px;
}

/* 主內容區 */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 80px;
  position: relative;
}

/* 分頁顯示控制 */
.view-section {
  display: none;
  padding: 15px;
  animation: fadeIn 0.3s ease;
}
.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 卡片樣式 */
.card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border-color);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #4B5563;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 4px solid var(--primary-green);
  display: flex;
  align-items: center;
}

/* 表單元件 */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  color: #6B7280;
  margin-bottom: 6px;
}
.form-group label .required {
  color: red;
}
.input-control {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  background: white;
  appearance: none;
}
.input-control:focus {
  outline: none;
  border-color: var(--primary-green);
}

/* 下拉選單容器 */
.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: "▼";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #666;
  font-size: 12px;
}

/* 唯讀欄位 */
.read-only-box {
  background-color: #F9FAFB;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  color: #111827;
  font-weight: bold;
  font-family: monospace;
  font-size: 16px;
}

/* 方向切換按鈕 */
.toggle-group {
  display: flex;
  background: #F3F4F6;
  padding: 4px;
  border-radius: 8px;
}
.toggle-btn {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 6px;
  font-size: 14px;
  color: #6B7280;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
}
.toggle-btn.active {
  background: white;
  color: var(--primary-green);
  font-weight: bold;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 時間輸入列 */
.time-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.time-row .input-wrapper {
  flex: 1;
}
.time-row .input-wrapper label {
  display: block;
  font-size: 13px;
  color: #6B7280;
  margin-bottom: 6px;
}
.now-btn {
  padding: 0 12px;
  height: 44px;
  background: #EFF6FF;
  color: #2563EB;
  border: 1px solid #DBEAFE;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.now-btn:active {
  background: #DBEAFE;
}

/* 照片上傳 */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.photo-upload-btn {
  height: 100px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  background: #fafafa;
  color: #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.photo-upload-btn:hover {
  border-color: var(--primary-green);
  background: #f0fff0;
}
.photo-upload-btn.has-photo {
  border-style: solid;
  border-color: var(--primary-green);
}
.photo-upload-btn img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-upload-btn input[type="file"] {
  display: none;
}
.photo-upload-btn .icon {
  font-size: 24px;
  margin-bottom: 4px;
}
.photo-upload-btn .label {
  font-size: 12px;
}

/* 送出按鈕 */
.submit-btn {
  width: 100%;
  padding: 16px;
  background-color: var(--primary-green);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgba(76, 175, 80, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.submit-btn:active {
  transform: scale(0.98);
}
.submit-btn:disabled {
  background-color: #9CA3AF;
  box-shadow: none;
  cursor: not-allowed;
}

/* 底部導航 */
.nav-bar {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60px;
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  z-index: 20;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #9CA3AF;
  font-size: 12px;
  cursor: pointer;
  border: none;
  background: transparent;
}
.nav-item.active-form {
  color: var(--primary-green);
}
.nav-item.active-history {
  color: var(--primary-blue);
}
.nav-icon {
  font-size: 24px;
  margin-bottom: 2px;
}

/* 歷史紀錄樣式 */
.filter-bar {
  position: sticky;
  top: 0;
  background: white;
  padding: 12px 15px;
  z-index: 5;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}
.filter-bar .input-control {
  font-size: 14px;
  padding: 8px;
}

.history-card {
  background: white;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 12px;
  border-left: 4px solid var(--primary-blue);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}
.history-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.history-card:active {
  transform: translateY(0);
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #E5E7EB;
}
.history-date {
  font-weight: bold;
  color: #374151;
}

.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}
.tag-red { background: #FEE2E2; color: #DC2626; }
.tag-green { background: #DCFCE7; color: #166534; }

.history-body {
  display: flex;
  gap: 12px;
}
.history-info {
  flex: 1;
  min-width: 0;
}
.history-photo {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
}
.history-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-row {
  font-size: 14px;
  color: #4B5563;
  margin-bottom: 4px;
  display: flex;
}
.history-label {
  color: #9CA3AF;
  width: 60px;
  flex-shrink: 0;
}

.history-action {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #E5E7EB;
  text-align: right;
}
.edit-hint {
  font-size: 12px;
  color: #9CA3AF;
}
.history-card:hover .edit-hint {
  color: var(--primary-blue);
}

.no-data {
  text-align: center;
  color: #999;
  margin-top: 40px;
  padding: 20px;
}

/* Loading 狀態 */
.loading {
  text-align: center;
  padding: 20px;
  color: #666;
}

/* Toast 訊息 */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  animation: toastIn 0.3s ease;
}
.toast.success {
  background: rgba(76, 175, 80, 0.9);
}
.toast.error {
  background: rgba(220, 38, 38, 0.9);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
