/* ============================================
   ActionLatam — Global Styles & Animations
   ============================================ */

/* --- Base Reset & Typography --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: rgb(var(--background));
  color: rgb(var(--foreground));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* --- Animated Gradient Background (Login) --- */
.animated-gradient {
  background: linear-gradient(
    -45deg,
    rgb(var(--background)),
    rgb(9 9 20),
    rgb(0 20 50),
    rgb(5 5 15),
    rgb(var(--background))
  );
  background-size: 400% 400%;
  animation: gradient-shift 20s ease infinite;
}

[data-theme="light"] .animated-gradient {
  background: linear-gradient(
    -45deg,
    rgb(var(--background)),
    rgb(235 245 255),
    rgb(220 240 255),
    rgb(245 245 250),
    rgb(var(--background))
  );
  background-size: 400% 400%;
}

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

/* --- Glassmorphism Card --- */
.glass-card {
  background: rgb(var(--card) / 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgb(var(--border) / 0.5);
  border-radius: calc(var(--radius) * 2);
}

/* --- Floating Orbs (Login background decoration) --- */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: rgb(var(--primary));
  top: -100px;
  right: -100px;
  animation: orb-float 12s ease-in-out infinite;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: rgb(var(--accent));
  bottom: -80px;
  left: -80px;
  animation: orb-float 15s ease-in-out infinite reverse;
}

.orb-3 {
  width: 200px;
  height: 200px;
  background: rgb(var(--primary));
  top: 50%;
  left: 50%;
  animation: orb-float 18s ease-in-out infinite 3s;
}

@keyframes orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.1); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(15px, 30px) scale(1.05); }
}

/* --- Input Styles --- */
.input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  padding-left: 2.75rem;
  background: rgb(var(--muted) / 0.5);
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  color: rgb(var(--foreground));
  font-size: 0.875rem;
  outline: none;
  transition: all 0.2s ease;
}

.input-field::placeholder {
  color: rgb(var(--muted-foreground));
}

.input-field:focus {
  border-color: rgb(var(--accent) / 0.6);
  box-shadow: 0 0 0 3px rgb(var(--accent) / 0.1);
  background: rgb(var(--muted) / 0.8);
}

.input-field:hover:not(:focus) {
  border-color: rgb(var(--border) / 0.8);
  background: rgb(var(--muted) / 0.6);
}

.input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgb(var(--muted-foreground));
  width: 18px;
  height: 18px;
  pointer-events: none;
  transition: color 0.2s ease;
}

.input-wrapper:focus-within .input-icon {
  color: rgb(var(--accent));
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  outline: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px rgb(var(--background)), 0 0 0 4px rgb(var(--ring));
}

.btn-primary {
  background: linear-gradient(135deg, rgb(var(--primary)), rgb(var(--primary) / 0.8));
  color: rgb(var(--primary-foreground));
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2), 0 1px 2px rgb(0 0 0 / 0.1);
}

.btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgb(var(--primary) / 0.4), 0 1px 3px rgb(0 0 0 / 0.2);
}

.btn-primary:active {
  transform: scale(0.98) translateY(0);
  filter: brightness(1);
}

.btn-secondary {
  background: rgb(var(--muted));
  color: rgb(var(--foreground));
  border: 1px solid rgb(var(--border));
}

.btn-secondary:hover {
  background: rgb(var(--muted) / 0.8);
  border-color: rgb(var(--muted-foreground) / 0.3);
}

.btn-ghost {
  background: transparent;
  color: rgb(var(--muted-foreground));
}

.btn-ghost:hover {
  background: rgb(var(--muted) / 0.5);
  color: rgb(var(--foreground));
}

.btn-danger {
  background: rgb(var(--destructive));
  color: rgb(var(--destructive-foreground));
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

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

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius);
}

/* Loading spinner for buttons */
.btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgb(var(--primary-foreground) / 0.3);
  border-top-color: rgb(var(--primary-foreground));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Animations --- */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-out-right {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-100%); }
  to { opacity: 1; transform: translateX(0); }
}

.animate-fade-in-up { animation: fade-in-up 0.6s ease-out; }
.animate-fade-in { animation: fade-in 0.3s ease-out; }
.animate-scale-in { animation: scale-in 0.2s ease-out; }

/* Staggered children animation */
.stagger-children > * {
  opacity: 0;
  animation: fade-in-up 0.4s ease-out forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }

/* --- Toast Container --- */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

#toast-container > * {
  pointer-events: all;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  background: rgb(var(--card));
  border: 1px solid rgb(var(--border));
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.3);
  font-size: 0.875rem;
  min-width: 300px;
  max-width: 420px;
  animation: slide-in-right 0.3s ease-out;
}

