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

/* ============================================
   CSS VARIABLES - Design System
   ============================================ */
:root {
  /* Brand Colors - NorthStar Theme */
  --color-primary: #1e40af; /* Deep Blue */
  --color-primary-hover: #1e3a8a;
  --color-primary-light: #3b82f6;
  --color-secondary: #7c3aed; /* Purple - AI features */
  --color-secondary-hover: #6d28d9;
  --color-accent: #f59e0b; /* Amber - highlights */

  /* Feeling Colors - Life Area States */
  --color-control: #10b981; /* Green - in control */
  --color-improving: #3b82f6; /* Blue - improving */
  --color-stagnant: #f59e0b; /* Amber - stagnant */
  --color-declining: #f97316; /* Orange - declining */
  --color-neglected: #ef4444; /* Red - neglected */

  /* Neutrals */
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;

  /* Text Colors */
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-tertiary: #94a3b8;
  --color-text-inverse: #ffffff;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   BASE STYLES
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  font-size: 1rem;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
}

h1 {
  font-size: 2.5rem;
}
h2 {
  font-size: 2rem;
}
h3 {
  font-size: 1.5rem;
}
h4 {
  font-size: 1.25rem;
}
h5 {
  font-size: 1.125rem;
}
h6 {
  font-size: 1rem;
}

p {
  line-height: 1.6;
  color: var(--color-text-secondary);
}

/* ============================================
   BUTTONS
   ============================================ */
