/* ============================================
   Ria Money - Unified Theme Stylesheet
   Red theme variables + shared animations
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Brand Colors */
  --ria-red: #dc2626;
  --ria-red-dark: #b91c1c;
  --ria-red-light: #fef2f2;
  --ria-red-hover: #991b1b;

  /* Semantic Colors */
  --success: #22c55e;
  --success-light: #f0fdf4;
  --error: #ef4444;
  --error-light: #fef2f2;
  --warning: #f59e0b;

  /* Neutrals */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg-page: #ffffff;
  --bg-gradient-start: #fef2f2;
  --bg-gradient-end: #fee2e2;
  --border-color: #e5e7eb;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Spacing */
  --radius-card: 1rem;
  --radius-pill: 9999px;
  --radius-input: 0.5rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 300ms ease;
}

/* ---------- Base ---------- */
html, body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

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

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

@keyframes shake {
  0%,100% { transform: translateX(0); }
  15%      { transform: translateX(-8px); }
  30%      { transform: translateX(8px); }
  45%      { transform: translateX(-6px); }
  60%      { transform: translateX(6px); }
  75%      { transform: translateX(-3px); }
  90%      { transform: translateX(3px); }
}

@keyframes redPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
  50%      { box-shadow: 0 0 12px 2px rgba(220, 38, 38, 0.45); }
}

@keyframes errorPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50%      { box-shadow: 0 0 12px 4px rgba(239, 68, 68, 0.35); }
}

@keyframes successPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
  50%      { box-shadow: 0 0 12px 4px rgba(34, 197, 94, 0.4); }
}

@keyframes popIn {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes popScale {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes drawCheck {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(-20px) rotate(0deg); }
  100% { opacity: 0; transform: translateY(300px) rotate(720deg); }
}

@keyframes progressFill {
  from { width: 0; }
  to   { width: 100%; }
}

@keyframes strokeCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes strokeCheck {
  to { stroke-dashoffset: 0; }
}

/* ---------- Utility Classes ---------- */
.fade-in      { animation: fadeIn 0.5s ease-out; }
.shake-anim   { animation: shake 0.5s ease-in-out; }
.shake        { animation: shake 0.5s ease-in-out; }
.red-glow     { animation: redPulse 0.9s ease-in-out 2; border-color: var(--ria-red) !important; }
.error-glow   { animation: errorPulse 0.6s ease-in-out 2; border-color: var(--error) !important; }
.success-glow { animation: successPulse 0.6s ease-in-out; border-color: var(--success) !important; }
.pop-in       { animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.pop-scale    { animation: popScale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.float-icon   { animation: float 3s ease-in-out infinite; }

/* ---------- Confetti ---------- */
.confetti {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Checkmark SVG Animations ---------- */
.check-path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}
.check-animate {
  animation: drawCheck 0.6s ease-out forwards;
}

.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 3;
  stroke-miterlimit: 10;
}
.checkmark-circle.active {
  animation: strokeCircle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.checkmark-check.active {
  animation: strokeCheck 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

/* ---------- Success Overlay ---------- */
#success-overlay {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
#success-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- OTP Inputs ---------- */
.otp-input::-webkit-outer-spin-button,
.otp-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.otp-input {
  -moz-appearance: textfield;
}

/* ---------- Password Strength ---------- */
.strength-weak   { background-color: var(--error);   width: 33%; }
.strength-medium { background-color: var(--warning); width: 66%; }
.strength-strong { background-color: var(--success); width: 100%; }

/* ---------- Custom Select (index.html) ---------- */
select.ria-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* ---------- Form Inputs ---------- */
.ria-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  transition: all var(--transition-fast);
  outline: none;
}
.ria-input:focus {
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
  ring: 2px solid var(--ria-red);
}

/* ---------- Buttons ---------- */
.ria-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--ria-red);
  color: #ffffff;
  font-weight: 600;
  border-radius: var(--radius-input);
  box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.2);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
}
.ria-btn:hover {
  background-color: var(--ria-red-dark);
}
.ria-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.ria-btn-outline {
  background-color: transparent;
  color: var(--ria-red);
  border: 1px solid var(--border-color);
  box-shadow: none;
}
.ria-btn-outline:hover {
  background-color: var(--ria-red-light);
}

/* ---------- Cards ---------- */
.ria-card {
  background-color: var(--bg-page);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 2rem;
  width: 100%;
  max-width: 28rem;
}

