/* ==========================================================================
   TemplateGalaxy — Cosmic Space Theme for Bootstrap 5.3
   ========================================================================== */

:root,
[data-bs-theme="dark"] {
  --bs-body-bg: #030712;
  --bs-body-color: #f8fafc;
  --bs-border-color: rgba(255, 255, 255, 0.12);
  --bs-primary: #a855f7;
  --bs-primary-rgb: 168, 85, 247;
  --bs-info: #00f2fe;
  --bs-info-rgb: 0, 242, 254;
  --bs-success: #10b981;
  --bs-warning: #f59e0b;
  --bs-danger: #f43f5e;
  --color-void: #030712;
  --color-abyss: #060919;
  --color-space-dark: #0a0f29;
  --color-neon-cyan: #00f2fe;
  --color-neon-blue: #4facfe;
  --color-neon-purple: #a855f7;
  --color-neon-pink: #ec4899;
}

html {
  max-width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #030712 !important;
  color: #f8fafc !important;
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.02em;
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Custom Cosmic Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #060919;
}
::-webkit-scrollbar-thumb {
  background: #252b48;
  border-radius: 4px;
  border: 2px solid #060919;
}
::-webkit-scrollbar-thumb:hover {
  background: #8b5cf6;
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ==========================================================================
   Bootstrap 5.3 Cosmic Form & Table Enhancements
   ========================================================================== */

.form-control,
.form-select {
  background-color: rgba(3, 7, 18, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #f8fafc !important;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  padding: 0.625rem 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control::placeholder {
  color: #64748b !important;
}

.form-control:focus,
.form-select:focus {
  background-color: rgba(6, 9, 25, 0.95) !important;
  border-color: #a855f7 !important;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25) !important;
  color: #ffffff !important;
  outline: none;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cbd5e1;
  margin-bottom: 0.4rem;
}

.form-check-input {
  background-color: #1e293b;
  border-color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
}
.form-check-input:checked {
  background-color: #10b981;
  border-color: #10b981;
}

.table-cosmic {
  --bs-table-bg: transparent;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: rgba(255, 255, 255, 0.08);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
  --bs-table-hover-color: #ffffff;
  margin-bottom: 0;
}
.table-cosmic thead th {
  background-color: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.85rem 1rem;
}
.table-cosmic tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* ==========================================================================
   Cosmic Glassmorphism, Buttons & Gradients
   ========================================================================== */

.cosmic-navbar {
  background-color: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cosmic-glass {
  background-color: rgba(10, 15, 41, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.cosmic-glass-hover {
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.cosmic-glass-hover:hover {
  background-color: rgba(10, 15, 41, 0.92);
  border-color: rgba(168, 85, 247, 0.45);
  transform: translateY(-4px);
  box-shadow: 0 16px 48px -8px rgba(168, 85, 247, 0.28), inset 0 0 0 1px rgba(168, 85, 247, 0.4);
}

.cosmic-btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.35rem;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff !important;
  background: linear-gradient(135deg, #a855f7 0%, #00f2fe 100%) !important;
  box-shadow: 0 0 25px -3px rgba(168, 85, 247, 0.5);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  text-decoration: none !important;
  white-space: nowrap;
}
.cosmic-btn-primary:hover {
  background: linear-gradient(135deg, #00f2fe 0%, #a855f7 100%) !important;
  box-shadow: 0 0 30px 0 rgba(0, 242, 254, 0.55);
  transform: translateY(-1px);
  color: #ffffff !important;
}
.cosmic-btn-primary:active {
  transform: translateY(0);
}
.cosmic-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.cosmic-btn-secondary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: #e2e8f0 !important;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
}
.cosmic-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff !important;
}

.cosmic-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.cosmic-gradient-text {
  background: linear-gradient(135deg, #00f2fe 0%, #a855f7 50%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  display: inline-block;
  font-weight: 900;
}

.card-preview-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 200px;
  overflow: hidden;
  background-color: #0a0f29;
}

.card-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.6s ease;
}
.cosmic-glass-hover:hover .card-preview-container img {
  transform: scale(1.05);
}

/* ==========================================================================
   Bulletproof Scrollable Modals & Drawers
   ========================================================================== */

.hidden,
.d-none {
  display: none !important;
}

#preview-modal,
#checkout-modal,
#stripe-modal,
#inspector-modal,
#cart-drawer,
#template-modal,
#preview-placeholder,
#checkout-free-banner {
  display: none;
}

#preview-modal:not(.hidden):not(.d-none) {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(3, 7, 18, 0.95);
  backdrop-filter: blur(16px);
}

#checkout-modal:not(.hidden):not(.d-none),
#stripe-modal:not(.hidden):not(.d-none),
#inspector-modal:not(.hidden):not(.d-none),
#template-modal:not(.hidden):not(.d-none) {
  display: flex !important;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 1060;
  padding: 0.75rem;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(14px);
  overflow-y: auto;
}

#cart-drawer:not(.hidden):not(.d-none) {
  display: flex !important;
  justify-content: flex-end;
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
}

#preview-placeholder:not(.hidden):not(.d-none),
#checkout-free-banner:not(.hidden):not(.d-none),
#cart-badge:not(.hidden):not(.d-none) {
  display: flex !important;
}

/* Guaranteed Scrollable Dialog Box for Admin & Storefront Modals */
.cosmic-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 820px;
  max-height: 92vh !important;
  margin: auto;
  display: flex !important;
  flex-direction: column !important;
  background-color: rgba(10, 15, 41, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 1.25rem;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 40px rgba(168, 85, 247, 0.2);
  overflow: hidden !important;
}

.cosmic-modal-header {
  flex-shrink: 0 !important;
  padding: 1rem 1.35rem;
  background: rgba(6, 9, 25, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 5;
}

.cosmic-modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: calc(92vh - 135px) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding: 1.35rem;
}

.cosmic-modal-footer {
  flex-shrink: 0 !important;
  padding: 0.9rem 1.35rem;
  background: rgba(6, 9, 25, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 5;
}

/* Ambient Background Glow Orbs */
.cosmic-orb-purple {
  position: fixed;
  top: 0;
  left: 20%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.1);
  filter: blur(130px);
  pointer-events: none;
  z-index: 0;
}

.cosmic-orb-cyan {
  position: fixed;
  bottom: 15%;
  right: 20%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(0, 242, 254, 0.09);
  filter: blur(150px);
  pointer-events: none;
  z-index: 0;
}

/* Admin Nav Pills */
.cosmic-nav-pills .nav-link {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.cosmic-nav-pills .nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}
.cosmic-nav-pills .nav-link.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.45), rgba(0, 242, 254, 0.35)) !important;
  border-color: rgba(168, 85, 247, 0.65) !important;
  box-shadow: 0 0 20px -5px rgba(168, 85, 247, 0.5);
}

/* Shadows & Animations */
.shadow-glow-purple {
  box-shadow: 0 0 25px -5px rgba(168, 85, 247, 0.45);
}
.shadow-glow-cyan {
  box-shadow: 0 0 25px -5px rgba(0, 242, 254, 0.45);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.animate-fade-in {
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