.toast.removing {
  animation: slide-out-right 0.3s ease-in forwards;
}

.toast-success { border-left: 3px solid rgb(var(--success)); }
.toast-error { border-left: 3px solid rgb(var(--destructive)); }
.toast-warning { border-left: 3px solid rgb(var(--warning)); }
.toast-info { border-left: 3px solid rgb(var(--primary)); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s ease-out;
}

.modal-content {
  background: rgb(var(--card));
  border: 1px solid rgb(var(--border));
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.5);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: scale-in 0.2s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgb(var(--border));
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgb(var(--border));
}

/* --- Sidebar --- */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  margin: 0 0.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: rgb(var(--muted-foreground));
  transition: all 0.15s ease;
  cursor: pointer;
  border-left: 2px solid transparent;
  position: relative;
}

.sidebar-item:hover {
  background: rgb(var(--muted) / 0.5);
  color: rgb(var(--foreground));
}

.sidebar-item.active {
  background: rgb(var(--sidebar-accent));
  color: rgb(var(--accent));
  border-left-color: rgb(var(--sidebar-active-border));
}

.sidebar-item .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: rgb(var(--muted));
  color: rgb(var(--muted-foreground));
  font-weight: 500;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgb(var(--border));
  white-space: nowrap;
  user-select: none;
}

.data-table th:first-child { border-radius: var(--radius) 0 0 0; }
.data-table th:last-child { border-radius: 0 var(--radius) 0 0; }

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgb(var(--border) / 0.5);
  color: rgb(var(--foreground));
}

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgb(var(--muted) / 0.3);
}

.data-table th.sortable {
  cursor: pointer;
}

.data-table th.sortable:hover {
  color: rgb(var(--foreground));
}

/* --- Badge/Tag --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success {
  background: rgb(var(--success) / 0.15);
  color: rgb(var(--success));
}

.badge-warning {
  background: rgb(var(--warning) / 0.15);
  color: rgb(var(--warning));
}

.badge-danger {
  background: rgb(var(--destructive) / 0.15);
  color: rgb(var(--destructive));
}

.badge-info {
  background: rgb(var(--primary) / 0.15);
  color: rgb(var(--primary));
}

.badge-accent {
  background: rgb(var(--accent) / 0.15);
  color: rgb(var(--accent));
}

.badge-muted {
  background: rgb(var(--muted));
  color: rgb(var(--muted-foreground));
}

/* --- KPI Card --- */
.kpi-card {
  background: rgb(var(--card));
  border: 1px solid rgb(var(--border));
  border-radius: calc(var(--radius) * 1.5);
  padding: 1.25rem;
  transition: all 0.2s ease;
}

.kpi-card:hover {
  border-color: rgb(var(--muted-foreground) / 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
}

/* --- Dropdown --- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: rgb(var(--card));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.3);
  z-index: 100;
  animation: scale-in 0.15s ease-out;
  overflow: hidden;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  color: rgb(var(--foreground));
  cursor: pointer;
  transition: background 0.1s ease;
}

.dropdown-item:hover {
  background: rgb(var(--muted) / 0.5);
}

.dropdown-item.active {
  color: rgb(var(--accent));
}

.dropdown-divider {
  height: 1px;
  background: rgb(var(--border));
  margin: 0.25rem 0;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: rgb(var(--muted-foreground));
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}

.pagination-btn:hover {
  background: rgb(var(--muted) / 0.5);
  color: rgb(var(--foreground));
}

.pagination-btn.active {
  background: rgb(var(--primary));
  color: rgb(var(--primary-foreground));
  border-color: rgb(var(--primary));
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgb(var(--muted));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--muted-foreground) / 0.5);
}

/* --- Text Selection --- */
::selection {
  background: rgb(var(--accent) / 0.25);
  color: rgb(var(--foreground));
}

/* --- Focus Visible --- */
*:focus-visible {
  outline: 2px solid rgb(var(--ring));
  outline-offset: 2px;
}

/* --- Transition Utilities --- */
.transition-theme {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* --- Notification Badge Pulse --- */
.notification-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: rgb(var(--destructive));
  border-radius: 50%;
  border: 2px solid rgb(var(--background));
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgb(var(--destructive) / 0.4); }
  100% { box-shadow: 0 0 0 8px rgb(var(--destructive) / 0); }
}

.notification-dot.has-new {
  animation: pulse-ring 2s infinite;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  color: rgb(var(--muted-foreground));
}

.empty-state .icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* --- Logo Gradient Text --- */
.logo-gradient {
  background: linear-gradient(135deg, rgb(var(--accent)), rgb(var(--primary)));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Password Toggle --- */
.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgb(var(--muted-foreground));
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

.password-toggle:hover {
  color: rgb(var(--foreground));
}
