/* ==============================================================================
   OmniPulse Mini App - Design System & Modern Responsive Styles
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Telegram Theme Variables with Fallbacks */
  --bg-color: var(--tg-theme-bg-color, #090d16);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #0f172a);
  --text-color: var(--tg-theme-text-color, #f8fafc);
  --hint-color: var(--tg-theme-hint-color, #94a3b8);
  --link-color: var(--tg-theme-link-color, #38bdf8);
  --button-color: var(--tg-theme-button-color, #6366f1);
  --button-text: var(--tg-theme-button-text-color, #ffffff);

  /* OmniPulse Brand Accents */
  --accent-cyan: #38bdf8;
  --accent-purple: #818cf8;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  /* Gradients & Glass */
  --grad-primary: linear-gradient(135deg, #6366f1 0%, #38bdf8 100%);
  --grad-card: linear-gradient(145deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.85) 100%);
  --grad-badge: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(99, 102, 241, 0.25));
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(56, 189, 248, 0.3);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
}

/* Container */
.app-container {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  padding: 12px 16px calc(80px + var(--safe-bottom)) 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 4px 4px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 11px;
  color: var(--hint-color);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.radar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-emerald);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Category Filter Pills */
.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px 0;
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--secondary-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hint-color);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-pill:hover {
  border-color: var(--glass-border-hover);
  color: var(--text-color);
}

.filter-pill.active {
  background: var(--grad-primary);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* Section Titles */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-count {
  font-size: 12px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Tracklist Grid */
.tracklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Track Card */
.track-card {
  position: relative;
  background: var(--grad-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.track-card:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
}

.track-poster-wrapper {
  position: relative;
  width: 72px;
  height: 104px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #1e293b;
}

.track-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.track-card:hover .track-poster {
  transform: scale(1.05);
}

.media-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #fff;
}

.media-badge.anime { background: rgba(56, 189, 248, 0.85); color: #020617; }
.media-badge.manga { background: rgba(236, 72, 153, 0.85); color: #ffffff; }
.media-badge.movie { background: rgba(245, 158, 11, 0.85); color: #020617; }
.media-badge.tv { background: rgba(129, 140, 248, 0.85); color: #ffffff; }
.media-badge.music { background: rgba(16, 185, 129, 0.85); color: #020617; }

.track-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
  min-width: 0;
}

.track-title {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.track-release-unit {
  font-size: 12px;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-top: 4px;
}

.countdown-box {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: var(--grad-badge);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #ffffff;
  margin-top: 6px;
  width: fit-content;
}

.countdown-icon {
  font-size: 12px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.untrack-btn {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.untrack-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
  border-color: rgba(239, 68, 68, 0.5);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--grad-card);
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 4px;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}

.empty-state p {
  font-size: 13px;
  color: var(--hint-color);
  max-width: 320px;
}

/* Calendar View */
.weekday-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.day-btn {
  background: var(--secondary-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 2px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.day-btn .day-short {
  font-size: 11px;
  font-weight: 600;
  color: var(--hint-color);
  display: block;
}

.day-btn .day-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-color);
  display: block;
  margin-top: 2px;
}

.day-btn.active {
  background: var(--grad-primary);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.day-btn.active .day-short,
.day-btn.active .day-num {
  color: #ffffff;
}

/* Guide & Command Showcase */
.guide-card {
  background: var(--grad-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.cmd-badge {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* External Browser Promo Banner */
.browser-promo-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(56, 189, 248, 0.2) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cta-button {
  background: var(--grad-primary);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: transform 0.2s ease;
}

.cta-button:hover {
  transform: translateY(-2px);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  padding: 8px 16px calc(8px + var(--safe-bottom)) 16px;
  display: flex;
  justify-content: space-around;
  z-index: 100;
}

.nav-tab {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--hint-color);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-tab .nav-icon {
  font-size: 19px;
  transition: transform 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-color);
}

.nav-tab.active {
  color: var(--accent-cyan);
}

.nav-tab.active .nav-icon {
  transform: scale(1.15);
}

/* Skeleton Loading Shimmer */
.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

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

/* Toast Notification */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
