/* APPLIX Design System 2026 */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --brand-primary: #2563EB;
  --brand-primary-light: #DBEAFE;
  --brand-primary-dark: #1E40AF;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --border: #E2E8F0;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --success: #16A34A;
  --warning: #D97706;
  --error: #DC2626;
  --info: #0EA5E9;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-color: 0 4px 16px rgba(37,99,235,0.2);
  --font-sans: 'Manrope', system-ui, sans-serif;
  --text-xs: clamp(11px, 2.5vw, 12px);
  --text-sm: clamp(13px, 3vw, 14px);
  --text-base: clamp(15px, 3.5vw, 16px);
  --text-lg: clamp(17px, 4vw, 18px);
  --text-xl: clamp(19px, 4.5vw, 22px);
  --text-2xl: clamp(22px, 5vw, 26px);
  /* iPhone 15 Pro Max safe areas */
  --space-safe-top: env(safe-area-inset-top, 0px);
  --space-safe-bottom: env(safe-area-inset-bottom, 0px);
  --space-safe-left: env(safe-area-inset-left, 0px);
  --space-safe-right: env(safe-area-inset-right, 0px);
  --nav-height: calc(64px + var(--space-safe-bottom));
  --header-height: calc(56px + var(--space-safe-top));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-family: var(--font-sans); font-size: var(--text-base); color: var(--text-primary); background: var(--surface-2); overflow-x: hidden; }
body { margin: 0; padding: 0; overscroll-behavior: none; -webkit-font-smoothing: antialiased; }

/* Safe area helper — adds top padding for notch/dynamic island on iPhone */
.safe-top {
  padding-top: var(--space-safe-top) !important;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

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

/* Slide animations */
@keyframes slideInRight { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes slideInLeft { from { transform: translateX(-100%); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-20px); opacity:0; } to { transform: translateY(0); opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity:0; } to { transform: scale(1); opacity:1; } }
@keyframes confetti { 0% { transform: translateY(0) rotate(0deg); opacity:1; } 100% { transform: translateY(-200px) rotate(720deg); opacity:0; } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.animate-slide-right { animation: slideInRight 0.3s ease-out; }
.animate-slide-left { animation: slideInLeft 0.3s ease-out; }
.animate-slide-up { animation: slideUp 0.35s cubic-bezier(0.32,0.72,0,1); }
.animate-slide-down { animation: slideDown 0.3s ease-out; }
.animate-fade-in { animation: fadeIn 0.25s ease-out; }
.animate-scale-in { animation: scaleIn 0.2s ease-out; }

/* Bottom sheet backdrop */
.backdrop-blur { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* Touch-friendly — increased for iPhone 15 Pro Max */
.tap-target { min-width: 48px; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }

/* Brand color utilities */
.bg-brand { background-color: var(--brand-primary); }
.text-brand { color: var(--brand-primary); }
.border-brand { border-color: var(--brand-primary); }
.bg-brand-light { background-color: var(--brand-primary-light); }
.shadow-brand { box-shadow: var(--shadow-color); }

/* Status badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }

/* Tab bar — with safe area bottom */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: flex-start;
  padding-top: 8px; padding-bottom: var(--space-safe-bottom);
  z-index: 50;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 500; color: var(--text-muted);
  transition: all 0.15s; cursor: pointer; position: relative; padding: 4px 12px;
}
.tab-item.active { color: var(--brand-primary); }
.tab-item.active::before {
  content: ''; position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--brand-primary-light); z-index: -1;
}
.tab-icon { font-size: 20px; }

/* Card */
.card {
  background: white; border-radius: var(--radius-lg); padding: 16px;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(226,232,240,0.5);
  transition: transform 0.1s;
}
.card:active { transform: scale(0.99); }

/* Input */
.input {
  height: 48px; width: 100%; padding: 0 16px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-base);
  outline: none; transition: all 0.15s;
}
.input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.input::placeholder { color: var(--text-muted); }

/* Button */
.btn {
  height: 48px; padding: 0 24px; border-radius: var(--radius-md); font-weight: 600;
  font-family: var(--font-sans); font-size: var(--text-base);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; transition: all 0.15s; border: none; outline: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand-primary); color: white; box-shadow: var(--shadow-color); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: rgba(37,99,235,0.05); color: var(--brand-primary); border: 1px solid rgba(37,99,235,0.3); }
.btn-danger { background: rgba(220,38,38,0.08); color: var(--error); }

/* Header — with safe area top for iPhone notch/Dynamic Island */
.header {
  position: sticky; top: 0; left: 0; right: 0;
  min-height: var(--header-height); 
  padding: var(--space-safe-top) 16px 0 16px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  z-index: 40; font-weight: 700; font-size: var(--text-lg);
}

/* Bottom Sheet */
.bottomsheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 60; animation: fadeIn 0.2s;
}
.bottomsheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-radius: 20px 20px 0 0;
  max-height: 90vh; overflow-y: auto;
  padding: 12px 16px calc(16px + var(--space-safe-bottom));
  z-index: 61; animation: slideUp 0.35s cubic-bezier(0.32,0.72,0,1);
}
.bottomsheet-pill {
  width: 36px; height: 4px; border-radius: 2px;
  background: #CBD5E1; margin: 0 auto 16px;
}

/* Toast — positioned below dynamic island */
.toast {
  position: fixed; top: calc(16px + var(--space-safe-top)); left: 50%; transform: translateX(-50%);
  padding: 12px 20px; border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600;
  z-index: 100; animation: slideDown 0.3s ease-out;
  box-shadow: var(--shadow-lg); max-width: 90vw;
}
.toast-success { background: #16A34A; color: white; }
.toast-error { background: #DC2626; color: white; }
.toast-info { background: #2563EB; color: white; }

/* Page content padding */
.page-content { padding: 0 16px 100px; max-width: 480px; margin: 0 auto; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 500;
  background: var(--surface-3); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s; border: 1px solid transparent;
  white-space: nowrap;
}
.chip.active { background: var(--brand-primary-light); color: var(--brand-primary); border-color: rgba(37,99,235,0.2); }

/* Progress bar */
.progress-bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand-primary); border-radius: 3px; transition: width 0.5s ease-out; }

/* Color picker */
.color-swatch {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  cursor: pointer; transition: transform 0.15s; border: 3px solid transparent;
}
.color-swatch:active { transform: scale(0.9); }
.color-swatch.selected { border-color: var(--text-primary); box-shadow: var(--shadow-md); }

/* Metric card */
.metric-card {
  background: white; border-radius: var(--radius-lg); padding: 14px;
  box-shadow: var(--shadow-sm); flex: 1; min-width: 100px;
}
.metric-value { font-size: var(--text-xl); font-weight: 800; line-height: 1.2; }
.metric-label { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }
.metric-delta { font-size: var(--text-xs); font-weight: 600; }
.metric-delta.up { color: var(--success); }
.metric-delta.down { color: var(--error); }

/* Phone frame */
.phone-frame {
  width: 260px; height: 520px; border-radius: 36px;
  border: 8px solid #1E293B; background: white;
  overflow: hidden; margin: 0 auto; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.phone-notch {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 100px; height: 24px; background: #1E293B;
  border-radius: 0 0 14px 14px; z-index: 5;
}

/* Image upload area */
.img-preview { display: block; }
.img-placeholder { display: flex; }

/* iOS viewport-fit support */
@supports (padding: max(0px)) {
  .header {
    padding-top: max(env(safe-area-inset-top, 0px), 0px);
  }
  .tab-bar {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 0px);
  }
  .toast {
    top: calc(16px + max(env(safe-area-inset-top, 0px), 0px));
  }
}
