/* ============================================
   Light Theme (default)
   ============================================ */

:root {
  --gradient-start: #6C63FF;
  --gradient-end: #3F8EFC;
  --bg-gradient: linear-gradient(135deg, #6C63FF 0%, #3F8EFC 100%);
  --bg-page: linear-gradient(160deg, #e8eaf6 0%, #f3e5f5 40%, #e3f2fd 100%);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px rgba(108, 99, 255, 0.08);
  --text-primary: #1a1a2e;
  --text-secondary: #555770;
  --text-muted: #94979e;
  --error: #e74c3c;
  --error-bg: #fdeaec;
  --success: #27ae60;
  --input-bg: rgba(255, 255, 255, 0.6);
  --input-border: rgba(200, 200, 220, 0.5);
  --input-focus: #6C63FF;
  --pill-bg: rgba(255, 255, 255, 0.7);
  --calendar-card-bg: rgba(255, 255, 255, 0.6);
  --calendar-card-checked-bg: rgba(108, 99, 255, 0.08);
  --toggle-bg: rgba(255, 255, 255, 0.5);
  --header-text: #1a1a2e;
  --radius-card: 20px;
  --radius-btn: 14px;
  --radius-pill: 50px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif;
  color-scheme: light;
}

/* ============================================
   Dark Theme
   ============================================ */

[data-theme="dark"] {
  --bg-page: linear-gradient(160deg, #0f0c29 0%, #1a1640 40%, #24243e 100%);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --text-primary: #eaeaff;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.35);
  --error: #ff6b6b;
  --error-bg: rgba(255, 107, 107, 0.12);
  --success: #51cf66;
  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.1);
  --input-focus: #6C63FF;
  --pill-bg: rgba(255, 255, 255, 0.05);
  --calendar-card-bg: rgba(255, 255, 255, 0.05);
  --calendar-card-checked-bg: rgba(108, 99, 255, 0.2);
  --toggle-bg: rgba(255, 255, 255, 0.06);
  --header-text: #ffffff;
  color-scheme: dark;
}

/* ============================================
   Base
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-page);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.3s ease;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ============================================
   Config Error
   ============================================ */

.config-error {
  max-width: 420px;
  margin: 80px auto;
  padding: 20px;
  text-align: center;
}

.config-error h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--error);
  margin-bottom: 16px;
}

.config-error-desc {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.config-error-hint {
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================
   Pages
   ============================================ */

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

/* ============================================
   Glass Card
   ============================================ */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--glass-shadow);
  transition: background 0.3s, border-color 0.3s;
}

/* ============================================
   Login
   ============================================ */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 40px 28px;
}

.login-header {
  margin-bottom: 32px;
}

.login-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--header-text);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: 1px;
}

.input-group {
  margin-bottom: 16px;
}

.login-form .input-field {
  width: 100%;
  text-align: center;
  font-size: 16px;
}

/* ============================================
   Header
   ============================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 12px;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--header-text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--gradient-start);
  background: rgba(108, 99, 255, 0.1);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
  font-family: var(--font);
}

.btn-text:hover {
  color: var(--gradient-start);
  background: rgba(108, 99, 255, 0.08);
}

/* ============================================
   Inputs
   ============================================ */

.input-field {
  width: 100%;
  padding: 14px 16px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-btn);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: all 0.3s;
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-field:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.12);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title-row .card-title {
  margin-bottom: 0;
}

.preset-select {
  padding: 5px 28px 5px 12px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
  transition: all 0.3s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394979e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.preset-select:hover {
  border-color: var(--gradient-start);
  color: var(--gradient-start);
}

.preset-select:focus {
  border-color: var(--gradient-start);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

[data-theme="dark"] .preset-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="dark"] .input-field:focus {
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.2);
}

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

/* ============================================
   Buttons
   ============================================ */

.btn-gradient {
  width: 100%;
  padding: 14px 24px;
  background: var(--bg-gradient);
  border: none;
  border-radius: var(--radius-btn);
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s;
  position: relative;
}

.btn-gradient:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(108, 99, 255, 0.35);
}

.btn-gradient:active:not(:disabled) {
  transform: translateY(0);
}

.btn-gradient:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-submit {
  margin-top: 8px;
  margin-bottom: 24px;
}

.btn-outline {
  padding: 10px 20px;
  background: transparent;
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-btn);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.3s;
}

.btn-outline:hover {
  border-color: var(--gradient-start);
  background: rgba(108, 99, 255, 0.06);
}

