@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 0 0% 7%;

    --card: 0 0% 100%;
    --card-foreground: 0 0% 7%;

    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 7%;

    --primary: 168 55% 44%;
    --primary-foreground: 0 0% 100%;
    --primary-muted: 168 40% 96%;

    --secondary: 220 14% 96%;
    --secondary-foreground: 0 0% 20%;

    --muted: 220 14% 96%;
    --muted-foreground: 0 0% 45%;

    --accent: 168 40% 96%;
    --accent-foreground: 168 55% 34%;

    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 100%;

    --success: 152 55% 42%;
    --success-foreground: 0 0% 100%;
    --success-muted: 152 40% 96%;

    --owe: 0 72% 58%;
    --owe-foreground: 0 0% 100%;
    --owe-muted: 0 50% 97%;

    --border: 0 0% 93%;
    --input: 0 0% 93%;
    --ring: 168 55% 44%;

    --radius: 1rem;

    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-primary: 240 5.9% 10%;
    --sidebar-primary-foreground: 0 0% 98%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

@layer base {
  * {
    border-color: hsl(var(--border));
  }
  html {
    height: 100%;
    -webkit-tap-highlight-color: transparent;
  }
  body {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100%;
    min-height: 100dvh;
    overscroll-behavior-y: none;
    touch-action: manipulation;
  }
  [x-cloak] {
    display: none !important;
  }
}

@layer components {
  .apple-card {
    background: hsl(var(--card));
    border-radius: 20px;
    box-shadow: 0 1px 3px hsl(0 0% 0% / 0.04), 0 4px 12px hsl(0 0% 0% / 0.03);
  }
  .apple-card-inset {
    border-radius: 1rem;
    background: color-mix(in oklab, hsl(var(--secondary)) 60%, transparent);
  }
  .section-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: hsl(var(--muted-foreground));
  }
  .subtle-divider {
    border-top-width: 1px;
    border-color: color-mix(in oklab, hsl(var(--border)) 60%, transparent);
  }
  .balance-positive {
    color: hsl(var(--success));
  }
  .balance-negative {
    color: hsl(var(--owe));
  }
  .balance-positive-bg {
    background-color: hsl(var(--success-muted));
  }
  .balance-negative-bg {
    background-color: hsl(var(--owe-muted));
  }
  .fab-shadow {
    box-shadow: 0 4px 20px hsl(var(--primary) / 0.35), 0 2px 8px hsl(0 0% 0% / 0.08);
  }
  .safe-bottom {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem);
  }
  @media (min-width: 768px) {
    .safe-bottom {
      padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
    }
  }
  .app-page-wrap {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    max-width: 32rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
  @media (min-width: 768px) {
    .app-page-wrap {
      max-width: 42rem;
      padding-left: 1.5rem;
      padding-right: 1.5rem;
    }
  }
  @media (min-width: 1024px) {
    .app-page-wrap {
      max-width: 48rem;
      padding-left: 2rem;
      padding-right: 2rem;
    }
  }
  @media (min-width: 1280px) {
    .app-page-wrap {
      max-width: 56rem;
    }
  }

  .pill {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 200ms;
  }
  .pill-active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    box-shadow: 0 1px 2px hsl(0 0% 0% / 0.06);
  }
  .pill-inactive {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
  }
  .tap-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@layer utilities {
  .animate-in-up {
    animation: slideInUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .animate-fade-in {
    animation: fadeIn 0.3s ease-out;
  }
  .animate-sheet-up {
    animation: sheetUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

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

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

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
