/* 庫存管理系統樣式 */
:root {
  --bg: #f5f5f5;
  --panel: #fff;
  --border: #ddd;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --text: #1f2937;
  --text-muted: #6b7280;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Microsoft JhengHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 1rem;
  line-height: 1.5;
}

#app {
  max-width: 720px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.panel[hidden] {
  display: none;
}

h1, h2 {
  margin-top: 0;
  color: var(--text);
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

/* 登入區 */
#loginSection input {
  display: block;
  width: 100%;
  max-width: 320px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

#loginSection button {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

#loginSection button:hover {
  background: var(--primary-hover);
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.message {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.message.success { color: #059669; }
.message.error { color: var(--danger); }

/* 主畫面：表頭 */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.header h1 { margin-bottom: 0; }

.user-email {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.btn-secondary {
  margin-left: auto;
  padding: 0.4rem 0.75rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: var(--bg);
  color: var(--text);
}

/* 表單 */
#productForm label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--text);
}

#productForm input {
  width: 100%;
  max-width: 280px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

#productForm button[type="submit"] {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

#productForm button[type="submit"]:hover {
  background: var(--primary-hover);
}

/* 列表 */
.list-wrap {
  margin-top: 2rem;
}

#list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.item-info {
  min-width: 0;
}

.item-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.item-value {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 0.5rem;
}

.item-actions button {
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-edit {
  background: #e0e7ff;
  color: var(--primary);
}

.btn-edit:hover {
  background: #c7d2fe;
}

.btn-delete {
  background: #fee2e2;
  color: var(--danger);
}

.btn-delete:hover {
  background: #fecaca;
}

/* 編輯模式：表單內嵌 */
.item-card.edit-mode .item-info,
.item-card.edit-mode .item-value,
.item-card.edit-mode .item-actions .btn-edit {
  display: none;
}

.item-card.edit-mode .item-actions .btn-cancel { display: inline-block; }
.item-card.edit-mode .item-actions .btn-save { display: inline-block; }

.edit-inline {
  display: none;
  grid-column: 1 / -1;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.item-card.edit-mode .edit-inline {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
}

.edit-inline input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.btn-cancel, .btn-save { display: none; }
