/* ─── FitCheck — Tablet-First Design System ─── */

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

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-hover: #F5F5F3;
  --border: #E8E6E1;
  --border-light: #F0EEEA;
  --text: #1A1A1A;
  --text-secondary: #6B6B6B;
  --text-muted: #999999;
  --accent: #C47A5A;
  --accent-hover: #B0694B;
  --accent-light: #F5EDE8;
  --success: #4A9E6F;
  --warning: #D4A843;
  --danger: #C75454;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --nav-height: 72px;
  --sidebar-width: 240px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ─── Typography ─── */
h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.125rem; font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }

/* ─── Layout Shell ─── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--nav-height) 1fr;
  min-height: 100dvh;
}

/* ─── Top Nav ─── */
.top-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.top-nav__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-nav__logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.top-nav__logo span { color: var(--accent); }

.top-nav__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border);
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  overflow-y: auto;
}

.sidebar__nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all 0.15s ease;
}

.sidebar__link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar__link.active {
  background: var(--accent-light);
  color: var(--accent);
}

.sidebar__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ─── Main Content ─── */
.main-content {
  padding: 32px;
  overflow-y: auto;
  max-height: calc(100dvh - var(--nav-height));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 { margin: 0; }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card--interactive {
  transition: all 0.2s ease;
}

.card--interactive:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

/* ─── Grid Layouts ─── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── Stat Cards (Dashboard) ─── */
.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card__label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9375rem;
  border: none;
  transition: all 0.15s ease;
}

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

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

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

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-icon { padding: 10px; border-radius: var(--radius-sm); }

/* ─── Wardrobe Grid ─── */
.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.wardrobe-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  cursor: pointer;
}

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

.wardrobe-item__image {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--bg);
}

.wardrobe-item__info {
  padding: 12px;
}

.wardrobe-item__name {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 2px;
}

.wardrobe-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.wardrobe-item__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
}

/* ─── Outfit Preview ─── */
.outfit-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}

.outfit-card__preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  background: var(--border-light);
}

.outfit-card__preview img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.outfit-card__body {
  padding: 16px;
}

.outfit-card__title {
  font-weight: 600;
  margin-bottom: 4px;
}

.outfit-card__occasion {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.outfit-card__rating {
  display: flex;
  gap: 2px;
  margin-top: 8px;
}

/* ─── Upload Zone ─── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.upload-zone__text {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.upload-zone__text strong {
  color: var(--accent);
}

/* ─── Calendar ─── */
.calendar-week {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-week__header {
  background: var(--surface);
  padding: 12px 8px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.calendar-week__header.today {
  color: var(--accent);
}

.calendar-week__time {
  background: var(--surface);
  padding: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.calendar-event {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 8px;
  font-size: 0.8125rem;
  margin: 2px;
}

.calendar-event__title { font-weight: 500; }
.calendar-event__outfit {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ─── Weather Widget ─── */
.weather-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.weather-widget__temp {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
}

.weather-widget__details {
  flex: 1;
}

.weather-widget__condition {
  font-weight: 500;
  margin-bottom: 2px;
}

.weather-widget__range {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ─── Today's Outfit ─── */
.today-outfit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
}

.today-outfit__visual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.today-outfit__item {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}

.today-outfit__item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}

.today-outfit__item-label {
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
}

.today-outfit__info h2 { margin-bottom: 12px; }

.today-outfit__reason {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.7;
}

.today-outfit__actions {
  display: flex;
  gap: 12px;
}

/* ─── Try-On Viewer ─── */
.tryon-viewer {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.tryon-viewer__model {
  flex: 1;
  aspect-ratio: 3/4;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.tryon-viewer__model img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tryon-viewer__controls {
  width: 320px;
  flex-shrink: 0;
}

.tryon-viewer__rotate {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

/* ─── Form Elements ─── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B6B' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ─── Tags / Chips ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: #FFF;
  border-color: var(--accent);
}

/* ─── Filter Bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-bar__search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.filter-bar__search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.filter-bar__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

/* ─── Empty States ─── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--text-secondary);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  color: var(--text-muted);
}

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

/* ─── Loading Spinner ─── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250,250,248,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

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

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #FFF;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

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

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

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
}

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

.modal__body { padding: 24px; }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ─── Login Page ─── */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  text-align: center;
  padding: 48px;
  max-width: 420px;
  width: 100%;
}

.login-card__logo {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card__logo span { color: var(--accent); }

.login-card__tagline {
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text);
  transition: all 0.15s ease;
  width: 100%;
  justify-content: center;
}

.btn-google:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--text-muted);
}

.btn-google svg { width: 20px; height: 20px; }

/* ─── Settings ─── */
.settings-section {
  margin-bottom: 32px;
}

.settings-section__title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── Tablet Responsive (primary breakpoint) ─── */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--nav-height) 1fr 64px;
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0;
    z-index: 100;
    background: var(--surface);
  }

  .sidebar__nav {
    flex-direction: row;
    justify-content: space-around;
    padding: 8px 0;
    gap: 0;
  }

  .sidebar__link {
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    font-size: 0.6875rem;
    text-align: center;
  }

  .sidebar__icon { width: 24px; height: 24px; }

  .main-content {
    padding: 20px;
    max-height: calc(100dvh - var(--nav-height) - 64px);
    padding-bottom: 80px;
  }

  .grid-4 { grid-template-columns: repeat(3, 1fr); }
  .today-outfit { grid-template-columns: 1fr; }
  .tryon-viewer { flex-direction: column; }
  .tryon-viewer__controls { width: 100%; }
}

/* ─── Phone ─── */
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .wardrobe-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  h1 { font-size: 1.5rem; }
}

/* ─── Utility ─── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
