/**
 * SuperAdmin Common Styles
 * Shared across all pages for consistent UI
 */

/* ========================================
   LIGHT MODE SIDEBAR FIX
   Ensures sidebar stays dark in light mode
   ======================================== */
[data-theme="light"] aside,
[data-theme="light"] [class*="sidebar"],
aside, [class*="sidebar"] {
  background: #1e293b !important;
  color: #fff !important;
}

[data-theme="light"] aside a,
[data-theme="light"] [class*="sidebar"] a,
[data-theme="light"] .sidebar-link,
[data-theme="light"] .nav-item {
  color: rgba(255,255,255,0.8) !important;
}

[data-theme="light"] aside a:hover,
[data-theme="light"] [class*="sidebar"] a:hover,
[data-theme="light"] .sidebar-link:hover,
[data-theme="light"] .nav-item:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #fff !important;
}

[data-theme="light"] aside [class*="active"],
[data-theme="light"] [class*="sidebar"] [class*="active"] {
  background: rgba(59,130,246,0.3) !important;
  color: #fff !important;
}

/* ========================================
   LOGO CLICKABLE STYLES
   ======================================== */
.sa-logo-wrapper,
.logo-clickable {
  cursor: pointer;
  transition: opacity 0.2s;
  text-decoration: none;
  display: block;
}

.sa-logo-wrapper:hover,
.logo-clickable:hover {
  opacity: 0.8;
}

/* ========================================
   MOBILE RESPONSIVE MENU
   ======================================== */
.mobile-menu-toggle,
.mobile-overlay {
  display: none;
}

/* Tablet Breakpoint */
@media (max-width: 1024px) {
  aside, [class*="sidebar"] {
    width: 220px !important;
  }
  main, [class*="main-content"], .main-content {
    margin-left: 220px !important;
  }
}

/* Mobile Breakpoint */
@media (max-width: 768px) {
  aside, [class*="sidebar"] {
    position: fixed !important;
    left: -280px !important;
    width: 260px !important;
    height: 100vh !important;
    z-index: 1000 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

  aside.mobile-open,
  [class*="sidebar"].mobile-open {
    left: 0 !important;
  }

  .mobile-menu-toggle {
    display: flex !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    color: white;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(59,130,246,0.4);
    transition: all 0.2s;
  }

  .mobile-menu-toggle:active {
    transform: scale(0.95);
  }

  .mobile-menu-toggle svg {
    width: 20px;
    height: 20px;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
    transition: opacity 0.3s;
  }

  .mobile-overlay.visible {
    display: block;
  }

  main, [class*="main-content"], .main-content {
    margin-left: 0 !important;
    padding: 70px 12px 12px 12px !important;
    width: 100% !important;
  }

  header, [class*="header"] {
    padding: 12px 16px 12px 80px !important;
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #0f172a !important;
    border-bottom: 1px solid #1e293b;
  }

  /* Card grids responsive */
  [class*="grid"] {
    grid-template-columns: 1fr !important;
  }

  /* Table responsive */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .mobile-menu-toggle {
    padding: 10px 14px;
    font-size: 13px;
  }

  .mobile-menu-toggle .menu-text {
    display: none;
  }

  main, [class*="main-content"], .main-content {
    padding: 65px 8px 8px 8px !important;
  }
}

/* Desktop - hide mobile elements */
@media (min-width: 769px) {
  .mobile-menu-toggle,
  .mobile-overlay {
    display: none !important;
  }
}

/* Large Desktop */
@media (min-width: 1400px) {
  aside, [class*="sidebar"] {
    width: 280px !important;
  }
  main, [class*="main-content"], .main-content {
    margin-left: 280px !important;
  }
}

/* ========================================
   TOAST NOTIFICATION STYLES
   ======================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #1e293b;
  border: 1px solid #334155;
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: toastSlide 0.3s ease;
}

.toast.success {
  border-left-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.toast.error {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.toast.warning {
  border-left-color: #f97316;
  background: rgba(249, 115, 22, 0.1);
}

.toast.info {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 13px;
  color: #f1f5f9;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 12px;
  color: #94a3b8;
  word-wrap: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.toast-close:hover {
  color: #f1f5f9;
}

@keyframes toastSlide {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastFadeOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Toast Mobile */
@media (max-width: 768px) {
  .toast-container {
    top: auto;
    bottom: 20px;
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .toast {
    padding: 12px 14px;
  }
}

/* ========================================
   LOADING SPINNER STYLES
   ======================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #334155;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: #94a3b8;
  margin-top: 16px;
  font-size: 14px;
}

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

/* Inline spinner for buttons/elements */
.spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

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

/* ========================================
   BACK TO DASHBOARD BUTTON
   ======================================== */
.back-to-dashboard {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 101;
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.2s;
}

.back-to-dashboard:hover {
  background: #334155;
}

@media (max-width: 768px) {
  .back-to-dashboard {
    top: 12px;
    right: 12px;
    padding: 8px 12px;
  }

  .back-to-dashboard .btn-text {
    display: none;
  }
}
