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

@layer base {
  :root {
    --background: 220 20% 97%;
    --foreground: 220 25% 10%;
    --card: 0 0% 100%;
    --card-foreground: 220 25% 10%;
    --popover: 0 0% 100%;
    --popover-foreground: 220 25% 10%;
    --primary: 160 60% 45%;
    --primary-foreground: 0 0% 100%;
    --secondary: 220 15% 92%;
    --secondary-foreground: 220 25% 10%;
    --muted: 220 15% 94%;
    --muted-foreground: 220 10% 50%;
    --accent: 160 60% 45%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 72% 55%;
    --destructive-foreground: 0 0% 100%;
    --border: 220 15% 90%;
    --input: 220 15% 90%;
    --ring: 160 60% 45%;
    --radius: 0.75rem;

    --surface: 0 0% 100%;
    --surface-elevated: 0 0% 100%;
    --surface-hover: 220 15% 96%;
    --success: 160 60% 45%;
    --success-foreground: 0 0% 100%;
    --warning: 38 92% 55%;
    --warning-foreground: 0 0% 100%;
    --info: 210 80% 55%;
    --info-foreground: 0 0% 100%;
    --income: 160 60% 45%;
    --expense: 0 72% 55%;
    --transfer: 210 80% 55%;
    --gradient-primary: linear-gradient(135deg, hsl(160 60% 45%), hsl(160 80% 35%));
    --gradient-hero: linear-gradient(160deg, hsl(220 25% 8%), hsl(220 30% 14%));
    --gradient-card: linear-gradient(135deg, hsl(0 0% 100%), hsl(220 15% 98%));
    --shadow-sm: 0 1px 2px hsl(220 25% 10% / 0.04);
    --shadow-md: 0 4px 12px hsl(220 25% 10% / 0.06);
    --shadow-lg: 0 8px 30px hsl(220 25% 10% / 0.08);
    --shadow-glow: 0 0 40px hsl(160 60% 45% / 0.15);

    --sidebar-background: 220 15% 98%;
    --sidebar-foreground: 220 25% 10%;
    --sidebar-primary: 160 60% 45%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 220 15% 92%;
    --sidebar-accent-foreground: 220 25% 10%;
    --sidebar-border: 220 15% 88%;
    --sidebar-ring: 160 60% 45%;

    --motion-ios-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --motion-ios-ease-soft: cubic-bezier(0.32, 0.72, 0, 1);
    --motion-fast: 120ms;
    --motion-base: 180ms;
    --motion-slow: 220ms;
    --motion-chip: 110ms;
    --motion-list: 160ms;
    --motion-sheet: 220ms;
  }

  .dark {
    --background: 220 25% 6%;
    --foreground: 220 10% 92%;
    --card: 220 25% 9%;
    --card-foreground: 220 10% 92%;
    --popover: 220 25% 9%;
    --popover-foreground: 220 10% 92%;
    --primary: 160 60% 45%;
    --primary-foreground: 0 0% 100%;
    --secondary: 220 20% 14%;
    --secondary-foreground: 220 10% 92%;
    --muted: 220 20% 14%;
    --muted-foreground: 220 10% 50%;
    --accent: 160 60% 45%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 62% 50%;
    --destructive-foreground: 0 0% 100%;
    --border: 220 20% 14%;
    --input: 220 20% 14%;
    --ring: 160 60% 45%;

    --surface: 220 25% 9%;
    --surface-elevated: 220 22% 12%;
    --surface-hover: 220 20% 14%;
    --gradient-card: linear-gradient(135deg, hsl(220 25% 9%), hsl(220 22% 11%));
    --shadow-sm: 0 1px 2px hsl(0 0% 0% / 0.2);
    --shadow-md: 0 4px 12px hsl(0 0% 0% / 0.3);
    --shadow-lg: 0 8px 30px hsl(0 0% 0% / 0.4);
    --shadow-glow: 0 0 40px hsl(160 60% 45% / 0.2);

    --sidebar-background: 220 25% 5%;
    --sidebar-foreground: 220 10% 80%;
    --sidebar-accent: 220 20% 10%;
    --sidebar-accent-foreground: 220 10% 90%;
    --sidebar-border: 220 20% 10%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground antialiased;
    background-image:
      radial-gradient(1000px circle at 10% -10%, hsl(160 60% 45% / 0.10), transparent 45%),
      radial-gradient(900px circle at 90% 0%, hsl(220 25% 10% / 0.08), transparent 50%);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@layer utilities {
  .bg-card {
    background-color: hsl(var(--card) / 0.75);
  }
  .bg-popover {
    background-color: hsl(var(--popover) / 0.75);
  }

  .text-gradient-primary {
    @apply bg-clip-text text-transparent;
    background-image: linear-gradient(135deg, hsl(160 60% 45%), hsl(160 80% 60%));
  }
  .bg-surface {
    background-color: hsl(var(--surface));
  }
  .bg-surface-elevated {
    background-color: hsl(var(--surface-elevated));
  }
  .shadow-card {
    box-shadow: var(--shadow-md);
  }
  .shadow-glow {
    box-shadow: var(--shadow-glow);
  }
  .glass {
    @apply backdrop-blur-xl;
    background: hsl(var(--surface) / 0.8);
  }
  .glass-dark {
    @apply backdrop-blur-xl;
    background: hsl(220 25% 8% / 0.85);
  }
  .widget-surface {
    backdrop-filter: blur(18px);
    background:
      linear-gradient(180deg, hsl(0 0% 100% / 0.74), hsl(220 20% 98% / 0.64)),
      hsl(var(--card) / 0.68);
    box-shadow:
      inset 0 1px 0 hsl(0 0% 100% / 0.7),
      0 18px 45px hsl(220 25% 10% / 0.07);
  }
  .widget-panel {
    background-color: var(--tw-ring-offset-color);
    border: 1px solid hsl(0 0% 100% / 0.32);
    box-shadow:
      inset 0 1px 0 hsl(0 0% 100% / 0.45),
      0 8px 24px hsl(220 25% 10% / 0.03);
    backdrop-filter: blur(10px);
  }

  .scrollbar-none {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .scrollbar-none::-webkit-scrollbar {
    display: none;
  }

  .ios-transition {
    transition-property: transform, opacity, box-shadow, background-color, border-color, color;
    transition-duration: var(--motion-base);
    transition-timing-function: var(--motion-ios-ease);
  }

  .ios-transition-fast {
    transition-property: transform, opacity, box-shadow, background-color, border-color, color;
    transition-duration: var(--motion-fast);
    transition-timing-function: var(--motion-ios-ease-soft);
  }

  .ios-transition-chip {
    transition-property: transform, opacity, background-color, border-color, color;
    transition-duration: var(--motion-chip);
    transition-timing-function: var(--motion-ios-ease-soft);
  }

  .ios-transition-list {
    transition-property: transform, opacity, background-color, border-color, color;
    transition-duration: var(--motion-list);
    transition-timing-function: var(--motion-ios-ease);
  }

  .ios-press {
    transform: translateZ(0);
    will-change: transform;
  }

  .ios-press:active {
    transform: scale(0.98);
  }

  .ios-press-soft:active {
    transform: scale(0.992);
  }

  .ios-press-deep:active {
    transform: scale(0.972);
  }

  .ios-chip {
    transition-property: transform, background-color, border-color, color, opacity;
    transition-duration: var(--motion-chip);
    transition-timing-function: var(--motion-ios-ease-soft);
  }

  .ios-chip:active {
    transform: scale(0.97);
  }

  .ios-list-row {
    transition-property: background-color, transform, box-shadow;
    transition-duration: var(--motion-list);
    transition-timing-function: var(--motion-ios-ease);
  }

  .ios-list-row:active {
    transform: scale(0.997);
  }

  .ios-card-hover {
    transform: translateY(0) translateZ(0);
  }

  .ios-card-hover:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px hsl(220 25% 10% / 0.08);
  }

  .ios-fade-up {
    animation: ios-fade-up var(--motion-slow) var(--motion-ios-ease) both;
  }

  .ios-sheet-enter {
    animation: ios-sheet-enter var(--motion-sheet) var(--motion-ios-ease) both;
  }

  @keyframes ios-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes ios-sheet-enter {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}