button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Primary Button */
.btn-primary {
  padding: 0.625rem 1.25rem;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
  padding: 0.625rem 1.25rem;
  background-color: var(--color-secondary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-secondary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Ghost Button */
.btn-ghost {
  padding: 0.625rem 1.25rem;
  background-color: transparent;
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  font-weight: 500;
}

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

/* Icon Button */
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover:not(:disabled) {
  background-color: var(--color-surface-hover);
}

/* Button Sizes */
.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1.125rem;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-compact {
  padding: var(--space-lg);
}

.card-bordered {
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* Card with feeling indicator */
.card-feeling {
  border-left: 4px solid var(--feeling-color, var(--color-border));
}

.card-feeling[data-feeling="in_control"] {
  --feeling-color: var(--color-control);
}

.card-feeling[data-feeling="improving"] {
  --feeling-color: var(--color-improving);
}

.card-feeling[data-feeling="stagnant"] {
  --feeling-color: var(--color-stagnant);
}

.card-feeling[data-feeling="declining"] {
  --feeling-color: var(--color-declining);
}

.card-feeling[data-feeling="neglected"] {
  --feeling-color: var(--color-neglected);
}

/* ============================================
   FORM INPUTS
   ============================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="month"],
textarea,
select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-tertiary);
}

input:disabled,
textarea:disabled,
select:disabled {
  background-color: var(--color-surface-hover);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Checkbox styling */
input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* Label styling */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.nav-link {
  padding: 0.625rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.nav-link:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.nav-link-active {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.nav-link-active:hover {
  background-color: var(--color-primary-hover);
}

/* Hamburger Menu */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  cursor: pointer;
  background: none;
  border: none;
  z-index: 1001;
}

.hamburger span {
  display: block;
  width: 1.5rem;
  height: 2px;
  background-color: var(--color-text-primary);
  transition: all var(--transition-fast);
  border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Menu */
.nav-menu {
  display: flex;
  gap: 0.5rem;
}

.nav-menu-mobile {
  display: none;
}

/* Floating Action Button (FAB) for mobile */
.fab {
  position: fixed;
  bottom: 80px;
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--color-secondary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-xl);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 999;
  transition: all var(--transition-base);
  border: none;
  cursor: pointer;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

.fab:active {
  transform: scale(0.95);
}

/* ============================================
   UTILITIES
   ============================================ */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.container-sm {
  max-width: 768px;
}

.container-lg {
  max-width: 1536px;
}

/* Spacing */
.space-y-xs > * + * {
  margin-top: var(--space-xs);
}
.space-y-sm > * + * {
  margin-top: var(--space-sm);
}
.space-y-md > * + * {
  margin-top: var(--space-md);
}
.space-y-lg > * + * {
  margin-top: var(--space-lg);
}
.space-y-xl > * + * {
  margin-top: var(--space-xl);
}

.space-x-xs > * + * {
  margin-left: var(--space-xs);
}
.space-x-sm > * + * {
  margin-left: var(--space-sm);
}
.space-x-md > * + * {
  margin-left: var(--space-md);
}
.space-x-lg > * + * {
  margin-left: var(--space-lg);
}

/* Padding utilities */
.p-0 {
  padding: 0;
}
.p-1 {
  padding: 0.25rem;
}
.p-2 {
  padding: 0.5rem;
}
.p-3 {
  padding: 0.75rem;
}
.p-4 {
  padding: 1rem;
}
.p-6 {
  padding: 1.5rem;
}
.p-8 {
  padding: 2rem;
}

.px-2 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}
.px-6 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.py-6 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

/* Margin utilities */
.m-0 {
  margin: 0;
}
.m-auto {
  margin: auto;
}
.mt-2 {
  margin-top: 0.5rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mt-6 {
  margin-top: 1.5rem;
}
.mt-8 {
  margin-top: 2rem;
}
.mb-2 {
  margin-bottom: 0.5rem;
}
.mb-4 {
  margin-bottom: 1rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.mb-8 {
  margin-bottom: 2rem;
}
.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

/* Text Utilities */
.text-primary {
  color: var(--color-text-primary);
}
.text-secondary {
  color: var(--color-text-secondary);
}
.text-tertiary {
  color: var(--color-text-tertiary);
}

.text-sm {
  font-size: 0.875rem;
}
.text-base {
  font-size: 1rem;
}
.text-lg {
  font-size: 1.125rem;
}
.text-xl {
  font-size: 1.25rem;
}
.text-2xl {
  font-size: 1.5rem;
}
.text-3xl {
  font-size: 1.875rem;
}

.font-normal {
  font-weight: 400;
}
.font-medium {
  font-weight: 500;
}
.font-semibold {
  font-weight: 600;
}
.font-bold {
  font-weight: 700;
}

.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.break-words {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Layout */
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.items-start {
  align-items: flex-start;
}
.items-center {
  align-items: center;
}
.items-end {
  align-items: flex-end;
}
.justify-start {
  justify-content: flex-start;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-end {
  justify-content: flex-end;
}
.gap-1 {
  gap: 0.25rem;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}
.gap-6 {
  gap: 1.5rem;
}
.gap-8 {
  gap: 2rem;
}
.flex-1 {
  flex: 1 1 0%;
}
.flex-shrink-0 {
  flex-shrink: 0;
}

.grid {
  display: grid;
}
.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Dimensions */
.w-full {
  width: 100%;
}
.w-auto {
  width: auto;
}
.w-1\/2 {
  width: 50%;
}
.w-1\/3 {
  width: 33.333333%;
}
.w-2\/3 {
  width: 66.666667%;
}
.w-1\/4 {
  width: 25%;
}
.w-3\/4 {
  width: 75%;
}
.max-w-sm {
  max-width: 24rem;
}
.max-w-md {
  max-width: 28rem;
}
.max-w-lg {
  max-width: 32rem;
}
.max-w-xl {
  max-width: 36rem;
}
.max-w-2xl {
  max-width: 42rem;
}
.max-w-full {
  max-width: 100%;
}
.h-full {
  height: 100%;
}
.h-auto {
  height: auto;
}
.min-h-screen {
  min-height: 100vh;
}
.min-h-0 {
  min-height: 0;
}

/* Display */
.block {
  display: block;
}
.inline-block {
  display: inline-block;
}
.hidden {
  display: none;
}

/* Overflow */
.overflow-hidden {
  overflow: hidden;
}
.overflow-y-auto {
  overflow-y: auto;
}

/* Position */
.relative {
  position: relative;
}
.absolute {
  position: absolute;
}
.fixed {
  position: fixed;
}
.sticky {
  position: sticky;
}

/* Borders */
.border {
  border: 1px solid var(--color-border);
}
.border-t {
  border-top: 1px solid var(--color-border);
}
.border-b {
  border-bottom: 1px solid var(--color-border);
}
.border-l {
  border-left: 1px solid var(--color-border);
}
.border-r {
  border-right: 1px solid var(--color-border);
}

.rounded {
  border-radius: var(--radius-md);
}
.rounded-sm {
  border-radius: var(--radius-sm);
}
.rounded-lg {
  border-radius: var(--radius-lg);
}
.rounded-full {
  border-radius: 9999px;
}

/* Shadows */
.shadow-sm {
  box-shadow: var(--shadow-sm);
}
.shadow-md {
  box-shadow: var(--shadow-md);
}
.shadow-lg {
  box-shadow: var(--shadow-lg);
}
.shadow-xl {
  box-shadow: var(--shadow-xl);
}

/* Transitions */
.transition {
  transition: all var(--transition-base);
}
.transition-fast {
  transition: all var(--transition-fast);
}

/* Misc */
.cursor-pointer {
  cursor: pointer;
}
.cursor-not-allowed {
  cursor: not-allowed;
}
.pointer-events-none {
  pointer-events: none;
}

.opacity-0 {
  opacity: 0;
}
.opacity-50 {
  opacity: 0.5;
}
.opacity-100 {
  opacity: 1;
}

.whitespace-pre-wrap {
  white-space: pre-wrap;
}
.line-through {
  text-decoration: line-through;
}

/* Mobile-specific utilities */
.overflow-x-auto {
  overflow-x: auto;
}
.overflow-y-auto {
  overflow-y: auto;
}
.overflow-scroll {
  overflow: scroll;
}
.scroll-smooth {
  scroll-behavior: smooth;
}

/* Mobile touch optimization */
.tap-highlight-none {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection on interactive elements */
.select-none {
  -webkit-user-select: none;
  user-select: none;
}

/* Text sizing for better mobile readability */
.text-adjust-none {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Safe area padding for notched devices */
@supports (padding: env(safe-area-inset-left)) {
  .safe-area-inset {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .safe-area-inset-top {
    padding-top: env(safe-area-inset-top);
  }

  .safe-area-inset-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
/* Show/Hide at breakpoints */
.md\:hidden {
  display: none;
}

.lg\:block {
  display: none;
}

@media (min-width: 1024px) {
  .lg\:block {
    display: block;
  }

  .lg\:flex {
    display: flex;
  }

  .lg\:grid {
    display: grid;
  }
}

@media (max-width: 768px) {
  .sm\:hidden {
    display: none;
  }

  .md\:hidden {
    display: block;
  }

  .sm\:block {
    display: block;
  }

  .sm\:flex {
    display: flex;
  }

  .sm\:flex-col {
    flex-direction: column;
  }

  .sm\:flex-row {
    flex-direction: row;
  }

  .sm\:w-full {
    width: 100%;
  }

  .sm\:text-sm {
    font-size: 0.875rem;
  }

  .sm\:text-base {
    font-size: 1rem;
  }

  .sm\:gap-2 {
    gap: 0.5rem;
  }

  .sm\:gap-4 {
    gap: 1rem;
  }

  .sm\:p-2 {
    padding: 0.5rem;
  }

  .sm\:p-4 {
    padding: 1rem;
  }

  .sm\:px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .sm\:py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet and below (max-width: 1024px) */
@media (max-width: 1024px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card {
    padding: var(--space-lg);
  }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
  /* Typography - smaller on mobile */
  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.5rem;
  }
  h3 {
    font-size: 1.25rem;
  }
  h4 {
    font-size: 1.125rem;
  }

  /* Container - less padding on mobile */
  .container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  /* Cards - more compact on mobile */
  .card {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }

  .card-compact {
    padding: var(--space-md);
  }

  /* Bottom Navigation Bar - Mobile */
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    border-bottom: none;
    border-top: 1px solid var(--color-border);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .nav .container {
    padding: 0.5rem 0.5rem;
    max-width: 100%;
  }

  /* Show hamburger on mobile */
  .hamburger {
    display: flex;
  }

  /* Hide desktop menu, show mobile menu */
  .nav-menu {
    display: none;
  }

  .nav-menu-mobile {
    display: flex;
    justify-content: space-around;
    width: 100%;
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.5rem 0.25rem;
    font-size: 0.625rem;
    min-width: 60px;
    flex: 1;
    border-radius: var(--radius-sm);
  }

  .nav-link span {
    font-size: 1.25rem;
  }

  /* Add padding to main content for bottom nav */
  main {
    padding-bottom: 5rem !important;
  }

  /* Show FAB on mobile */
  .fab {
    display: flex;
  }

  /* Hide desktop AI button and logout */
  .nav-menu.items-center {
    display: none;
  }

  /* Buttons - larger touch targets */
  button {
    min-height: 44px; /* iOS touch target minimum */
  }

  .btn-primary,
  .btn-secondary,
  .btn-ghost {
    padding: 0.75rem 1rem;
  }

  .btn-icon {
    min-width: 44px;
    min-height: 44px;
    padding: 0.625rem;
  }

  .btn-sm {
    padding: 0.5rem 0.75rem;
    min-height: 40px;
  }

  .btn-lg {
    padding: 1rem 1.5rem;
    min-height: 52px;
  }

  /* Forms - easier to use on mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="month"],
  textarea,
  select {
    padding: 0.75rem;
    font-size: 1rem; /* Prevent iOS zoom on focus */
    min-height: 44px;
  }

  textarea {
    min-height: 120px;
  }

  input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 44px;
    min-height: 44px;
  }

  /* Layout - single column on mobile */
  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  /* Spacing - more compact */
  .space-y-xl > * + * {
    margin-top: var(--space-lg);
  }
  .space-y-lg > * + * {
    margin-top: var(--space-md);
  }

  .gap-8 {
    gap: 1rem;
  }
  .gap-6 {
    gap: 0.75rem;
  }

  /* Text - better readability */
  .text-3xl {
    font-size: 1.5rem;
  }
  .text-2xl {
    font-size: 1.25rem;
  }
  .text-xl {
    font-size: 1.125rem;
  }

  /* Hide elements that take too much space on mobile */
  .mobile-hide {
    display: none;
  }

  /* Stack flex items on mobile */
  .mobile-stack {
    flex-direction: column;
  }

  /* Full width on mobile */
  .mobile-full {
    width: 100%;
  }

  /* Mobile-friendly tables */
  table {
    font-size: 0.875rem;
  }

  th, td {
    padding: 0.5rem;
  }

  /* Make tables scrollable horizontally on mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modal/Dialog full screen on mobile */
  .modal,
  .dialog {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
}

/* Small mobile (max-width: 480px) */
@media (max-width: 480px) {
  /* Even more compact */
  h1 {
    font-size: 1.5rem;
  }
  h2 {
    font-size: 1.25rem;
  }

  .container {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .card {
    padding: var(--space-sm);
  }

  /* Smaller buttons on very small screens */
  .btn-primary,
  .btn-secondary,
  .btn-ghost {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
  }

  /* Compact navigation */
  .nav-link {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
  }

  /* Reduce gaps */
  .gap-4 {
    gap: 0.5rem;
  }
  .gap-6 {
    gap: 0.75rem;
  }
  .gap-8 {
    gap: 1rem;
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  .nav {
    position: fixed; /* Keep at bottom even in landscape */
    bottom: 0;
  }

  .min-h-screen {
    min-height: auto;
  }

  /* More compact nav in landscape */
  .nav-link {
    padding: 0.375rem 0.25rem;
    font-size: 0.5625rem;
  }

  .nav-link span {
    font-size: 1rem;
  }
}

/* Touch-specific optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets for touch devices */
  button,
  a,
  input[type="checkbox"],
  select {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects on touch devices */
  .card:hover {
    box-shadow: var(--shadow-md); /* Same as default */
  }

  button:hover:not(:disabled) {
    transform: none; /* No transform on touch */
  }

  .nav-link:hover {
    background-color: transparent; /* No hover on touch */
  }

  /* Active states instead */
  button:active:not(:disabled) {
    opacity: 0.8;
  }

  .card:active {
    box-shadow: var(--shadow-lg);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

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

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

.animate-slide-in {
  animation: slideIn var(--transition-base) ease-out;
}

.animate-slide-in-bottom {
  animation: slideInFromBottom var(--transition-base) ease-out;
}

/* Chat Panel Mobile Styles */
@media (max-width: 768px) {
  /* Make chat panel full screen on mobile */
  .fixed[style*="width: 28rem"] {
    width: 100% !important;
    left: 0 !important;
  }

  /* Alternative: if using a specific class for chat */
  .chat-panel {
    width: 100% !important;
    left: 0 !important;
  }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-background);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* Thinner scrollbars on mobile */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  /* Better touch scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }
}
