/* ========================================
   Admin 表單樣式系統
   ======================================== */

/* 頁面標題 */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 2rem;
  background: white;
  border-radius: 1rem;
  border: 2px solid #e5e7eb;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #f3f4f6;
  color: #1f2937;
  text-decoration: none;
  border-radius: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.btn-back:hover {
  background: #e5e7eb;
  transform: translateX(-4px);
}

.btn-back:focus {
  outline: 2px solid #2455A6;
  outline-offset: 2px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  font-size: 0.9375rem;
  color: #6b7280;
}

/* 表單容器 */
.form-container {
  background: white;
  border-radius: 1rem;
  border: 2px solid #e5e7eb;
  padding: 2rem;
}

.admin-form {
  max-width: 900px;
}

/* 表單區塊 */
.form-section {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid #e5e7eb;
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 2rem;
  padding-bottom: 0;
}

.form-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1.5rem;
}

/* 表單行 */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-row:last-child {
  margin-bottom: 0;
}

/* 表單組 */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
}

.form-label.required::after {
  content: ' *';
  color: #dc2626;
}

.form-label-small {
  display: block;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* 表單輸入 */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.875rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 1rem;
  color: #1f2937;
  transition: all 0.2s ease;
  font-family: inherit;
  background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #2455A6;
  box-shadow: 0 0 0 3px rgba(36, 85, 166, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: #9ca3af;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-select {
  cursor: pointer;
}

/* Checkbox 網格 */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-item:hover {
  background: white;
  border-color: #2455A6;
}

.checkbox-item:has(input:checked) {
  background: var(--primary-light);
  border-color: #2455A6;
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #2455A6;
}

.checkbox-item span {
  font-weight: 600;
  color: #374151;
  font-size: 0.9375rem;
}

/* 檔案上傳 */
.file-upload-area {
  border: 2px dashed #e5e7eb;
  border-radius: 0.75rem;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafafa;
}

.file-upload-area:hover {
  border-color: #2455A6;
  background: #f9fafb;
}

.file-upload-area:focus {
  outline: 2px solid #2455A6;
  outline-offset: 2px;
}

.file-upload-placeholder {
  pointer-events: none;
}

.upload-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.file-upload-placeholder p {
  margin: 0.5rem 0;
  color: #374151;
  font-weight: 600;
}

.upload-hint {
  font-size: 0.875rem;
  color: #9ca3af;
  font-weight: 400;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid #e5e7eb;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-remove-image {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-remove-image:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.btn-remove-image:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* 表單按鈕 */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid #e5e7eb;
}

.btn-primary,
.btn-secondary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  border: none;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: #2455A6;
  color: white;
}

.btn-primary:hover {
  background: #1e4a8f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(36, 85, 166, 0.3);
}

.btn-primary:focus {
  outline: 2px solid #2455A6;
  outline-offset: 2px;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-secondary:focus {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

/* Toast 通知 */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  font-weight: 600;
  font-size: 0.9375rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 10000;
  max-width: 400px;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.toast-success {
  border-color: #10b981;
  color: #065f46;
  background: #d1fae5;
}

.toast-error {
  border-color: #ef4444;
  color: #991b1b;
  background: #fee2e2;
}

.toast-info {
  border-color: #3b82f6;
  color: #1e40af;
  background: #dbeafe;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .page-header {
    padding: 1.5rem;
  }

  .form-container {
    padding: 1.5rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}

/* ========================================
   衝突檢測指示器（即時提示）
======================================== */
.clash-indicator {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-radius: 10px;
  font-size: 0.9rem;
  animation: clashIn 0.25s ease;
}

@keyframes clashIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.clash-indicator .clash-ic {
  font-size: 1.1rem;
  line-height: 1.35;
  flex-shrink: 0;
}

.clash-indicator .clash-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.clash-indicator .clash-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.clash-indicator .clash-msg {
  font-size: 0.85rem;
  line-height: 1.45;
}

.clash-ok {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

.clash-soft {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.clash-hard {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

/* 載入失敗 / 重試狀態 */
.clash-error {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}

.clash-retry-btn {
  align-self: flex-start;
  margin-top: 0.5rem;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: #374151;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.clash-retry-btn:hover {
  background: #1f2937;
}

/* 替代時段建議 */
.clash-suggestions {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.18);
}

.suggestions-label {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0.85;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.5rem;
}

.suggestion-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.5rem 0.65rem;
  text-align: left;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.suggestion-btn:hover {
  border-color: #2455a6;
  box-shadow: 0 2px 8px rgba(36, 85, 166, 0.18);
  transform: translateY(-1px);
}

.suggestion-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: #2455a6;
}

.suggestion-time {
  font-size: 0.86rem;
  font-weight: 600;
  color: #111827;
}