/* ---------- Nav ---------- */
.ria-nav {
  background-color: var(--bg-page);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 1rem;
}

/* ---------- Footer ---------- */
.ria-footer {
  background-color: #111827;
  color: #9ca3af;
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.875rem;
}

/* ---------- Page Background ---------- */
.ria-page-bg {
  min-height: 100vh;
  background: linear-gradient(to bottom right, var(--bg-gradient-start), var(--bg-gradient-end));
  display: flex;
  flex-direction: column;
}

/* ---------- Icon Circle (card headers) ---------- */
.ria-icon-circle {
  width: 4rem;
  height: 4rem;
  background-color: var(--ria-red-light);
  color: var(--ria-red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

/* ---------- Link ---------- */
.ria-link {
  color: var(--ria-red);
  font-weight: 600;
  text-decoration: none;
}
.ria-link:hover {
  text-decoration: underline;
}

/* ---------- Divider ---------- */
.ria-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}
.ria-divider::before,
.ria-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border-color);
}
.ria-divider span {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Touch-friendly tap targets (min 44px) */
button, a, .ria-input, .otp-input, select {
  min-height: 44px;
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .ria-page-bg {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .ria-nav {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .ria-footer {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}

/* Small screens (< 480px) */
@media (max-width: 480px) {
  :root {
    --radius-card: 0.75rem;
  }

  .ria-card {
    padding: 1.25rem;
    border-radius: var(--radius-card);
    max-width: 100%;
  }

  .ria-nav {
    padding: 0.75rem 1rem;
  }

  .ria-nav a {
    font-size: 1.25rem;
  }

  .ria-icon-circle {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
  }

  .ria-input {
    padding: 0.875rem 0.875rem 0.875rem 2.5rem;
  }

  .ria-btn {
    padding: 0.875rem 1rem;
    font-size: 1rem;
  }

  /* OTP inputs: larger touch targets */
  .otp-input {
    width: 2.75rem !important;
    height: 3.25rem !important;
    font-size: 1.25rem !important;
    border-radius: 0.5rem !important;
  }

  /* Footer smaller padding */
  .ria-footer {
    padding: 1rem;
    font-size: 0.8125rem;
  }

  /* Reduce confetti count on mobile via smaller fall distance */
  @keyframes confettiFall {
    0%   { opacity: 1; transform: translateY(-20px) rotate(0deg); }
    100% { opacity: 0; transform: translateY(200px) rotate(720deg); }
  }

  /* Slightly faster animations on mobile for snappier feel */
  .fade-in { animation-duration: 0.35s; }
  .pop-in  { animation-duration: 0.45s; }
}

/* Medium screens (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
  .ria-card {
    padding: 1.5rem;
  }

  .otp-input {
    width: 3rem !important;
    height: 3.5rem !important;
    font-size: 1.375rem !important;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Landscape phones: ensure card doesn't overflow */
@media (max-height: 500px) and (orientation: landscape) {
  .ria-card {
    padding: 1rem;
  }
  .ria-icon-circle {
    width: 3rem;
    height: 3rem;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }
}

/* ============================================
   AUTH PAGE CARDS (Tailwind-based pages)
   Targets cards without .ria-card class
   ============================================ */

/* Mobile auth card overrides */
@media (max-width: 480px) {
  /* Auth page white cards */
  main .bg-white.rounded-2xl.shadow-xl,
  main .bg-white.rounded-xl.shadow-xl {
    padding: 1.25rem !important;
    border-radius: 1rem !important;
  }

  /* Auth page nav brand size */
  nav a.text-2xl {
    font-size: 1.25rem !important;
  }

  /* Auth page card icon circles */
  main .rounded-full.w-16.h-16 {
    width: 3.5rem !important;
    height: 3.5rem !important;
    font-size: 1.25rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* Auth page headings */
  main h1.text-2xl {
    font-size: 1.375rem !important;
  }

  /* Form inputs taller for touch */
  main input[type="text"],
  main input[type="email"],
  main input[type="password"],
  main input[type="number"] {
    padding-top: 0.875rem !important;
    padding-bottom: 0.875rem !important;
  }

  /* Social login buttons: full width on very small screens */
  main .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* Reduce vertical padding on auth main */
  main.py-10 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
}

/* Medium screens */
@media (min-width: 481px) and (max-width: 767px) {
  main .bg-white.rounded-2xl.shadow-xl,
  main .bg-white.rounded-xl.shadow-xl {
    padding: 1.5rem !important;
  }
}
