/* Genus Appointments & Chat - Main Stylesheet */

/* ==================== CSS VARIABLES ==================== */
:root {
  --primary: #1a365d;
  --primary-light: #2b6cb0;
  --gray-700: #4a5568;
  --gray-600: #718096;
  --gray-400: #a0aec0;
  --gray-200: #e2e8f0;
  --gray-100: #f7fafc;
  --white: #ffffff;
  --success: #38a169;
  --warning: #d69e2e;
  --danger: #e53e3e;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==================== BASE STYLES ==================== */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  background: var(--gray-100);
  color: var(--gray-700);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ==================== HEADER ==================== */
header {
  background: var(--primary);
  color: var(--white);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  height: 64px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.header-tabs {
  display: flex;
  gap: 4px;
}

.header-tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: background 0.2s, color 0.2s;
}

.header-tab:hover { color: var(--white); background: rgba(255,255,255,0.1); }
.header-tab.active { color: var(--white); background: rgba(255,255,255,0.2); }

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

/* ==================== LAYOUT ==================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.main-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

@media (max-width: 900px) { .main-grid { grid-template-columns: 1fr; } }

/* ==================== USER BAR ==================== */
.user-bar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.user-bar label {
  font-weight: 600;
  color: var(--primary);
}

.user-bar select {
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--white);
}

.user-bar select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

/* ==================== BUTTONS ==================== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary-light); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-400); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover:not(:disabled) { background: #2f855a; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #c53030; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ==================== CARDS ==================== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 16px; }

/* ==================== CALENDAR ==================== */
.calendar { width: 100%; }

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-nav button {
  background: var(--gray-200);
  border: none;
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
}

.calendar-nav button:hover { background: var(--gray-400); color: var(--white); }
.calendar-nav .month-label { font-weight: 600; color: var(--primary); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-grid .day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  padding: 4px;
}

.calendar-grid .day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.1s;
  position: relative;
}

.calendar-grid .day:hover { background: var(--gray-200); }
.calendar-grid .day.empty { cursor: default; }
.calendar-grid .day.empty:hover { background: transparent; }
.calendar-grid .day.selected { background: var(--primary-light); color: var(--white); font-weight: 600; }
.calendar-grid .day.today { border: 2px solid var(--primary-light); }
.calendar-grid .day.has-booked { box-shadow: inset 0 0 0 2px var(--gray-400); }
.calendar-grid .day.has-available { box-shadow: inset 0 0 0 2px var(--success); }
.calendar-grid .day.has-booked.has-available { box-shadow: inset 0 0 0 2px var(--warning); }
.calendar-grid .day.avail-selected { box-shadow: inset 0 0 0 2px #fc8181; background: #fff5f5; }
.calendar-grid .day.avail-selected:hover { background: #fed7d7; }

/* ==================== SLOTS ==================== */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.slot-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.slot-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.slot-card .time { font-weight: 600; font-size: 1rem; color: var(--primary); margin-bottom: 4px; }
.slot-card .status { font-size: 0.8rem; color: var(--gray-600); margin-bottom: 8px; }
.slot-card.available { border-left: 4px solid var(--success); }
.slot-card.booked { border-left: 4px solid var(--warning); background: #fffbeb; }
.slot-card .booked-info { font-size: 0.75rem; color: var(--gray-600); margin-top: 4px; }

/* ==================== STATUS BAR ==================== */
.status-bar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-bar .status-text { flex: 1; font-size: 0.9rem; color: var(--gray-600); }

/* ==================== ERROR PANEL ==================== */
.error-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--warning);
  background: #fffbeb;
  color: var(--gray-700);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
}

.error-toggle.hidden { display: none; }

.error-panel {
  margin-top: 12px;
  background: #fff5f5;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.error-panel.hidden { display: none; }

.error-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--danger);
}

.error-report {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 0.8rem;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  background: var(--primary);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
}

.modal-header h2 { margin: 0; font-size: 1.1rem; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body { padding: 20px; }

/* ==================== FORMS ==================== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-700);
  font-size: 0.9rem;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.form-group textarea { resize: vertical; min-height: 80px; }
.form-group .char-count { font-size: 0.75rem; color: var(--gray-600); text-align: right; margin-top: 4px; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

.section-title {
  font-weight: 600;
  color: var(--primary);
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

/* ==================== USER LIST ==================== */
.user-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.user-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.user-list-item:last-child { border-bottom: none; }
.user-list-item .user-info { flex: 1; display: flex; align-items: center; gap: 8px; }
.user-list-item .user-info-text { display: flex; flex-direction: column; }
.user-list-item .user-name { font-weight: 500; color: var(--primary); }
.user-list-item .user-meta { font-size: 0.8rem; color: var(--gray-600); }
.user-list-item .user-actions { display: flex; gap: 6px; }

/* ==================== AVATARS ==================== */
.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gray-200);
  border: 1px solid var(--gray-200);
}