/* ============================================
   Card Title
   ============================================ */

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.card-title.clickable {
  width: 100%;
  background: none;
  border: none;
  font-family: var(--font);
  cursor: pointer;
  justify-content: space-between;
  margin-bottom: 0;
}

.card-icon {
  font-size: 18px;
}

/* ============================================
   Members Grid
   ============================================ */

.members-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.member-pill {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--input-border);
  background: var(--pill-bg);
  color: var(--text-secondary);
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
}

.member-pill:hover {
  border-color: var(--gradient-start);
  color: var(--gradient-start);
}

.member-pill.active {
  background: var(--bg-gradient);
  border-color: transparent;
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.btn-select-all {
  margin-top: 10px;
  padding: 6px 16px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.3s;
}

.btn-select-all:hover {
  border-color: var(--gradient-start);
  color: var(--gradient-start);
}

.btn-select-all.active {
  background: var(--bg-gradient);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

/* ============================================
   Title Preview
   ============================================ */

.title-preview {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-muted);
  min-height: 22px;
  transition: all 0.3s;
}

.title-preview.visible {
  color: var(--gradient-start);
  font-weight: 500;
}

/* ============================================
   Time Toggle
   ============================================ */

.time-toggle {
  display: flex;
  gap: 0;
  background: var(--toggle-bg);
  border-radius: var(--radius-btn);
  padding: 4px;
  margin-top: 12px;
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.3s;
}

.toggle-btn.active {
  background: var(--bg-gradient);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(108, 99, 255, 0.25);
}

.time-fields {
  margin-top: 16px;
  animation: fadeIn 0.3s ease;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-group {
  flex: 1;
}

.time-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.time-separator {
  color: var(--text-muted);
  font-size: 18px;
  padding-top: 20px;
}

.date-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-group {
  flex: 1;
}

.date-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ============================================
   Calendar Options
   ============================================ */

.calendar-options {
  display: flex;
  gap: 10px;
}

.calendar-card {
  flex: 1;
  cursor: pointer;
}

.calendar-card input {
  display: none;
}

.calendar-card-inner {
  text-align: center;
  padding: 14px 8px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--input-border);
  background: var(--calendar-card-bg);
  transition: all 0.3s;
}

.calendar-card input:checked + .calendar-card-inner {
  border-color: var(--gradient-start);
  background: var(--calendar-card-checked-bg);
  box-shadow: 0 2px 12px rgba(108, 99, 255, 0.15);
}

.calendar-label {
  font-size: 20px;
  font-weight: 700;
  color: var(--gradient-start);
}

.calendar-name {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   Collapsible Extra Fields
   ============================================ */

.extra-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease, padding-top 0.3s ease;
  max-height: 300px;
  opacity: 1;
  padding-top: 16px;
}

.extra-fields.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
}

.chevron {
  transition: transform 0.3s;
}

.chevron.rotated {
  transform: rotate(180deg);
}

/* ============================================
   Result Card
   ============================================ */

.result-card {
  text-align: center;
  padding: 28px 20px;
}

.result-card.animate-in {
  animation: fadeIn 0.3s ease;
}

.result-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.result-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-title.success {
  color: var(--success);
}

.result-title.error {
  color: var(--error);
}

.result-message {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.6;
  white-space: pre-line;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ============================================
   Error Message
   ============================================ */

.error-msg {
  color: var(--error);
  font-size: 13px;
  margin-top: 10px;
  animation: shake 0.4s ease;
}

/* ============================================
   Validation Error
   ============================================ */

.field-error {
  color: var(--error);
  font-size: 12px;
  margin-top: 6px;
  display: none;
}

.field-error.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

.input-field.invalid {
  border-color: var(--error);
  background: var(--error-bg);
}

/* ============================================
   Spinner
   ============================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.input-field.time-adjusted {
  animation: timeFlash 0.6s ease;
}

@keyframes timeFlash {
  0%, 100% { border-color: var(--input-border); }
  50% { border-color: var(--input-focus); box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.12); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-header p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-card .input-field {
  margin-bottom: 4px;
}

.modal-card .btn-gradient {
  margin-top: 12px;
}

.modal-success {
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.modal-success h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-success p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-success .btn-outline {
  display: inline-block;
}

/* ============================================
   Utility
   ============================================ */

.hidden {
  display: none !important;
}

.content {
  padding-bottom: 40px;
}
