/* ========================================
   VP Booking System - 深色科技感主题
   ======================================== */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a1f35;
  --bg-hover: #242b45;
  --border-color: #2a3050;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --glow-blue: 0 0 20px rgba(59, 130, 246, 0.3);
  --glow-purple: 0 0 20px rgba(139, 92, 246, 0.3);
  --gradient-main: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-bg: linear-gradient(180deg, #0a0e1a 0%, #111827 100%);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  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-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ========== Header ========== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  font-size: 24px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.user-email {
  color: var(--accent-cyan);
  font-weight: 500;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: var(--glow-blue);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

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

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

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 20px;
}

/* ========== Login Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--glow-purple);
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

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

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

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-input {
  flex: 1;
}

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

/* Email input group */
.email-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.email-input-group .form-input {
  border: none;
  border-radius: 0;
  flex: 1;
}
.email-input-group .form-input:focus {
  box-shadow: none;
}
.email-suffix {
  padding: 0 14px;
  color: var(--text-muted);
  font-size: 14px;
  white-space: nowrap;
  background: var(--bg-hover);
  height: 100%;
  display: flex;
  align-items: center;
  padding-top: 10px;
  padding-bottom: 10px;
  border-left: 1px solid var(--border-color);
}

.form-error {
  font-size: 12px;
  color: var(--accent-red);
  margin-top: 4px;
}

/* ========== Calendar ========== */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.calendar-nav {
  display: flex;
  gap: 8px;
}

.calendar-month {
  font-size: 18px;
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  gap: 8px;
}

.calendar-week-header {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.calendar-week-header span {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px;
}

.calendar-week {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  margin-bottom: 6px;
}

.week-label {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px;
}

.week-slots {
  display: flex;
  gap: 6px;
}

.slot {
  flex: 1;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  position: relative;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.slot-date {
  font-size: 11px;
  color: var(--text-muted);
}

.slot-type {
  font-size: 12px;
  font-weight: 500;
}

.slot-available {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
}

.slot-available:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-green);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.slot-booked {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  cursor: not-allowed;
}

.slot-mine {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--accent-blue);
}

.slot-past {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.slot-unavailable {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
}

.slot-blocked {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent-orange);
  cursor: not-allowed;
}

.legend-dot.blocked {
  background: rgba(245, 158, 11, 0.3);
  border: 1px solid var(--accent-orange);
}

.slot-booked-user {
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== Legend ========== */
.legend {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-dot.available {
  background: rgba(16, 185, 129, 0.3);
  border: 1px solid var(--accent-green);
}

.legend-dot.booked {
  background: rgba(239, 68, 68, 0.3);
  border: 1px solid var(--accent-red);
}

.legend-dot.mine {
  background: rgba(59, 130, 246, 0.3);
  border: 1px solid var(--accent-blue);
}

.legend-dot.past {
  background: var(--bg-secondary);
  border: 1px solid var(--text-muted);
}

/* ========== Bookings Table ========== */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  color: var(--text-secondary);
}

tr:hover td {
  background: var(--bg-hover);
}

.status-active {
  color: var(--accent-green);
}

.status-cancelled {
  color: var(--accent-red);
}

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

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.toast-info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== Confirm Dialog ========== */
.confirm-dialog {
  text-align: center;
}

.confirm-dialog p {
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.confirm-dialog .highlight {
  color: var(--accent-cyan);
  font-weight: 600;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* ========== Loading ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

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

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

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

/* ========== Admin Specific ========== */
.admin-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.admin-nav .btn {
  border-radius: 6px 6px 0 0;
}

.admin-nav .btn.active {
  background: var(--accent-blue);
  color: white;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.setting-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.setting-item label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.device-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 8px;
}

.device-info h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.device-info p {
  font-size: 13px;
  color: var(--text-muted);
}

.device-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.device-status.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.device-status.inactive {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.device-actions {
  display: flex;
  gap: 8px;
}

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

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .container {
    padding: 16px;
  }

  .calendar-week-header {
    display: none;
  }

  .calendar-week {
    grid-template-columns: 1fr;
  }

  .week-label {
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 4px 4px;
  }

  .week-slots {
    flex-direction: column;
  }

  .slot {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: auto;
    padding: 10px 14px;
  }

  .legend {
    gap: 12px;
  }

  .form-row {
    flex-direction: column;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-nav {
    overflow-x: auto;
    white-space: nowrap;
  }

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

  th, td {
    padding: 8px 10px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 16px;
  }

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

  .modal {
    padding: 24px 20px;
  }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========== Misc ========== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-16 {
  margin-top: 16px;
}

.mb-16 {
  margin-bottom: 16px;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Mock code display */
.mock-code {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--accent-orange);
  color: var(--accent-orange);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 8px;
}

.mock-hint {
  font-size: 11px;
  color: var(--accent-orange);
  text-align: center;
  margin-top: 4px;
}

/* Admin password change */
.password-change-notice {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 24px;
  color: var(--accent-orange);
  font-size: 14px;
}
