/*
 * Equilibrio Financiero - Design System v2.0
 * Premium fintech dashboard with golden amber brand
 */

/* ============================================================
   DESIGN TOKENS
   Centralized design variables for consistency
   ============================================================ */
:root {
  /* Brand palette - golden amber */
  --brand-50: #fffbeb;
  --brand-100: #fef3c7;
  --brand-200: #fde68a;
  --brand-300: #fcd34d;
  --brand-400: #fbbf24;
  --brand-500: #f2b705;
  --brand-600: #d49904;
  --brand-700: #a87803;
  --brand-800: #7c5902;
  --brand-900: #5c4102;

  /* Override Tailwind indigo with brand */
  --color-indigo-50: #fffbeb;
  --color-indigo-100: #fef3c7;
  --color-indigo-200: #fde68a;
  --color-indigo-300: #fcd34d;
  --color-indigo-400: #fbbf24;
  --color-indigo-500: #f2b705;
  --color-indigo-600: #f2b705;
  --color-indigo-700: #d49904;
  --color-indigo-800: #a87803;
  --color-indigo-900: #7c5902;

  /* Spacing scale */
  --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.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 10px 30px -5px rgba(0, 0, 0, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.04);
  --shadow-dropdown: 0 10px 40px -8px rgba(0, 0, 0, 0.12), 0 4px 12px -4px rgba(0, 0, 0, 0.06);
  --shadow-glow-brand: 0 0 20px rgba(242, 183, 5, 0.15);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Sidebar */
  --sidebar-width: 17rem;
  --sidebar-width-collapsed: 4.5rem;
}

.dark {
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-card-hover: 0 10px 30px -5px rgba(0, 0, 0, 0.4), 0 4px 10px -4px rgba(0, 0, 0, 0.3);
  --shadow-dropdown: 0 10px 40px -8px rgba(0, 0, 0, 0.5), 0 4px 12px -4px rgba(0, 0, 0, 0.3);
  --shadow-glow-brand: 0 0 20px rgba(242, 183, 5, 0.1);
}

/* ============================================================
   MODALS
   ============================================================ */
turbo-frame#modal {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 60;
  overflow-y: auto;
}

turbo-frame#modal:not(:empty) {
  display: flex;
}

turbo-frame#modal > div {
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease-out forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-slide-in-left {
  animation: slideInLeft 0.3s ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out forwards;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-count-up {
  animation: count-up 0.5s ease-out forwards;
}

/* Staggered animation delays for lists */
.stagger-1 { animation-delay: 0.05s; opacity: 0; }
.stagger-2 { animation-delay: 0.1s; opacity: 0; }
.stagger-3 { animation-delay: 0.15s; opacity: 0; }
.stagger-4 { animation-delay: 0.2s; opacity: 0; }
.stagger-5 { animation-delay: 0.25s; opacity: 0; }
.stagger-6 { animation-delay: 0.3s; opacity: 0; }
.stagger-7 { animation-delay: 0.35s; opacity: 0; }
.stagger-8 { animation-delay: 0.4s; opacity: 0; }

/* ============================================================
   DISABLED INPUTS
   ============================================================ */
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ============================================================
   CURP INPUT STYLES
   ============================================================ */
input[data-curp-validation-target="curpInput"]:focus,
input[data-aval-curp-validation-target="curpInput"]:focus,
input[data-credit-wizard-target="curpInput"]:focus,
input[data-credit-wizard-target="avalCurpInput"]:focus {
  box-shadow: 0 0 0 4px rgba(242, 183, 5, 0.15);
}

input[data-curp-validation-target="curpInput"]::placeholder,
input[data-aval-curp-validation-target="curpInput"]::placeholder,
input[data-credit-wizard-target="curpInput"]::placeholder,
input[data-credit-wizard-target="avalCurpInput"]::placeholder {
  letter-spacing: 0.15em;
}

/* ============================================================
   TABLE IMPROVEMENTS
   ============================================================ */
table tbody tr {
  transition: background-color var(--transition-fast);
}

/* Responsive tables on mobile */
@media (max-width: 639px) {
  .table-responsive-cards thead {
    display: none;
  }
  .table-responsive-cards tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-xl);
    border: 1px solid rgb(226 232 240 / 0.8);
    padding: 1rem;
    background: white;
  }
  .dark .table-responsive-cards tbody tr {
    background: rgb(30 41 59);
    border-color: rgb(51 65 85 / 0.6);
  }
  .table-responsive-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    border: none;
  }
  .table-responsive-cards tbody td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    color: rgb(100 116 139);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    flex-shrink: 0;
    margin-right: 1rem;
  }
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */
.custom-scrollbar::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.3);
  border-radius: 9999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(148, 163, 184, 0.5);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-transition {
  transition: transform var(--transition-smooth), width var(--transition-smooth);
}

.overlay-transition {
  transition: opacity var(--transition-smooth);
}

/* Sidebar nav item active indicator */
.nav-item-active {
  position: relative;
}

.nav-item-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 9999px 9999px 0;
  background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
}

/* ============================================================
   DARK MODE - Additional overrides
   ============================================================ */