.avatar-sm { width: 40px; height: 40px; }
.avatar.hidden { display: none; }

.user-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.user-summary .user-summary-name {
  font-size: 0.85rem;
  color: var(--gray-600);
}

.user-summary .user-summary-meta {
  font-size: 0.75rem;
  color: var(--gray-600);
}

/* ==================== CHECKBOXES ==================== */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.checkbox-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.checkbox-item input { width: auto; }

/* ==================== ADMIN CALENDAR ==================== */
.admin-calendar-container {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  max-width: 280px;
}

.admin-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.admin-calendar-nav button {
  background: var(--gray-200);
  border: none;
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
}

.admin-calendar-nav button:hover { background: var(--gray-400); color: var(--white); }

#admin-month-label { font-weight: 600; font-size: 0.85rem; color: var(--primary); }

.admin-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 0.75rem;
}

.admin-calendar-grid .adm-day-header {
  text-align: center;
  font-weight: 600;
  color: var(--gray-600);
  padding: 2px;
}

.admin-calendar-grid .adm-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.admin-calendar-grid .adm-day:hover { background: var(--gray-200); }
.admin-calendar-grid .adm-day.empty { cursor: default; }
.admin-calendar-grid .adm-day.empty:hover { background: transparent; }
.admin-calendar-grid .adm-day.adm-selected { background: #fc8181; color: var(--white); font-weight: 600; }
.admin-calendar-grid .adm-day.adm-today { border: 1px solid var(--primary-light); }

.admin-selected-dates {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.8rem;
}

.admin-dates-label { color: var(--gray-600); }
.admin-dates-chips { color: var(--primary); font-weight: 500; }

.admin-date-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fed7d7;
  color: #c53030;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.admin-date-chip button {
  background: none;
  border: none;
  color: #c53030;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
}

/* ==================== CHAT ==================== */
.chat-container { display: flex; flex-direction: column; gap: 16px; }

.context-bar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.context-bar h3 { margin: 0 0 12px; font-size: 0.95rem; color: var(--primary); }
.context-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.context-btn {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.context-btn:hover { border-color: var(--primary-light); }
.context-btn.active { background: var(--primary-light); color: var(--white); border-color: var(--primary-light); }

.chat-messages {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
}

.chat-message {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: var(--radius);
  position: relative;
}

.chat-message.user { background: var(--gray-100); margin-left: 40px; }
.chat-message.assistant { background: #e6f3ff; margin-right: 40px; }

.chat-message .role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.chat-message .content { white-space: pre-wrap; word-break: break-word; }

.chat-message.streaming .content::after {
  content: "▋";
  animation: blink 1s step-end infinite;
  color: var(--primary-light);
}

@keyframes blink { 50% { opacity: 0; } }

.chat-message .delete-msg {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
}

.chat-message .delete-msg:hover { color: var(--danger); }

/* Boost options */
.boost-options {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 12px;
}
.boost-options-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}
.boost-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-100);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--gray-700);
  transition: border-color 0.2s, background 0.2s;
}
.boost-option:hover {
  border-color: var(--primary-light);
  background: var(--white);
}
.boost-option:last-child { margin-bottom: 0; }
.boost-options-close {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--gray-600);
  cursor: pointer;
  text-align: center;
}
.boost-options-close:hover { color: var(--primary); }

.chat-input-area {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.chat-input-row { display: flex; gap: 8px; }

.chat-input-row textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  min-height: 60px;
}

.chat-input-row textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.chat-input-buttons { display: flex; flex-direction: column; gap: 4px; }

/* ==================== QUESTION QUEUE ==================== */
.question-queue {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.question-queue h3 { margin: 0 0 12px; font-size: 0.95rem; color: var(--primary); }
.queue-list { max-height: 150px; overflow-y: auto; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.queue-item:last-child { border-bottom: none; }
.queue-item input[type="checkbox"] { width: auto; flex-shrink: 0; }
.queue-item .queue-text { flex: 1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.queue-item .queue-del {
  background: transparent;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}

.queue-item .queue-del:hover { color: var(--danger); }
.queue-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ==================== MISC ==================== */
.warning-box {
  background: #fffbeb;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.85rem;
  color: var(--gray-700);
  margin-bottom: 16px;
}

.logs-panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
}

.logs-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-top: 8px;
}

.logs-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-200);
}

.logs-item:last-child { border-bottom: none; }
.logs-item input { width: auto; }

.logs-output {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px;
  margin-top: 8px;
  font-size: 0.8rem;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
}
