/* MODERN UI ENHANCEMENTS FOR DASHBOARD */
/* Animations & Transitions */

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

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

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

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

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

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

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

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

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

/* Enhanced Login Screen */
#login-screen {
  animation: fadeIn 0.4s ease-out;
}

.login-card {
  animation: fadeInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Enhanced Input Fields */
.input-field {
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.input-field:focus {
  transform: translateY(-1px);
}

.input-field:hover {
  border-color: rgba(148, 163, 184, .5);
}

/* Enhanced Buttons */
.btn-login {
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn-login::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  transition: left .5s;
}

.btn-login:hover::before {
  left: 100%;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(59, 130, 246, .3);
}

.btn-login:active {
  transform: translateY(0);
}

/* Header Button Enhancements */
.header-add-btn {
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-add-btn:hover {
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, .15);
}

.header-add-btn:active {
  transform: scale(0.98);
}

/* Enhanced Stat Cards */
.stat-card {
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeIn 0.4s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }

.stat-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12) !important;
}

/* Gradient Border on Hover */
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 1rem;
  padding: 1px;
  background: linear-gradient(135deg, rgba(59,130,246,.3), rgba(6,182,212,.3));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.stat-card:hover::before {
  opacity: 1;
}

/* Article Card Animations */
.article-card {
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-card:hover {
  transform: translateX(4px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
}

/* Tab Buttons */
.tab-btn {
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  background: rgba(148,163,184,.24);
  transform: translateY(-1px);
}

.tab-btn.active {
  animation: fadeInScale 0.3s ease-out;
}

/* Enhanced Toast Notifications */
.toast {
  animation: slideInRight 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(12px);
}

.toast.removing {
  animation: slideInLeft 0.3s ease-out forwards;
}

/* Modal Dialog System */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.25s ease-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  animation: fadeInScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.1);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
  color: inherit;
  font-size: 1.2rem;
}

.modal-close:hover {
  background: rgba(248, 113, 113, 0.15);
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.5rem;
}

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

.modal-btn {
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-btn-primary {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: white;
}

.modal-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.3);
}

.modal-btn-secondary {
  background: rgba(148, 163, 184, 0.1);
  color: inherit;
}

.modal-btn-secondary:hover {
  background: rgba(148, 163, 184, 0.2);
}

/* Skeleton Loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.12) 0%,
    rgba(148, 163, 184, 0.25) 50%,
    rgba(148, 163, 184, 0.12) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

.skeleton-card {
  background: var(--bg-card);
  border: 1px solid rgba(148, 163, 184, .15);
  border-radius: 1rem;
  padding: .9rem;
  margin-bottom: 1rem;
}

.skeleton-title {
  height: 1.2rem;
  width: 60%;
  margin-bottom: 0.75rem;
}

.skeleton-text {
  height: 0.8rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
  width: 40%;
}

/* Context Menu (Right-click) */
.context-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  display: none;
  min-width: 180px;
  animation: fadeInScale 0.15s ease-out;
  backdrop-filter: blur(12px);
}

.context-menu.active {
  display: block;
}

.context-menu-item {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  transition: all 0.15s;
  color: inherit;
}

.context-menu-item:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: translateX(3px);
}

.context-menu-item.danger:hover {
  background: rgba(248, 113, 113, 0.1);
  color: #ef4444;
}

.context-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* Keyboard Shortcuts */
.kbd {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  font-family: monospace;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 0.3rem;
  margin-left: auto;
  box-shadow: 0 2px 0 rgba(148, 163, 184, 0.15);
}

/* Progress Indicators */
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: 999px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

/* Glassmorphism Effects */
.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

[data-theme="dark"] .glass {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Enhanced Dropdown Menus */
.dropdown-enhanced {
  position: relative;
}

.dropdown-menu-enhanced {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.4rem;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.dropdown-menu-enhanced.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.dropdown-item-enhanced {
  padding: 0.6rem 0.8rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-item-enhanced:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: translateX(3px);
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0 0.3rem;
  animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: rgba(15, 23, 42, 0.95);
  color: white;
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 4000;
}

.tooltip::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
}

.tooltip:hover::before,
.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

[data-theme="dark"] .tooltip::before {
  background: rgba(241, 245, 249, 0.95);
  color: #0f172a;
}

[data-theme="dark"] .tooltip::after {
  border-top-color: rgba(241, 245, 249, 0.95);
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(148, 163, 184, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active {
  display: flex;
}

/* FAB Enhancements */
.fab {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

.fab:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 15px 35px rgba(59, 130, 246, 0.4);
}

.fab:active {
  transform: scale(0.95);
}

/* Search Bar Enhancement */
.search-input {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

/* Action Button Micro-interactions */
.action-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.action-btn:active {
  transform: scale(0.95);
}

/* Theme Toggle Animation */
.theme-toggle {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
  transform: rotate(20deg) scale(1.1);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.theme-toggle:active {
  transform: rotate(20deg) scale(0.95);
}

/* Checkbox Animations */
.checkbox-item {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-item:hover {
  transform: translateX(3px);
  background: rgba(148,163,184,.14);
}

[data-theme="dark"] .checkbox-item:hover {
  background: rgba(15,23,42,.35);
}

/* File Upload Area */
.file-upload-area {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.file-upload-area:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.05);
  transform: translateY(-2px);
}

.file-upload-area.drag-over {
  border-color: rgba(59, 130, 246, 0.8);
  background: rgba(59, 130, 246, 0.1);
  transform: scale(1.02);
}

/* User Card Hover */
.user-card {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}

/* Filter Dropdowns */
.filter-select {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-select:hover {
  border-color: rgba(148, 163, 184, 0.3);
}

.filter-select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Stagger Animation for Lists */
.article-card {
  animation: fadeIn 0.4s ease-out backwards;
}

.article-card:nth-child(1) { animation-delay: 0.05s; }
.article-card:nth-child(2) { animation-delay: 0.1s; }
.article-card:nth-child(3) { animation-delay: 0.15s; }
.article-card:nth-child(4) { animation-delay: 0.2s; }
.article-card:nth-child(5) { animation-delay: 0.25s; }
.article-card:nth-child(6) { animation-delay: 0.3s; }
.article-card:nth-child(7) { animation-delay: 0.35s; }
.article-card:nth-child(8) { animation-delay: 0.4s; }
.article-card:nth-child(9) { animation-delay: 0.45s; }
.article-card:nth-child(10) { animation-delay: 0.5s; }

/* Micro-interaction: Button Press */
button:active {
  transform: scale(0.97);
}

/* Focus Visible for Accessibility */
*:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Smooth transitions for theme switching */
* {
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Override for elements that shouldn't animate during theme switch */
.no-theme-transition * {
  transition: none !important;
}

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