/* =============================================
   =                ROOT VARIABLES             =
   ============================================= */
:root {
  /* Colors */
  --primary-purple: #9b5eff;
  --bg-gradient: radial-gradient(circle at top left, #111 0%, #000 100%);
  --bg-dark: #111;
  --bg-card: #1a1a1a;
  --bg-modal: #1e1e1e;
  --text-primary: #fff;
  --text-secondary: #ccc;
  --text-meta: #aaa;
  --text-footer-link: #a0aec0;
  --border-primary: #333;
  --border-secondary: #444;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.1);

  /* Sizing & Spacing */
  --radius-l: 16px;
  --radius-m: 12px;
  --radius-s: 8px;
  --radius-xs: 6px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-med: 0.3s ease;

  /* Fonts */
  --font-main: "Segoe UI", sans-serif;
  --font-code: "Fira Code", "Courier New", Courier, monospace;
}

/* =============================================
   =                GLOBAL STYLES              =
   ============================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background: var(--bg-gradient);
  color: var(--text-primary);
  padding: 20px;
  min-height: 100vh;
  overflow-x: hidden;
}

.card-hidden {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

/* =============================================
   =            LAYOUT & MAIN SECTIONS         =
   ============================================= */
.fancy-header {
  position: sticky;
  top: 0;
  z-index: 999;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 20px rgba(155, 94, 255, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-l);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 30px;
  margin-bottom: 30px;
}

.content {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.content-header h2 {
  font-size: 28px;
  margin-bottom: 10px;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}

/* =============================================
   =                 COMPONENTS                =
   ============================================= */
/* ----- Logo & Navigation ----- */
.logo,
.brand-highlight {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(to left, rgb(155, 139, 139), #ffffff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: flicker 2s infinite alternate;
}

nav a {
  margin: 0 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}

nav a::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition-med);
}

nav a:hover {
  color: var(--text-primary);
}

nav a:hover::after {
  width: 100%;
}

/* ----- Buttons ----- */
.glow-btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-m);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
  box-shadow: 0 0 15px rgba(155, 94, 255, 0.2);
  transition: all var(--transition-med);
}
.glow-btn:hover {
  background: var(--text-primary);
  color: black;
  box-shadow: 0 0 25px rgba(155, 94, 255, 0.53);
}

.copy-btn {
  background: #2a2a2a;
  color: var(--text-secondary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.copy-btn:hover {
  background: var(--border-primary);
  border-color: #777;
  color: var(--text-primary);
  transform: translateY(-1px);
}

.close-btn {
  position: absolute;
  top: -15px;
  right: -10px;
  background: transparent;
  border: none;
  color: var(--text-meta);
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  transition: color var(--transition-fast);
  line-height: 1;
}
.close-btn:hover {
  color: var(--text-primary);
}

.copy-code-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--border-primary);
  border: 1px solid #555;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
  z-index: 10;
}
.copy-code-btn:hover {
  background: var(--border-secondary);
  color: var(--text-primary);
}

