/* ===== Premium UI — Animations & Enhanced Components ===== */

/* ===== Keyframes ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

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

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

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(20px) scale(.9); }
}

@keyframes float {
  0%   { transform: translateY(0) scale(1); }
  100% { transform: translateY(-30px) scale(1.1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .5; }
}

@keyframes checkBounce {
  0%   { transform: scale(0); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ===== Page Entry Animation ===== */
.content-area > *:not(.slide-panel):not(.slide-panel-backdrop):not(.cmd-palette):not(.cmd-palette-backdrop):not(script):not(style) {
  animation: fadeInUp .4s cubic-bezier(.4,0,.2,1) both;
}
.content-area > *:nth-child(2):not(.slide-panel):not(.slide-panel-backdrop) { animation-delay: .05s; }
.content-area > *:nth-child(3):not(.slide-panel):not(.slide-panel-backdrop) { animation-delay: .1s; }
.content-area > *:nth-child(4):not(.slide-panel):not(.slide-panel-backdrop) { animation-delay: .15s; }
.content-area > *:nth-child(5):not(.slide-panel):not(.slide-panel-backdrop) { animation-delay: .2s; }
.content-area > *:nth-child(6):not(.slide-panel):not(.slide-panel-backdrop) { animation-delay: .25s; }

/* Forzar que slide panels no tengan animacion de entrada y mantengan su transform */
.content-area > .slide-panel,
.content-area > .slide-panel-backdrop {
  animation: none !important;
}

/* ===== Page Header (Concept C — Minimal lightweight) ===== */
.page-header {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: 1.75rem;
  padding: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
  border-left: none;
}

.page-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent-primary) 10%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: none;
}

.page-header-text h4 {
  font-size: 1.4rem;
  font-weight: 300;
  margin: 0;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -.3px;
}

.page-header-text small {
  color: var(--text-muted);
  font-size: .78rem;
  margin-top: 2px;
  display: block;
  font-weight: 400;
}

.page-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* ===== Card Enhancements (Concept C — minimal) ===== */
.card {
  transition: box-shadow .15s ease;
}
.card:hover {
  box-shadow: var(--card-shadow-hover);
}

.card-filter {
  border: 1px solid var(--border-color) !important;
  background: var(--card-bg) !important;
}

.card-header {
  font-weight: 500;
  font-size: .85rem;
}

/* ===== Dropdown Themed ===== */
.dropdown-menu {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 6px;
}

.dropdown-item {
  color: var(--text-primary);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .85rem;
  transition: background .15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--page-bg);
  color: var(--text-primary);
}

.dropdown-item.text-danger {
  color: var(--badge-danger-text) !important;
}
.dropdown-item.text-danger:hover {
  background: var(--badge-danger-bg);
}

.dropdown-divider {
  border-color: var(--border-color-light);
  margin: 4px 0;
}

/* ===== Table Enhancements (Concept C — clean) ===== */
.table > tbody > tr {
  transition: background .12s ease;
}
.table > tbody > tr:hover {
  background: var(--page-bg) !important;
}
.table > tbody > tr:hover > td {
  color: var(--text-primary);
}

.row-actions {
  opacity: .3;
  transition: opacity .2s ease;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  white-space: nowrap;
}
tr:hover .row-actions {
  opacity: 1;
}
.row-actions .btn {
  white-space: nowrap;
}

/* Row stagger animation */
.row-entering {
  animation: fadeInUp .3s cubic-bezier(.4,0,.2,1) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

/* Sticky thead */
.table-responsive .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Table card wrapper */
.card .table-responsive {
  border-radius: 0 0 var(--radius-md, 14px) var(--radius-md, 14px);
  overflow: hidden;
}

/* Card footer counter */
.card-footer {
  font-size: .8rem;
  font-weight: 500;
}

/* ===== Slide Panel ===== */
.slide-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1040;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.slide-panel-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--card-bg);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-elevation-3, 0 12px 36px rgba(0,0,0,.1));
  z-index: 1050;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}
.slide-panel.active {
  transform: translateX(0);
}

.slide-panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.slide-panel-header h5 {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.slide-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all .15s ease;
}
.slide-panel-close:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-primary);
}

.slide-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.slide-panel-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color-light);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* ===== Toast System ===== */
.toast-container-custom {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1100;
  display: flex;
  flex-direction: column-reverse;
  gap: .5rem;
  pointer-events: none;
}

.toast-custom {
  pointer-events: auto;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm, 10px);
  background: var(--card-bg);
  border: 1px solid var(--border-color-light);
  box-shadow: var(--shadow-elevation-2, 0 4px 12px rgba(0,0,0,.08));
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 280px;
  max-width: 400px;
  animation: toastSlideIn .4s cubic-bezier(.175,.885,.32,1.275);
}

