/* ============================================
   ADMIN DASHBOARD — Styles
   Uses same design tokens as main site
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary: #7C6AE8;
  --color-primary-dark: #5B4BC7;
  --color-primary-light: #B8AEFA;
  --color-primary-ultra-light: #F0EEFF;
  --color-primary-glow: rgba(124, 106, 232, 0.15);
  --color-surface: #FFFFFF;
  --color-background: #F4F2FF;
  --color-navy: #0A0A2E;
  --color-text: #1A1A2E;
  --color-text-muted: #6B7280;
  --color-text-light: #9CA3AF;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-info: #3B82F6;
  --color-border: rgba(0, 0, 0, 0.08);
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(124,106,232,0.08);
  --shadow-lg: 0 12px 40px rgba(124,106,232,0.12);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }

/* --- Layout --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-navy);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar__brand {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar__brand-icon {
  width: 36px; height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.sidebar__brand-text {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
}

.sidebar__nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar__section-title {
  padding: 0.75rem 1.5rem 0.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: rgba(255,255,255,0.6);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.sidebar__link:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.sidebar__link.active {
  color: #fff;
  background: rgba(124,106,232,0.15);
  border-left-color: var(--color-primary);
}

.sidebar__link svg {
  width: 20px; height: 20px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.sidebar__badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  min-width: 20px;
  text-align: center;
}

.sidebar__footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.sidebar__avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.sidebar__user-info {
  flex: 1;
  min-width: 0;
}

.sidebar__user-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-navy);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar__hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--color-text);
}

.topbar__hamburger svg {
  width: 24px; height: 24px;
}

/* --- Page Content --- */
.page-content {
  padding: 2rem;
  flex: 1;
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  transition: all var(--transition);
}

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

.stat-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-card__icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.stat-card__icon--purple { background: var(--color-primary-ultra-light); color: var(--color-primary); }
.stat-card__icon--green { background: #D1FAE5; color: var(--color-success); }
.stat-card__icon--amber { background: #FEF3C7; color: var(--color-warning); }
.stat-card__icon--blue { background: #DBEAFE; color: var(--color-info); }
.stat-card__icon--red { background: #FEE2E2; color: var(--color-danger); }

.stat-card__icon svg {
  width: 22px; height: 22px;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.2;
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* --- Card / Panel --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-navy);
}

.card__body {
  padding: 1.5rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; }

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:hover { background: var(--color-primary-dark); }

.btn--secondary {
  background: var(--color-primary-ultra-light);
  color: var(--color-primary);
}
.btn--secondary:hover { background: #E2DDFF; }

.btn--danger {
  background: #FEE2E2;
  color: var(--color-danger);
}
.btn--danger:hover { background: #FECACA; }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn--ghost:hover { background: rgba(0,0,0,0.04); color: var(--color-text); }

.btn--sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}
.btn--sm svg { width: 16px; height: 16px; }

.btn--lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

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

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

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

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--color-primary-ultra-light);
}

.data-table__thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #f3f4f6;
}

.data-table__actions {
  display: flex;
  gap: 0.35rem;
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--available { background: #D1FAE5; color: #065F46; }
.badge--reserved { background: #FEF3C7; color: #92400E; }
.badge--sold { background: #DBEAFE; color: #1E40AF; }
.badge--hidden { background: #F3F4F6; color: #6B7280; }
.badge--open { background: #D1FAE5; color: #065F46; }
.badge--closed { background: #F3F4F6; color: #6B7280; }

/* Product category badges */
.badge--food { background: #D1FAE5; color: #065F46; }
.badge--supplements { background: #FEF3C7; color: #92400E; }
.badge--essentials { background: #DBEAFE; color: #1E40AF; }
.badge--grooming { background: #EDE9FE; color: #5B21B6; }
.badge--cleaning { background: #E0F2FE; color: #0369A1; }
.badge--toys { background: #FCE7F3; color: #9D174D; }

/* --- Forms --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

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

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

.form-hint {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 0.3rem;
}

/* --- Image Upload --- */
.image-upload {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.image-upload:hover {
  border-color: var(--color-primary-light);
  background: var(--color-primary-ultra-light);
}

.image-upload__preview {
  max-width: 200px;
  max-height: 160px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-bottom: 0.75rem;
}

.image-upload__text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.image-upload__text strong {
  color: var(--color-primary);
}

.image-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 46, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-navy);
}

.modal__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal__close:hover {
  background: rgba(0,0,0,0.05);
  color: var(--color-text);
}

.modal__close svg { width: 20px; height: 20px; }

.modal__body {
  padding: 1.5rem;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* --- Toolbar / Filters --- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.toolbar__search {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.toolbar__search svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--color-text-light);
  pointer-events: none;
}

.toolbar__search input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.toolbar__search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.toolbar__filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-btn {
  padding: 0.45rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-body);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--color-text-muted);
}

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

.filter-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.pagination__buttons {
  display: flex;
  gap: 0.35rem;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 280px;
}

.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }
.toast--info { background: var(--color-info); }

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

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}

/* --- Loading Spinner --- */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 2rem auto;
}

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

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-navy) 0%, #1a1a4e 100%);
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  width: 90%;
  max-width: 420px;
}

.login-card__brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-card__logo {
  width: 56px; height: 56px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}

.login-card__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-navy);
}

.login-card__subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
}

.login-card .form-input {
  padding: 0.75rem 1rem;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
  font-size: 0.95rem;
}

.login-error {
  background: #FEE2E2;
  color: var(--color-danger);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  margin-bottom: 1rem;
  display: none;
}

.login-error.visible { display: block; }

/* --- Chat Styles --- */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - var(--topbar-height) - 4rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}

.chat-sidebar {
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.chat-sidebar__header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-sidebar__list {
  flex: 1;
  overflow-y: auto;
}

.chat-convo {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}

.chat-convo:hover { background: var(--color-primary-ultra-light); }
.chat-convo--active { background: var(--color-primary-ultra-light); border-left: 3px solid var(--color-primary); }

.chat-convo__name {
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-convo__time {
  font-size: 0.7rem;
  color: var(--color-text-light);
  font-weight: 400;
}

.chat-convo__preview {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-convo__badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  min-width: 18px;
  text-align: center;
}

.chat-main {
  display: flex;
  flex-direction: column;
}

.chat-main__header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-main__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-msg {
  max-width: 70%;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
}

.chat-msg--visitor {
  background: #F3F4F6;
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg--admin {
  background: var(--color-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg__time {
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 0.25rem;
}

.chat-input-area {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
}

.chat-input-area input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-body);
}

.chat-input-area input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* --- Settings Grid --- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.settings-section {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
}

.settings-section__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar__hamburger {
    display: block;
  }
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-sidebar {
    display: none;
  }
}

@media (max-width: 640px) {
  .page-content {
    padding: 1rem;
  }
  .topbar {
    padding: 0 1rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar__search {
    max-width: none;
  }
}
