/* Loan Manager — Mobile-First Finance App */

:root {
  --lm-bg: #f8fafc;
  --lm-surface: #ffffff;
  --lm-primary: #3b82f6;
  --lm-primary-soft: #eff6ff;
  --lm-primary-dark: #0f172a;
  --lm-primary-darker: #1e293b;
  --lm-accent: #6366f1;
  --lm-success: #22c55e;
  --lm-success-soft: #f0fdf4;
  --lm-warning: #f59e0b;
  --lm-warning-soft: #fef3c7;
  --lm-danger: #ef4444;
  --lm-danger-soft: #fef2f2;
  --lm-text: #0f172a;
  --lm-text-soft: #94a3b8;
  --lm-text-muted: #64748b;
  --lm-border: #e2e8f0;
  --lm-border-light: #f1f5f9;

  --lm-shadow: 0 1px 3px rgba(0,0,0,0.04);
  --lm-shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --lm-shadow-lg: 0 4px 12px rgba(0,0,0,0.08);

  --lm-radius: 14px;
  --lm-radius-sm: 10px;
  --lm-radius-full: 100px;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur-fast: 150ms;
  --dur-normal: 250ms;
  --dur-slow: 400ms;
}

body.lm-app {
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-weight: 500;
  background: var(--lm-bg);
  color: var(--lm-text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

[x-cloak] { display: none !important; }


/* === Cards === */

.lm-card {
  background: var(--lm-surface);
  border: 1.5px solid var(--lm-border);
  border-radius: var(--lm-radius);
  box-shadow: var(--lm-shadow);
}

.lm-card-dark {
  background: linear-gradient(135deg, var(--lm-primary-dark) 0%, var(--lm-primary-darker) 100%);
  border: none;
  border-radius: 16px;
  color: #fff;
}


/* === Range slider === */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--lm-radius-full);
  background: var(--lm-border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--lm-primary);
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring);
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--lm-primary);
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
  cursor: pointer;
}


/* === Segmented control === */

.lm-segment {
  transition: all var(--dur-fast) ease;
}
.lm-segment-active {
  background: var(--lm-surface);
  border-radius: 8px;
  font-weight: 700;
  color: var(--lm-text);
  box-shadow: var(--lm-shadow);
}


/* === Navigation === */

.lm-nav-bar {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 0 0 1px rgba(226,232,240,0.4),
              0 -2px 16px rgba(15,23,42,0.04);
}

.lm-nav-tab {
  position: relative;
  color: var(--lm-text-soft);
  transition: color var(--dur-fast) ease;
}

.lm-nav-tab-active {
  color: var(--lm-primary);
}
.lm-nav-tab-active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 30%; right: 30%;
  height: 2.5px;
  border-radius: 2px;
  background: var(--lm-primary);
  animation: dot-pop 250ms var(--ease-spring);
}

.lm-nav-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.lm-nav-fade {
  padding-top: 1.5rem;
  background: linear-gradient(to top, var(--lm-bg) 65%, transparent);
}

.lm-nav-safe {
  padding-bottom: calc(0.25rem + env(safe-area-inset-bottom, 0px));
}


/* === Progress bar === */

.lm-progress-bar {
  height: 5px;
  border-radius: var(--lm-radius-full);
  background: var(--lm-border-light);
  overflow: hidden;
}

.lm-progress-fill {
  height: 100%;
  border-radius: var(--lm-radius-full);
  transition: width var(--dur-slow) var(--ease-out-expo);
}


/* === Bottom sheet === */

.lm-sheet-backdrop {
  animation: fade-in var(--dur-fast) ease-out;
}

.lm-sheet {
  animation: sheet-up var(--dur-normal) var(--ease-out-expo);
}


/* === Buttons === */

.lm-btn-primary {
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-normal) ease;
  box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}
.lm-btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(59,130,246,0.2);
}


/* === Animations === */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes card-up {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes dot-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.card-enter { animation: card-up 300ms var(--ease-smooth) both; }


/* === HTMX transitions === */

.htmx-swapping { opacity: 0; transition: opacity 150ms var(--ease-smooth); }
.htmx-settling { opacity: 1; transition: opacity 150ms var(--ease-smooth); }


/* === Scrollbar === */

.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { scrollbar-width: none; }


/* === Login === */

.lm-login-bg {
  background: radial-gradient(ellipse at 50% 0%, #eff6ff 0%, var(--lm-bg) 65%);
}


/* === Amortization table row expand === */

.lm-row-expand {
  overflow: hidden;
  transition: max-height var(--dur-normal) var(--ease-smooth),
              opacity var(--dur-fast) ease;
}


/* === Reduced motion === */

@media (prefers-reduced-motion: reduce) {
  .card-enter,
  .lm-sheet,
  .lm-sheet-backdrop {
    animation: none;
  }
  .lm-btn-primary,
  .lm-nav-tab,
  .lm-segment,
  .lm-progress-fill,
  input[type="range"]::-webkit-slider-thumb {
    transition: none;
  }
}
