/* =========================================================
   Light Theme + Animations + Skeleton
   ========================================================= */

/* ==================== Light Theme ==================== */
[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #eef1f8;
  --panel-3: #e6eaf3;
  --border: #d1d9e6;
  --border-soft: #e1e6ef;
  --text: #1a1f36;
  --text-muted: #5a6380;
  --text-dim: #8a92a8;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --cyan: #0891b2;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
}

[data-theme="light"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="light"] #topbar,
[data-theme="light"] #sidebar {
  background: var(--panel);
}

[data-theme="light"] .top-btn {
  background: var(--panel-2);
  color: var(--text-muted);
}

[data-theme="light"] .top-btn:hover {
  background: #dbe1ee;
  color: var(--text);
}

[data-theme="light"] .menu-group {
  background: #f8fafd;
  border-color: var(--border-soft);
}

[data-theme="light"] .menu-item {
  color: #4a5268;
}

[data-theme="light"] .menu-item:hover {
  background: rgba(99,102,241,.1);
  color: var(--text);
}

[data-theme="light"] .menu-item.active {
  background: rgba(99,102,241,.15);
  color: var(--accent);
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #ffffff !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

[data-theme="light"] .panel,
[data-theme="light"] .card {
  background: var(--panel);
  border-color: var(--border);
}

[data-theme="light"] .toast {
  background: #ffffff;
  color: var(--text);
}

[data-theme="light"] .login-card {
  background: var(--panel);
}

[data-theme="light"] .login-logo {
  background: transparent;
  box-shadow: 0 10px 30px rgba(99,102,241,.15);
}

/* ==================== Theme Toggle Button ==================== */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .3s cubic-bezier(.34, 1.56, .64, 1);
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: #26265a;
  color: var(--cyan);
  transform: rotate(15deg) scale(1.05);
}

[data-theme="light"] .theme-toggle:hover {
  background: #dbe1ee;
}

.theme-toggle:active {
  transform: scale(.92);
}

/* ==================== Skeleton Loading ==================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--panel) 0%,
    var(--panel-2) 50%,
    var(--panel) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .skeleton {
  background: linear-gradient(
    90deg,
    #eef1f8 0%,
    #dde3ee 50%,
    #eef1f8 100%
  );
  background-size: 200% 100%;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full { width: 100%; }

.skeleton-card {
  height: 100px;
  border-radius: 14px;
  margin-bottom: 12px;
}

.skeleton-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

/* ==================== Page Transition ==================== */
@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page {
  animation: pageSlideIn .35s cubic-bezier(.22, 1, .36, 1);
}

/* ==================== Hover Lift ==================== */
.card {
  transition: transform .25s cubic-bezier(.22, 1, .36, 1),
              border-color .2s,
              box-shadow .25s;
}

.card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
}

[data-theme="light"] .card:hover {
  box-shadow: 0 12px 32px rgba(15,23,42,.12);
}

/* ==================== Button Pulse ==================== */
@keyframes buttonPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
  70%  { box-shadow: 0 0 0 12px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.btn-primary:not(:disabled):hover {
  animation: buttonPulse 1.5s infinite;
}

/* ==================== Global Search (Ctrl+K) ==================== */
#global-search {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeIn .2s ease;
}

.search-modal {
  width: 580px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: searchIn .3s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes searchIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.search-input-wrap .icon {
  font-size: 20px;
  color: var(--text-muted);
}

.search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

.search-input-wrap kbd {
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}

.search-item:hover,
.search-item.selected {
  background: rgba(99,102,241,.15);
}

.search-item .icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.search-item .title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.search-item .hint {
  font-size: 12px;
  color: var(--text-muted);
}

.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ==================== Enhanced Toast ==================== */
.toast {
  position: relative;
  overflow: hidden;
  padding-right: 40px;
}

.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: .3;
  animation: toastProgress 3.5s linear forwards;
}

.toast.success::after { color: var(--success); }
.toast.error::after   { color: var(--danger); }
.toast.warning::after { color: var(--warning); }

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

.toast .toast-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .2s;
}

.toast .toast-close:hover {
  background: rgba(255,255,255,.1);
}

/* ==================== Loading Dots ==================== */
.loading-dots {
  display: inline-flex;
  gap: 3px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: dotBounce .8s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ==================== Number Counter Animation ==================== */
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.count-anim {
  animation: countUp .4s ease;
}

/* ==================== Progress Pulse ==================== */
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .85; }
}

.progress-active {
  animation: progressPulse 2s ease-in-out infinite;
}

/* ==================== Better Mobile Responsive ==================== */
@media (max-width: 900px) {
  #app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr auto;
  }

  #sidebar {
    grid-column: 1;
    grid-row: 3;
    max-height: 260px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  #main-content {
    grid-column: 1;
    grid-row: 2;
    padding: 12px;
  }

  .topbar-section:first-child .top-btn:not(#exitBtn) {
    display: none;
  }

  .brand-text {
    display: none;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }

  .card-value {
    font-size: 18px !important;
  }

  .page-title {
    font-size: 18px !important;
  }

  .page-title .emoji {
    font-size: 22px !important;
  }

  .panel {
    padding: 14px;
  }

  .search-modal {
    width: 100%;
    border-radius: 18px 18px 0 0;
    margin-top: auto;
  }

  #global-search {
    padding-top: 0;
    align-items: flex-end;
  }
}

@media (max-width: 500px) {
  .topbar-section {
    gap: 8px;
  }

  .user-meta {
    display: none;
  }

  .top-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .btn-primary {
    padding: 12px;
    font-size: 14px;
  }
}

@keyframes pulse-dot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.6;
  }
}