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

/* CSS Variables - Theme System */
:root {
  /* Light theme defaults (will be overridden by theme classes) */
  --primary-color: #FF006E;
  --primary-light: #FF3399;
  --primary-dark: #CC0056;

  --secondary-color: #00F5FF;
  --secondary-light: #33F7FF;
  --secondary-dark: #00C0CC;

  --bg-color: #0F1419;
  --bg-secondary: #1a1f2e;
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0B0;

  --success-color: #10B981;
  --warning-color: #F59E0B;
  --danger-color: #EF4444;
  --info-color: #3B82F6;

  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  --border-radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 240px;
  --header-height: 73px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  letter-spacing: -0.02em;
  transition: var(--transition);
}

/* Typography */
h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.875rem;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.625rem;
}

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: #FFFFFF;
  border: 2px solid var(--primary-color);
  border-radius: var(--border-radius);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  user-select: none;
}

.btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  color: var(--bg-color);
}

.btn-secondary:hover {
  background-color: var(--secondary-light);
  border-color: var(--secondary-light);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: #FFFFFF;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* Form Elements */
input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 0, 110, 0.1);
}

input::placeholder {
  color: var(--text-secondary);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Cards */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.card-primary {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(255, 0, 110, 0.05) 0%, rgba(0, 245, 255, 0.05) 100%);
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Grid */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-1 {
  grid-template-columns: 1fr;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
}

/* Utility Classes */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-col {
  flex-direction: column;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.gap-3 {
  gap: 1.5rem;
}

.gap-4 {
  gap: 2rem;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}

.p-2 {
  padding: 1rem;
}

.p-3 {
  padding: 1.5rem;
}

.p-4 {
  padding: 2rem;
}

.text-center {
  text-align: center;
}

.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.5rem;
}

.font-bold {
  font-weight: 700;
}

.opacity-75 {
  opacity: 0.75;
}

.hidden {
  display: none;
}

/* Active Button States - Ensure readability across all themes */
.theme-btn.active {
  color: #FFFFFF !important;
  font-weight: 600;
}

/* Unit buttons - ensure white text when active */
.unit-btn.active,
.btn-secondary:hover {
  color: #FFFFFF !important;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

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

.slide-in {
  animation: slideIn 0.5s ease-out;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  background-color: var(--primary-color);
  color: white;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background-color: var(--success-color);
}

.badge-warning {
  background-color: var(--warning-color);
  color: var(--bg-color);
}

.badge-danger {
  background-color: var(--danger-color);
}

.badge-info {
  background-color: var(--info-color);
}

/* Divider */
.divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 1.5rem 0;
}

/* =====================
   Sidebar Navigation
   ===================== */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--bg-secondary);
  border-right: 2px solid var(--border-color);
  padding-top: var(--header-height);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 0.5rem 0.25rem;
  opacity: 0.5;
}

.sidebar-inner {
  padding: 1rem 0.75rem;
}

.sidebar-home {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
  margin-bottom: 0.75rem;
}

.sidebar-home:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--primary-color);
}

.sidebar-home.active {
  background-color: var(--primary-color);
  color: #fff;
}

.sidebar-category {
  margin-bottom: 1rem;
}

.sidebar-cat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem 0.3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  width: 100%;
}

.sidebar-link:hover:not(.disabled) {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--primary-color);
}

.sidebar-link.active {
  background-color: rgba(var(--primary-color-rgb, 255, 0, 110), 0.15);
  color: var(--primary-color);
  font-weight: 600;
}

.sidebar-link.disabled {
  opacity: 0.45;
  cursor: default;
}

.sidebar-link-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.sidebar-link-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-soon {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--border-color);
  color: var(--text-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Push main content to make room for fixed sidebar (desktop only) */
@media (min-width: 901px) {
  .main-content {
    margin-left: var(--sidebar-width);
  }
}

/* Tool pages: sidebar hidden by default, no margin needed */
body.tool-page-sidebar-hidden .main-content {
  margin-left: 0;
}

/* Overlay backdrop - sits below the header so header stays visible */
#sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
}

