/**
 * AceBGCSE Shared Styles
 * Unified CSS custom properties, resets, and shared component styles.
 * Imported by every page for consistent theming.
 */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #050914;
  --bg-secondary: #0a1020;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --accent: #00E5FF;
  --accent-hover: #00c4db;
  --secondary: #5B7CFF;
  --green: #00D4AA;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
}

/* ---------- Global Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
}

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ---------- Selection ---------- */
::selection {
  background: rgba(0, 229, 255, 0.3);
  color: #fff;
}

/* ---------- Shared Animations ---------- */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 229, 255, 0.3); }
  50% { box-shadow: 0 0 40px rgba(0, 229, 255, 0.5); }
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

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

.animate-fade-in-up { animation: fade-in-up 0.8s ease-out forwards; }
.animate-float { animation: float 6s ease-in-out infinite; }
.animate-pulse-glow { animation: pulse-glow 3s ease-in-out infinite; }
.animate-gradient { background-size: 200% 200%; animation: gradient-shift 8s ease infinite; }
.animate-slide-in-left { animation: slide-in-left 0.6s ease-out forwards; }

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }

/* ---------- Glass Morphism ---------- */
.glass {
  background: rgba(255, 255, 255, 0.03);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-sm {
  background: rgba(255, 255, 255, 0.02);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------- Gradient Text ---------- */
.gradient-text {
  background: linear-gradient(135deg, #00E5FF 0%, #5B7CFF 50%, #00D4AA 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Button Shine ---------- */
.btn-shine {
  position: relative;
  overflow: hidden;
}

.btn-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(45deg);
  transition: all 0.5s;
  opacity: 0;
}

.btn-shine:hover::after {
  left: 100%;
  opacity: 1;
}

/* ---------- Grid Pattern Background ---------- */
.grid-pattern {
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* ---------- Smooth Gradient Background (Auth, Dashboard) ---------- */
.gradient-bg {
  background: linear-gradient(135deg, rgba(5, 9, 20, 1) 0%, rgba(26, 10, 46, 0.8) 50%, rgba(15, 22, 41, 1) 100%);
  position: relative;
}

.gradient-bg::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  background: transparent;
  border-radius: 50%;
  pointer-events: none;
}

.gradient-bg::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  background: transparent;
  border-radius: 50%;
  pointer-events: none;
}

/* ---------- Loading Spinner ---------- */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 0.8s ease-in-out infinite;
}

.loading-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* ---------- Messages ---------- */
.success-message {
  background: rgba(0, 212, 170, 0.1);
  border: 1px solid rgba(0, 212, 170, 0.3);
  color: #00D4AA;
}

.error-message {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: #FF4757;
}

/* ---------- Trial Banner ---------- */
.trial-banner {
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.15), rgba(91, 124, 255, 0.15));
  border: 1px solid rgba(0, 229, 255, 0.2);
  color: var(--accent);
}

.trial-banner-urgent {
  background: linear-gradient(90deg, rgba(255, 71, 87, 0.15), rgba(255, 107, 107, 0.15));
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: #FF4757;
}

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

.card-hover:hover {
  transform: translateY(-8px);
  border-color: rgba(0, 229, 255, 0.3);
}

/* ---------- Stat Card ---------- */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.1), transparent);
  transition: left 0.5s;
}

.stat-card:hover::before {
  left: 100%;
}

/* ---------- Orb Decorations (Disabled) ---------- */
.orb {
  display: none;
}

.orb-1 {
  display: none;
}

.orb-2 {
  display: none;
}

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

/* ---------- iOS Safe Area ---------- */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* ---------- Touch Targets (WCAG 2.5.5) ---------- */
@media (pointer: coarse) {
  button, a, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ---------- Print ---------- */
@media print {
  header, footer, .orb, .trial-banner, button[onclick] { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .glass, .glass-sm { background: #f5f5f5 !important; border: 1px solid #ddd !important; }
}

/* ========== MOBILE RESPONSIVE FIXES ========== */

/* Mobile First: Base styles for small screens */
@media (max-width: 768px) {
  /* Ensure mobile viewport doesn't show desktop layout */
  html, body {
    width: 100%;
    overflow-x: hidden;
  }

  /* Fix for Windows-like display on mobile */
  body {
    max-width: 100vw;
    margin: 0;
    padding: 0;
  }

  /* Ensure buttons are touch-friendly */
  button, a, [role="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
  }

  /* Fix auth container on mobile */
  .auth-container, .dashboard-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 1rem;
  }

  /* Fix form inputs on mobile */
  input, textarea, select {
    width: 100%;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }

  /* Fix navigation on mobile */
  nav, header {
    width: 100%;
    padding: 1rem 1rem;
  }

  /* Ensure modals/dialogs work on mobile */
  .modal, .dialog {
    width: calc(100% - 2rem);
    max-height: 90vh;
  }

  /* Fix hero sections on mobile */
  .hero, .hero-section {
    padding: 2rem 1rem;
    min-height: auto;
  }

  /* Fix text sizes on mobile */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.1rem; }

  /* Fix grid layouts on mobile */
  .grid, .grid-cols-2, .grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Fix sidebar on mobile */
  .sidebar, .nav-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 80%;
    height: 100vh;
    transition: left 0.3s ease;
    z-index: 1000;
  }

  .sidebar.open, .nav-sidebar.open {
    left: 0;
  }

  /* Fix bottom sheets on mobile */
  .bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    border-radius: 1.5rem 1.5rem 0 0;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .sidebar {
    width: 200px;
  }
}

/* Landscape mobile */
@media (max-height: 600px) and (max-width: 900px) {
  body {
    padding-top: 0;
  }
  
  header, nav {
    padding: 0.5rem;
  }
  
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1rem; }
}

/* Large desktop */
@media (min-width: 1441px) {
  .container, .max-width-container {
    max-width: 1280px;
  }
}

/* Ensure no horizontal scroll on any device */
* {
  max-width: 100%;
}

body {
  overflow-x: hidden !important;
}
