/* ===== 坤宁堂 TCM Clinic Queue System - Styles ===== */

:root {
  --primary: #8B4513;
  --primary-light: #A0522D;
  --primary-dark: #5C2C0E;
  --accent: #D4A574;
  --accent-light: #E8C9A0;
  --bg: #FDF8F0;
  --bg-card: #FFFFFF;
  --bg-soft: #F5EDDE;
  --text: #2D1B0E;
  --text-light: #6B5544;
  --text-muted: #9C8B7A;
  --success: #4A7C59;
  --success-light: #E8F5E9;
  --danger: #C0392B;
  --danger-light: #FDEDEC;
  --warning: #E67E22;
  --warning-light: #FFF3E0;
  --info: #2980B9;
  --info-light: #EBF5FB;
  --border: #E8DCC8;
  --border-light: #F0E8D8;
  --shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
  --shadow-lg: 0 4px 20px rgba(139, 69, 19, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

/* Prevent flash on re-render */
.page, .auth-page {
  animation: none;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(200, 16, 46, 0); }
}

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

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
}

.header-brand .logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary-dark);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.3);
  font-weight: 600;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user .avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 600;
}

.header-user .user-name {
  font-size: 14px;
  opacity: 0.95;
}

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page {
  animation: fadeIn 0.4s ease;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* ===== Forms ===== */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-card);
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

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

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

.form-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: var(--primary-dark);
}

.btn-accent:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #3D6B4E;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #A93226;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 17px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Auth Pages ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--primary-dark) 100%);
  padding: 20px;
}

.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.5s ease;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-circle {
  width: 64px;
  height: 64px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 24px;
  color: var(--primary-dark);
  font-weight: 700;
  letter-spacing: 3px;
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ===== Role Selector ===== */
.role-selector {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.role-card {
  flex: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.role-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.role-card.active {
  border-color: var(--primary);
  background: var(--bg-soft);
}

.role-card .role-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.role-card .role-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--primary-dark);
}

.role-card .role-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Queue Display ===== */
.queue-display {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.queue-display::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: rgba(212, 165, 116, 0.1);
  border-radius: 50%;
}

.queue-label {
  font-size: 14px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
  position: relative;
}

.queue-number {
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  position: relative;
}

.queue-status {
  font-size: 18px;
  opacity: 0.9;
  position: relative;
}

.queue-status.calling {
  animation: ring 1.5s infinite;
}

/* ===== Ticket Card ===== */
.ticket-card {
  background: linear-gradient(135deg, #fff 0%, var(--bg-soft) 100%);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  position: relative;
}

.ticket-card .ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.ticket-card .clinic-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
}

.ticket-card .ticket-date {
  font-size: 12px;
  color: var(--text-muted);
}

.ticket-card .ticket-number {
  font-size: 56px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin: 12px 0;
}

.ticket-card .ticket-label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ticket-card .ticket-info {
  display: flex;
  justify-content: space-around;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.ticket-card .ticket-info-item {
  text-align: center;
}

.ticket-card .ticket-info-item .label {
  font-size: 12px;
  color: var(--text-muted);
}

.ticket-card .ticket-info-item .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary-dark);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Queue List ===== */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  transition: var(--transition);
  animation: slideIn 0.3s ease;
}

.queue-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.queue-item.current {
  background: var(--success-light);
  border-color: var(--success);
  animation: pulse 2s infinite;
}

.queue-item.called {
  background: var(--warning-light);
  border-color: var(--warning);
}

.queue-item.skipped {
  opacity: 0.5;
  background: var(--danger-light);
}

.queue-item.served {
  opacity: 0.5;
  background: var(--bg-soft);
}

.queue-item .item-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  min-width: 60px;
}

.queue-item .item-info {
  flex: 1;
  margin-left: 12px;
}

.queue-item .item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.queue-item .item-time {
  font-size: 12px;
  color: var(--text-muted);
}

.queue-item .item-actions {
  display: flex;
  gap: 6px;
}

.queue-item .item-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.status-waiting {
  background: var(--info-light);
  color: var(--info);
}

.status-called {
  background: var(--warning-light);
  color: var(--warning);
}

.status-serving {
  background: var(--success-light);
  color: var(--success);
}

.status-served {
  background: var(--bg-soft);
  color: var(--text-muted);
}

.status-skipped {
  background: var(--danger-light);
  color: var(--danger);
}

/* ===== Countdown Timer ===== */
.countdown {
  font-size: 14px;
  color: var(--warning);
  font-weight: 600;
}

.countdown.urgent {
  color: var(--danger);
  animation: pulse 1s infinite;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state .empty-text {
  font-size: 15px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  min-width: 280px;
  max-width: 400px;
  border-left: 4px solid var(--info);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

.modal-body {
  margin-bottom: 24px;
  color: var(--text-light);
  font-size: 15px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ===== Grid Layouts ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .role-selector {
    flex-direction: column;
  }
  .header {
    padding: 0 12px;
  }
  .header-brand {
    font-size: 18px;
  }
  .header-user .user-name {
    display: none;
  }
  .container {
    padding: 16px;
  }
  .queue-number {
    font-size: 56px;
  }
  .ticket-card .ticket-number {
    font-size: 44px;
  }
}

/* ===== Clinic Info Bar ===== */
.clinic-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: 14px;
}

.clinic-info-bar .info-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
}

.clinic-info-bar .info-item strong {
  color: var(--primary-dark);
}

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 16px 0;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-open {
  background: var(--success-light);
  color: var(--success);
}

.badge-closed {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}