.toast-custom.removing {
  animation: toastSlideOut .25s ease forwards;
}

.toast-custom-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  flex-shrink: 0;
}
.toast-custom.toast-success .toast-custom-icon {
  background: var(--badge-success-bg);
  color: var(--badge-success-text);
}
.toast-custom.toast-danger .toast-custom-icon {
  background: var(--badge-danger-bg);
  color: var(--badge-danger-text);
}
.toast-custom.toast-warning .toast-custom-icon {
  background: var(--badge-warning-bg);
  color: var(--badge-warning-text);
}

.toast-custom-text {
  flex: 1;
  font-size: .85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.toast-custom-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: .75rem;
  opacity: .5;
  transition: opacity .15s;
}
.toast-custom-close:hover { opacity: 1; }

/* ===== Empty States ===== */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  animation: fadeIn .5s ease;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
  color: var(--accent-primary);
}

.empty-state h6 {
  font-weight: 600;
  margin-bottom: .25rem;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-muted);
  font-size: .85rem;
  max-width: 280px;
  margin: 0 auto;
}

.empty-state .btn {
  margin-top: 1rem;
}

/* ===== Skeleton Loaders ===== */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base, var(--border-color-light)) 25%, var(--skeleton-shine, var(--card-bg)) 50%, var(--skeleton-base, var(--border-color-light)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-text-sm { height: 10px; margin-bottom: 6px; }
.skeleton-row { height: 40px; margin-bottom: 4px; border-radius: 6px; }

/* ===== Navbar Breadcrumb ===== */
.navbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: .8rem;
}
.navbar-breadcrumb .bi { font-size: .55rem; }
.navbar-breadcrumb span { color: var(--text-secondary); }

/* Navbar user button */
.navbar-user-btn {
  border-radius: var(--radius-sm, 10px) !important;
  padding: .35rem .65rem !important;
  transition: all .15s ease !important;
}
.navbar-user-btn:hover {
  background: var(--sidebar-hover-bg) !important;
}

/* ===== Export Dropdown ===== */
.export-dropdown .dropdown-item i {
  width: 18px;
  text-align: center;
}

/* ===== Navbar rediseñado (Concept C) ===== */
.top-navbar {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-app-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--navbar-brand-color);
  letter-spacing: -.2px;
}

/* Command Palette Trigger (central search button) */
.cmd-trigger-wrapper {
  flex: 1;
  max-width: 520px;
  display: flex;
  justify-content: center;
}

.cmd-trigger {
  width: 100%;
  max-width: 480px;
  background: var(--page-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all .15s ease;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
}

.cmd-trigger:hover {
  border-color: var(--accent-primary);
  background: var(--card-bg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 8%, transparent);
}

.cmd-trigger-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.cmd-trigger-placeholder {
  flex: 1;
  color: var(--text-muted);
}

.cmd-trigger-kbd {
  display: flex;
  gap: 3px;
}
.cmd-trigger-kbd kbd {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: inherit;
  color: var(--text-secondary);
  line-height: 1.4;
}

@media (max-width: 768px) {
  .cmd-trigger-placeholder { display: none; }
  .cmd-trigger-kbd { display: none; }
  .cmd-trigger { padding: 7px 10px; justify-content: center; max-width: 44px; }
}

/* ===== Command Palette Overlay ===== */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8,9,10,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1060;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.cmd-palette-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.cmd-palette {
  position: fixed;
  top: 15vh;
  left: 50%;
  transform: translateX(-50%) scale(.96);
  width: 90%;
  max-width: 600px;
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 0 0 1px var(--border-color-light);
  z-index: 1070;
  opacity: 0;
  pointer-events: none;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.cmd-palette.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.cmd-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color-light);
}
.cmd-palette-input-wrap i {
  color: var(--text-muted);
  font-size: 16px;
}
.cmd-palette-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
}
.cmd-palette-input::placeholder {
  color: var(--text-muted);
}
.cmd-palette-esc {
  background: var(--page-bg);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: inherit;
}

.cmd-palette-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.cmd-palette-section {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 8px 12px 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .1s ease;
  user-select: none;
}
.cmd-item:hover,
.cmd-item.selected {
  background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
}

.cmd-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.cmd-item-content {
  flex: 1;
  min-width: 0;
}
.cmd-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-item-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-item-hint {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cmd-palette-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.cmd-palette-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--page-bg);
}
.cmd-palette-footer-hints {
  display: flex;
  gap: 16px;
}
.cmd-palette-footer-hint {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cmd-palette-footer-hint kbd {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 9px;
  font-family: inherit;
  color: var(--text-secondary);
}

/* Hide the breadcrumb we don't need anymore */
.navbar-breadcrumb { display: none !important; }

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