/* ----- Cards ----- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 320px;
  margin: 10px;
  transition: transform var(--transition-fast),
    box-shadow var(--transition-fast);
  min-width: 360px;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.08);
}

.preview {
  width: 100%;
  height: 260px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid var(--border-primary);
}
.preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--text-primary);
  pointer-events: none;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  font-size: 14px;
  color: var(--text-secondary);
}
.card-footer svg {
  margin-right: 6px;
  vertical-align: middle;
}

/* ----- Forms & Filters ----- */
.filters {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}
.filters select,
.filters input {
  padding: 8px 12px;
  border-radius: var(--radius-s);
  background: #1c1c1c;
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

/* ----- Modal ----- */
/* ====== Modal Overlay ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(10px) saturate(120%);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.3s ease;
}
.modal-overlay.show {
  display: flex;
  opacity: 1;
}

/* ====== Modal Box ====== */
.modal-content {
  background: linear-gradient(145deg, #1a1a1a, #111);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 900px;
  max-height: 88vh;
  overflow: hidden;
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.15), 0 0 60px rgba(0, 0, 0, 0.8);
  transform: scale(0.96);
  transition: transform 0.4s ease;
  display: flex;
  flex-direction: column;
}
.modal-overlay.show .modal-content {
  transform: scale(1);
}

/* ====== Modal Header ====== */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 1.6rem;
  background: linear-gradient(90deg, #fff, #bbb);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin: 0;
}

.modal-header p {
  color: #aaa;
  font-size: 0.9rem;
  margin: 5px 0 0;
}
.close-btn {
  background: transparent;
  border: none;
  font-size: 2rem;
  color: #ccc;
  cursor: pointer;
  transition: color 0.25s, transform 0.25s;
}
.close-btn:hover {
  color: #fff;
  transform: rotate(90deg);
}

/* ====== Modal Body ====== */
.modal-body {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 25px;
  overflow-y: auto;
  padding-right: 10px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

/* ====== Code Section ====== */
.code-section {
  flex: 1 1 45%;
  display: flex;
  flex-direction: column;
  min-width: 300px;
}
.code-section h4 {
  margin-bottom: 8px;
  color: #e0e0e0;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ====== Code Container ====== */
.code-container {
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s;
}
.code-container:hover {
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}
.code-container pre {
  margin: 0;
  padding: 15px;
  overflow: auto;
  flex-grow: 1;
  font-family: "Fira Code", monospace;
  color: #f0f0f0;
  font-size: 0.9rem;
  line-height: 1.6;
  background: #181818;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-container pre::-webkit-scrollbar {
  height: 6px;
}
.code-container pre::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

/* ====== Copy Button ====== */
.copy-code-btn {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #2b2b2b, #1a1a1a);
  color: #e0e0e0;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}
.copy-code-btn:hover {
  background: linear-gradient(180deg, #3a3a3a, #222);
  color: #fff;
  letter-spacing: 0.3px;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}
.copy-code-btn:active {
  transform: scale(0.97);
}

/* ====== Responsive ====== */
@media (max-width: 700px) {
  .modal-body {
    flex-direction: column;
  }
  .code-section {
    flex: 1 1 100%;
  }
}

/* =============================================
   =                   FOOTER                  =
   ============================================= */
.stylish-footer {
  background: transparent;
  padding: 60px 20px 30px;
  color: #cbd5e1;
}
.footer-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  max-width: 1200px;
  margin: auto;
  gap: 40px;
}
.footer-section {
  flex: 1 1 200px;
  min-width: 180px;
}
.footer-section h3 {
  color: var(--text-primary);
  font-size: 16px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.footer-section a {
  display: block;
  font-size: 14px;
  color: var(--text-footer-link);
  margin-bottom: 10px;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.footer-section a:hover {
  color: var(--text-primary);
  transform: translateX(4px);
}

.footer-socials a {
  font-size: 18px;
  color: var(--text-footer-link);
  margin-right: 15px;
  transition: transform var(--transition-fast), color var(--transition-fast);
}
.footer-socials a:hover {
  color: var(--text-primary);
  transform: scale(1.2);
}

.footer-section.brand h2 {
  font-size: 24px;
  margin-bottom: 10px;
}

.tagline {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 10px;
}
.license {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 20px;
}
.license a {
  color: #d8b4fe;
  text-decoration: none;
}

.footer-bottom {
  text-align: center;
  margin-top: 40px;
  font-size: 13px;
  color: #6b7280;
  border-top: 1px solid #2a2a2a;
  padding-top: 20px;
}

/* =============================================
   =                ANIMATIONS                 =
   ============================================= */
@keyframes flicker {
  from {
    opacity: 0.8;
  }
  to {
    opacity: 1;
  }
}

/* =============================================
   =                MEDIA QUERIES              =
   ============================================= */
@media (max-width: 768px) {
  .modal-body {
    flex-direction: column;
    max-height: 60vh;
  }
  .modal-content {
    padding: 20px;
  }
  .footer-content {
    flex-direction: column;
    gap: 30px;
    text-align: center;
  }
  .footer-socials {
    justify-content: center;
  }
}

/* =============================================
   =           MOBILE RESPONSIVENESS           =
   ============================================= */

/* For tablets and larger phones */
@media (max-width: 768px) {
  body {
    padding: 15px; /* Reduce body padding */
  }

  /* --- Header & Navigation --- */
  .fancy-header {
    flex-direction: column; /* Stack logo and nav */
    gap: 15px;
    padding: 15px;
    position: static; /* Remove sticky header on mobile if preferred */
  }

  .logo {
    font-size: 1.8rem; /* Slightly smaller logo */
  }

  nav a {
    margin: 0 8px; /* Reduce space between nav links */
    font-size: 0.95rem;
  }

  /* --- Content & Grid --- */
  .content-header {
    flex-direction: column; /* Stack title and filters */
    align-items: flex-start;
    gap: 15px;
  }

  .content-header h2 {
    font-size: 24px;
  }

  .filters {
    width: 100%; /* Make filters take full width */
  }

  .filters select,
  .filters input {
    width: 100%; /* Make form elements full-width */
  }

  .grid {
    gap: 15px; /* Reduce gap between cards */
  }

  .card {
    width: 100%; /* Make cards take full width */
    min-width: unset; /* Remove the minimum width restriction */
    margin: 0;
  }

  /* --- Modal --- */
  .modal-content {
    width: 95%; /* Use more screen width */
    padding: 20px;
    max-height: 85vh; /* Adjust max height */
  }

  .modal-body {
    flex-direction: column; /* Stack code sections */
    max-height: 60vh; /* Ensure body is scrollable within modal */
  }

  .modal-header h3 {
    font-size: 20px; /* Adjust modal title size */
  }

  .close-btn {
    top: -5px;
    right: 5px;
    font-size: 28px;
  }

  /* --- Footer --- */
  .footer-content {
    flex-direction: column; /* Stack footer sections */
    text-align: center; /* Center-align footer text */
    gap: 30px;
  }

  .footer-section a:hover {
    transform: none; /* Disable hover effect on mobile */
  }

  .footer-socials {
    justify-content: center; /* Center social icons */
  }
}

/* For smaller mobile devices */
@media (max-width: 480px) {
  body {
    padding: 10px; /* Further reduce padding */
  }

  .fancy-header {
    padding: 12px;
  }

  nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* Allow nav links to wrap if needed */
    gap: 10px;
  }

  .glow-btn {
    width: 100%; /* Make header button full-width */
    text-align: center;
  }

  .preview {
    height: 220px; /* Reduce preview height */
  }

  .modal-content {
    padding: 15px;
  }

  .code-container code {
    font-size: 13px; /* Smaller font for code for better fit */
  }

  .footer-section h3 {
    font-size: 15px;
  }
  .footer-section a,
  .tagline,
  .license {
    font-size: 13px;
  }
}
