/**
 * app.css — Fawnly Design System
 * Clean, confident, warm slate blue brand. High readability.
 * Font: Inter — sharp, professional, great at small sizes.
 */

/* ─── Fonts ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── Design tokens ─────────────────────────────────────────────────────── */
:root {
  /* Backgrounds — warm cream */
  --bg:            #fdfcfa;
  --bg-warm:       #f7f6f3;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  /* Text — dark, high contrast, easy to read */
  --text-heading:   #0f172a;
  --text-body:      #1e293b;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  /* Brand — dark slate */
  --brand:          #1e293b;
  --brand-hover:    #0f172a;
  --brand-bg:       #f1f5f9;
  --brand-border:   #cbd5e1;
  --brand-soft:     #e2e8f0;

  /* Accent — amber for warmth */
  --accent:         #f59e0b;
  --accent-hover:   #d97706;
  --accent-bg:      #fffbeb;
  --accent-border:  #fde68a;

  /* Semantic */
  --success:        #059669;
  --success-hover:  #047857;
  --success-bg:     #ecfdf5;
  --success-border: #a7f3d0;

  --warning:        #d97706;
  --warning-bg:     #fffbeb;
  --warning-border: #fde68a;
  --warning-text:   #92400e;

  --danger:         #dc2626;
  --danger-hover:   #b91c1c;
  --danger-bg:      #fef2f2;
  --danger-border:  #fecaca;

  /* Sizing */
  --sidebar-width: 256px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-pill: 999px;

  /* Shadows — subtle, professional */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

  /* Motion — subtle, fast */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.12s;
  --duration-normal: 0.2s;
  --duration-slow: 0.3s;
}

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

/* ─── Base ───────────────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ─── App layout ─────────────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────────────────────────────  */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.sidebar .logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-heading);
  text-decoration: none;
  letter-spacing: -0.4px;
  display: block;
  margin-bottom: 28px;
  padding: 8px 12px;
  flex-shrink: 0;
}
.sidebar .logo span { color: var(--brand); }

.sidebar-nav { list-style: none; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all var(--duration-fast) var(--ease-smooth);
}
.sidebar-nav li a:hover {
  background: var(--bg-warm);
  color: var(--text-body);
}
.sidebar-nav li a.active {
  background: var(--brand-bg);
  color: var(--brand);
  font-weight: 600;
}
.sidebar-nav li a .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity var(--duration-fast);
}
.sidebar-nav li a:hover .nav-icon,
.sidebar-nav li a.active .nav-icon { opacity: 1; }
.sidebar-nav li a.active .nav-icon { color: var(--brand); }
.sidebar-nav li a .icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }

.sidebar-user {
  margin-top: auto;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.sidebar-user-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-text { min-width: 0; flex: 1; }
.sidebar-user .user-name  { font-size: 13px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-biz   { font-size: 11px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-tier  {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--brand);
}
.sidebar-user a[href*="logout"] {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-smooth);
  border: 1px solid transparent;
}
.sidebar-user a[href*="logout"]:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

/* ─── Main content ────────────────────────────────────────────────────────  */
.main {
  margin-left: var(--sidebar-width);
  padding: 0;
  flex: 1;
  min-width: 0;
}
.main-body {
  padding: 32px 40px;
  animation: fadeUp var(--duration-slow) var(--ease-smooth);
}
.main-inner {
  max-width: 860px;
}

/* ─── Page header zone ─────────────────────────────────────────────────────  */
.page-header-zone {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 40px 24px;
  animation: fadeIn var(--duration-normal) var(--ease-smooth);
}
.page-header {
  max-width: 860px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
}
.page-header-inner { min-width: 0; }
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.3px;
  line-height: 1.3;
}
.page-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
}

/* ─── Cards ────────────────────────────────────────────────────────────────  */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-normal) var(--ease-smooth);
}
.card:hover {
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: -0.1px;
  margin-bottom: 4px;
}
.card .desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 400;
  line-height: 1.5;
}

.card-brand-tint {
  background: var(--brand-bg);
  border-color: var(--brand-border);
}

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: -4px;
  margin-bottom: 12px;
}
.label-opt {
  font-weight: 400;
  color: var(--text-muted);
}
.preview-loading-msg {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 6px 0;
}