.dark turbo-frame#modal {
  background-color: rgba(0, 0, 0, 0.75);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: rgba(100, 116, 139, 0.4);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 116, 139, 0.6);
}

/* ============================================================
   CARD SYSTEM
   ============================================================ */
.card-base {
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
  border: 1px solid rgb(241 245 249 / 0.8);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.dark .card-base {
  background: rgb(30 41 59);
  border-color: rgb(51 65 85 / 0.6);
}

.card-hover {
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.card-hover:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

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

/* Glass card */
.card-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-2xl);
}

.dark .card-glass {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(51, 65, 85, 0.5);
}

/* ============================================================
   KPI / STAT CARDS
   ============================================================ */
.stat-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-2xl);
  padding: 1.25rem;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

.stat-card::before {
  display: none;
}

.stat-card-brand::before { background: var(--brand-500); }
.stat-card-emerald::before { background: rgb(16 185 129); }
.stat-card-amber::before { background: rgb(245 158 11); }
.stat-card-blue::before { background: rgb(59 130 246); }
.stat-card-violet::before { background: rgb(139 92 246); }
.stat-card-rose::before { background: rgb(244 63 94); }

/* Stat value animation */
.stat-value {
  animation: count-up 0.5s ease-out forwards;
}

/* ============================================================
   GRADIENT ACCENTS
   ============================================================ */
.brand-gradient {
  background: linear-gradient(135deg, #fbbf24 0%, #f2b705 50%, #d49904 100%);
}

.dark .brand-gradient {
  background: linear-gradient(135deg, #fbbf24 0%, #f2b705 100%);
}

.gradient-brand-subtle {
  background: linear-gradient(135deg, rgba(242, 183, 5, 0.08) 0%, rgba(212, 153, 4, 0.04) 100%);
}

.dark .gradient-brand-subtle {
  background: linear-gradient(135deg, rgba(242, 183, 5, 0.1) 0%, rgba(212, 153, 4, 0.05) 100%);
}

.gradient-emerald-subtle {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(5, 150, 105, 0.04) 100%);
}

.dark .gradient-emerald-subtle {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(5, 150, 105, 0.06) 100%);
}

.gradient-amber-subtle {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.04) 100%);
}

.dark .gradient-amber-subtle {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(217, 119, 6, 0.06) 100%);
}

.gradient-blue-subtle {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(37, 99, 235, 0.04) 100%);
}

.dark .gradient-blue-subtle {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(37, 99, 235, 0.06) 100%);
}

.gradient-violet-subtle {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(109, 40, 217, 0.04) 100%);
}

.dark .gradient-violet-subtle {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(109, 40, 217, 0.06) 100%);
}

.gradient-rose-subtle {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.08) 0%, rgba(225, 29, 72, 0.04) 100%);
}

.dark .gradient-rose-subtle {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.12) 0%, rgba(225, 29, 72, 0.06) 100%);
}

/* ============================================================
   FOCUS STYLES
   ============================================================ */
.focus-ring:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* ============================================================
   BADGE SYSTEM
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.5;
}

.badge-sm {
  padding: 0.0625rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 700;
}

/* ============================================================
   OTP MODAL
   ============================================================ */
.otp-overlay-transition {
  transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
  opacity: 0;
}

.otp-overlay-visible {
  opacity: 1;
}

.otp-modal-transition {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
}

.otp-overlay-visible .otp-modal-transition,
.otp-modal-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.otp-input-focus:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(242, 183, 5, 0.2);
  transform: scale(1.05);
}

.otp-input-focus {
  transition: all 0.15s ease;
}

.otp-input-focus:not(:placeholder-shown) {
  border-color: var(--brand-500);
  background-color: rgba(242, 183, 5, 0.04);
}

.dark .otp-input-focus:not(:placeholder-shown) {
  background-color: rgba(242, 183, 5, 0.08);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-glow:hover {
  box-shadow: var(--shadow-glow-brand);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-bg {
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(242, 183, 5, 0.12) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  border-radius: 50%;
  pointer-events: none;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(242, 183, 5, 0.08) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  border-radius: 50%;
  pointer-events: none;
}

.dark .login-bg::before {
  background: radial-gradient(circle, rgba(242, 183, 5, 0.06) 0%, transparent 70%);
}

.dark .login-bg::after {
  background: radial-gradient(circle, rgba(242, 183, 5, 0.04) 0%, transparent 70%);
}

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-bar {
  height: 6px;
  border-radius: var(--radius-full);
  background: rgb(241 245 249);
  overflow: hidden;
}

.dark .progress-bar {
  background: rgb(51 65 85 / 0.5);
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state-icon {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
  background: rgb(15 23 42 / 0.9);
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 50;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, rgb(241 245 249) 25%, rgb(226 232 240) 50%, rgb(241 245 249) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.dark .skeleton {
  background: linear-gradient(90deg, rgb(51 65 85 / 0.5) 25%, rgb(71 85 105 / 0.5) 50%, rgb(51 65 85 / 0.5) 75%);
  background-size: 200% 100%;
}

/* ============================================================
   DIVIDER
   ============================================================ */
.divider-brand {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-400), transparent);
  border: none;
}

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