/* -------------------------------------------------------------------
   1. VARIABLES & RESET (Light Theme)
------------------------------------------------------------------- */
:root {
  /* Brand Colors - Indigo & Slate */
  --primary: #4f46e5; /* Indigo 600 */
  --primary-hover: #4338ca; /* Indigo 700 */
  --accent: #ec4899; /* Pink 500 (for subtle highlights) */

  /* Backgrounds */
  --bg-body: #f8fafc; /* Slate 50 */
  --bg-card: #ffffff; /* White */
  --bg-input: #ffffff;

  /* Text */
  --text-main: #0f172a; /* Slate 900 */
  --text-muted: #64748b; /* Slate 500 */
  --text-light: #94a3b8; /* Slate 400 */

  /* Borders & Shadows */
  --border: #e2e8f0; /* Slate 200 */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius: 0.75rem; /* 12px rounded corners */
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------------
   2. LAYOUT UTILITIES
------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container {
  flex: 1; /* Pushes footer down */
  padding-bottom: 3rem;
}

a {
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}
button {
  cursor: pointer;
  font-family: inherit;
  border: none;
}

/* -------------------------------------------------------------------
   3. HEADER
------------------------------------------------------------------- */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
}
.brand .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Nav */
.nav {
  display: flex;
  gap: 2rem;
}
.nav a {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.nav a:hover {
  color: var(--primary);
}

.mobile-nav-toggle {
  display: none;
  background: none;
  font-size: 1.5rem;
  color: var(--text-main);
}

/* -------------------------------------------------------------------
   4. HERO SECTION
------------------------------------------------------------------- */
.hero {
  background: linear-gradient(to bottom, #ffffff, #f1f5f9);
  padding: 4rem 0 3rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.hero-sub {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* Search Bar */
.search-box {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 50px; /* Pill shape */
  border: 2px solid var(--border);
  font-size: 1rem;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* -------------------------------------------------------------------
   5. HOME GRID & CARDS
------------------------------------------------------------------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.tools-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.25s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-icon {
  font-size: 2rem;
  background: #eff6ff;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}

.card-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.card-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* -------------------------------------------------------------------
   6. TOOL PAGE LAYOUT (Sidebar + Main)
------------------------------------------------------------------- */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2.5rem;
  align-items: start;
}

.tool-main {
  min-width: 0; /* Prevents overflow */
}

.tool-h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.tool-desc {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* The Panel where the tool lives */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

/* Sidebar Widgets */
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.sidebar-widget h4 {
  margin-bottom: 1rem;
  font-size: 1rem;
}
.sidebar-links {
  list-style: none;
}
.sidebar-links li {
  margin-bottom: 0.75rem;
}
.sidebar-links a {
  color: var(--primary);
  font-weight: 500;
}
.sidebar-links a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------------
   7. AUTO-STYLING GENERATED INPUTS (Magic CSS)
   This makes the plain HTML in your JSON look amazing
------------------------------------------------------------------- */
/* Labels */
.panel label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  margin-top: 1rem;
}
.panel label:first-child {
  margin-top: 0;
}

/* Inputs & Textareas */
.panel input[type="text"],
.panel input[type="number"],
.panel input[type="date"],
.panel input[type="email"],
.panel input[type="password"],
.panel select,
.panel textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.panel input:focus,
.panel textarea:focus,
.panel select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.panel textarea {
  min-height: 120px;
  resize: vertical;
}

/* File Inputs */
.panel input[type="file"] {
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

/* Buttons inside the tool panel */
.panel button {
  background-color: var(--primary);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  margin-top: 1.5rem;
  transition: background 0.2s;
  display: inline-block;
  width: auto;
}

.panel button:hover {
  background-color: var(--primary-hover);
}

/* Result Areas (h3, pre) */
.panel h3[id$="res"],
.panel h3[id$="out"] {
  background: #f0fdf4; /* Light Green */
  color: #166534; /* Dark Green */
  padding: 1rem;
  border-radius: 0.5rem;
  margin-top: 1.5rem;
  font-size: 1.1rem;
  border: 1px solid #bbf7d0;
  word-break: break-word;
}

.panel pre {
  background: #1e293b;
  color: #f8fafc;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* The .row class for buttons */
.panel .row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------------
   8. AD PLACEHOLDERS
------------------------------------------------------------------- */
.ad-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 0.5rem;
  overflow: hidden;
  margin: 0 auto;
}

.ad-label {
  font-size: 0.7rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Dimensions for Ad Slots */
.ad-leaderboard {
  min-height: 90px;
  width: 100%;
  max-width: 728px;
}
.ad-responsive {
  min-height: 250px;
  width: 100%;
}
.ad-vertical {
  min-height: 600px;
  width: 100%;
}
.ad-sticky-container {
  position: sticky;
  top: 90px;
}

/* -------------------------------------------------------------------
   9. FOOTER
------------------------------------------------------------------- */
.footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  margin-top: auto;
}

.footer-links {
  margin-bottom: 1rem;
}
.footer-links a {
  margin: 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.footer small {
  color: var(--text-light);
}

/* -------------------------------------------------------------------
   10. RESPONSIVE
------------------------------------------------------------------- */
@media (max-width: 768px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
  .tool-sidebar {
    display: none;
  } /* Hide sidebar on mobile to focus on tool */

  .nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  .nav.nav-open {
    display: flex;
  }

  .mobile-nav-toggle {
    display: block;
  }

  .hero-title {
    font-size: 1.8rem;
  }
}