#sidebar-overlay.show {
  display: block;
}

/* Hamburger toggle button */
#sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: var(--transition);
}

#sidebar-toggle:hover {
  border-color: var(--primary-color);
}

#sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

/* Mobile / Tablet: collapse sidebar */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
    z-index: 200;
    padding-top: 0;
    box-shadow: none;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .main-content {
    margin-left: 0;
  }

  #sidebar-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  #sidebar {
    width: 280px;
  }
}

/* Tool Pages: hide sidebar by default on desktop */
body.tool-page-sidebar-hidden #sidebar {
  transform: translateX(-100%);
  box-shadow: none;
}

body.tool-page-sidebar-hidden .main-content {
  margin-left: 0;
}

/* Ensure toggle is visible on tool pages */
body.tool-page-sidebar-hidden #sidebar-toggle {
  display: flex;
}

/* Ensure sidebar appears when opened on tool pages (higher specificity) */
body.tool-page-sidebar-hidden #sidebar.open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  z-index: 200; /* Ensure open sidebar is always above the overlay */
}

/* =====================
   Tool Cards
   ===================== */

.tool-card-hidden {
  display: none;
}

/* =====================
   Tool Footer (page-specific)
   ===================== */

.tool-footer {
  background-color: var(--bg-secondary);
  border-top: 2px solid var(--border-color);
  padding: 1.5rem;
  margin-top: 3rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.tool-footer-content {
  max-width: 900px;
  margin: 0 auto;
}

.tool-footer a {
  color: var(--primary-color);
}

.tool-footer a:hover {
  text-decoration: underline;
}

/* =====================
   Site Footer (shared across all pages)
   ===================== */

.site-footer {
  background-color: var(--bg-secondary);
  border-top: 2px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.site-footer-content {
  max-width: 1200px;
  margin: 0 auto;
  color: var(--text-secondary);
}

.site-footer-nav {
  margin-bottom: 0.5rem;
}

.site-footer-nav a {
  margin: 0 1rem;
  color: var(--primary-color);
}

.site-footer-nav a:hover {
  text-decoration: underline;
}

.site-footer-copy {
  font-size: 0.8rem;
  margin: 0;
}

/* Logo icon (shared across all pages) */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  line-height: 0;
}

.logo-icon img {
  display: block;
}

.logo-compact .logo-icon img {
  width: 1.5em;
  height: 1.5em;
}

/* ===== Skip link (accessibility) =====
   Hidden until keyboard-focused; jumps to #main-content. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 0.75rem 1rem;
  background: var(--primary-color);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

/* ===== Related Tools widget =====
   Injected by related-tools.js into .main-content above the site footer. */
.related-tools {
  margin: 3rem 0 1rem 0;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.related-tools-heading {
  margin: 0 0 1.25rem 0;
  font-size: 1.25rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.related-tool-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

.related-tool-card:hover,
.related-tool-card:focus {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  outline: none;
}

.related-tool-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.related-tool-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.related-tool-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.related-tool-desc {
  color: var(--text-secondary);
  font-size: 0.825rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Sidebar theme picker =====
   Lives inside the hamburger sidebar; hidden on desktop, shown ≤600px where
   the header doesn't have room for the 5 theme circles. */
.sidebar-theme-block {
  display: none;
  padding: 0.75rem 1rem 1.25rem;
}

.sidebar-theme-block .sidebar-cat-label {
  margin-bottom: 0.5rem;
}

.sidebar-theme-block .theme-selector-compact {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.sidebar-theme-block .theme-circle {
  width: 32px;
  height: 32px;
}

@media (max-width: 600px) {
  .header #theme-container { display: none; }
  .sidebar-theme-block { display: block; }
}