/* ─── Form elements ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { margin-bottom: 6px; }
.form-group > *:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-heading);
}
label .label-hint {
  font-weight: 400;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  font-weight: 400;
  background: var(--surface);
  color: var(--text-body);
  margin-bottom: 12px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="url"]::placeholder,
textarea::placeholder { color: var(--text-muted); }

input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30,41,59,0.12);
}

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-smooth);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-body);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-warm); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-warm); color: var(--text-body); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-pill { border-radius: var(--radius-pill); }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-normal) var(--ease-smooth), transform var(--duration-normal) var(--ease-smooth);
  pointer-events: none;
  max-width: 360px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
}
.toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { background: var(--text-heading); color: #fff; }
.toast.error   { background: var(--danger); color: #fff; }
.toast.info    { background: var(--brand); color: #fff; }
.toast.show { opacity: 1; transform: translateY(0); display: block; pointer-events: auto; }

/* ─── Skeleton shimmer ──────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk, .skeleton-line, .skeleton {
  background: linear-gradient(90deg, var(--bg-warm) 25%, var(--surface) 50%, var(--bg-warm) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ─── Mobile top bar ───────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  z-index: 1001;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.mobile-header .logo {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-heading);
  text-decoration: none;
  letter-spacing: -0.4px;
}
.mobile-header .logo span { color: var(--brand); }

.hamburger {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  line-height: 1;
  font-size: 18px;
  color: var(--text-body);
}
.hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-body);
  margin: 3px 0;
  border-radius: 1px;
}

.quick-action-chip .chip-svg { flex-shrink: 0; }

/* ─── Sidebar backdrop (mobile/tablet overlay) ────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1001;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-smooth);
}
.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

/* ─── Tablet + Mobile breakpoint ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .mobile-header { display: flex; }
  .hamburger { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-smooth);
    z-index: 1002;
    padding-bottom: 80px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: translateX(0); }

  .page-header-zone {
    padding: 20px 20px;
    padding-top: 64px;
  }
  .main-body { padding: 24px 20px; }
  .main { margin-left: 0; }

  /* Prevent iOS auto-zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="url"],
  textarea,
  select { font-size: 16px; }

  /* Ensure minimum tap target for buttons */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
}

/* ─── Small mobile breakpoint ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sidebar { width: 260px; }
  .page-header-zone { padding: 16px 14px; padding-top: 62px; }
  .page-header h1 { font-size: 20px; }
  .main-body { padding: 16px 14px; }
  .card { padding: 16px 18px; }
}

/* ─── Location switcher ─────────────────────────────────────────────────── */
.location-switcher {
  margin: 8px 0 16px;
  position: relative;
}
.location-switcher-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-heading);
  transition: all var(--duration-fast) var(--ease-smooth);
}
.location-switcher-btn:hover { border-color: var(--border-strong); background: var(--bg-warm); }
.location-switcher-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.location-switcher-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}
.location-switcher-chevron {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
  transition: transform 0.2s;
}
.location-switcher-btn[aria-expanded="true"] .location-switcher-chevron { transform: rotate(180deg); }

.location-switcher-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
  animation: scaleIn var(--duration-fast) var(--ease-smooth);
}
.location-switcher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-body);
  transition: background var(--duration-fast);
}
.location-switcher-item:hover { background: var(--bg-warm); }
.location-switcher-item.active { background: var(--brand-bg); color: var(--brand); font-weight: 600; }
.location-switcher-item-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.location-switcher-check { font-size: 13px; color: var(--brand); margin-left: 8px; width: 16px; text-align: center; }
.location-switcher-add {
  display: block;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  font-size: 13px;
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}
.location-switcher-add:hover { background: var(--bg-warm); border-radius: var(--radius-sm); }

@media (max-width: 1024px) {
  .location-switcher-dropdown {
    position: fixed;
    top: auto;
    bottom: 60px;
    left: 8px; right: 8px;
    border-radius: var(--radius-xl);
  }
}

/* ─── Utility: staggered entrance ────────────────────────────────────────── */
.animate-in {
  animation: fadeUp var(--duration-slow) var(--ease-smooth) backwards;
}
.animate-in:nth-child(1) { animation-delay: 0s; }
.animate-in:nth-child(2) { animation-delay: 0.04s; }
.animate-in:nth-child(3) { animation-delay: 0.08s; }
.animate-in:nth-child(4) { animation-delay: 0.12s; }
.animate-in:nth-child(5) { animation-delay: 0.16s; }
.animate-in:nth-child(6) { animation-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
