/* --- Modern CSS Resets & Variables --- */
:root {
  /* Softer, modern gradient background */
  --bg: #f8fafc;
  --card-bg: #ffffff;
  
  /* Text Hierarchy */
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  /* Brand Colors */
  --primary: #3b82f6;      
  --primary-hover: #2563eb;
  --accent: #0ea5e9;
  
  /* Modern UI Elements */
  --border: #e2e8f0;
  --card-border: #f1f5f9;
  --ring: rgba(59, 130, 246, 0.5);
  
  /* Layered, subtle shadows (Apple/Stripe style) */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --border: #334155;
  --card-border: #334155;
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.4);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* --- Hero & Search --- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 3rem;
  padding: 3rem 0 1rem;
}

.hero h1 { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 0.5rem; }
.hero p { color: var(--text-muted); font-size: 1.125rem; max-width: 600px; }

.search-container {
  margin-top: 2rem;
  position: relative;
  width: 100%;
  max-width: 480px;
}

.search-container i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.25rem;
}

.search-container input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border-radius: 9999px; /* Pill shape */
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.search-container input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* --- Navigation Pills --- */
.nav-pills {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 3rem;
}

.nav-pills a {
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.nav-pills a:hover, .nav-pills a.active {
  background: var(--text-main);
  color: var(--card-bg);
  border-color: var(--text-main);
}

/* --- Sections & Cards --- */
.tool-section { margin-bottom: 4rem; scroll-margin-top: 2rem; }

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-header i { font-size: 1.75rem; color: var(--primary); }
.section-header h2 { font-size: 1.5rem; font-weight: 600; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

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

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
  transition: background 0.3s ease;
}

[data-theme="dark"] .card-icon { background: rgba(59, 130, 246, 0.1); }

.card:hover .card-icon {
  background: var(--primary);
  color: white;
}

.card h4 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.card p { color: var(--text-muted); font-size: 0.95rem; flex-grow: 1; }

/* --- Tool Sub-Page Specific Styles --- */

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 2rem;
  transition: color 0.2s ease;
}

.breadcrumb:hover { color: var(--primary); }

.tool-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.tool-header .card-icon { margin-bottom: 0; }
.tool-header h1 { margin-bottom: 0.25rem; font-size: 2rem; }
.tool-header p { margin-bottom: 0; }

/* The side-by-side workspace */
.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  height: calc(100vh - 250px);
  min-height: 500px;
}

@media (min-width: 768px) {
  .workspace { grid-template-columns: 1fr 1fr; }
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.panel-header h3 { font-size: 1rem; margin: 0; font-weight: 600; color: var(--text-muted); }
.panel-actions { display: flex; gap: 0.5rem; }

/* Refined Inputs and Outputs */
textarea {
  flex-grow: 1;
  width: 100%;
  border: none;
  padding: 1.25rem;
  font-family: 'Fira Code', monospace; /* Good for coding tools */
  font-size: 0.9rem;
  resize: none;
  background: var(--card-bg);
  color: var(--text-main);
}

textarea:focus { outline: none; }

pre {
  flex-grow: 1;
  margin: 0;
  padding: 1.25rem;
  background: var(--card-bg);
  border: none;
  border-radius: 0;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  color: var(--text-main);
  overflow-y: auto;
}

.error-text { color: #ef4444 !important; background: #fef2f2 !important; }
[data-theme="dark"] .error-text { background: rgba(239, 68, 68, 0.1) !important; }

/* Modern Buttons */
button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

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

.success-state { color: #10b981; border-color: #10b981; }

/* Form Layouts for Workspace Panels */
.panel-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; flex-grow: 1; background: var(--card-bg); }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.checkbox-group { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: var(--text-main); font-size: 0.9rem;}
.checkbox-group input[type="checkbox"] { width: auto; transform: scale(1.2); cursor: pointer; }
.result-display { display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: var(--primary); text-align: center; height: 100%; }
canvas { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-top: 1rem; }

/* --- Home Page Upgrades --- */
.hero-nav { display: flex; justify-content: flex-end; width: 100%; max-width: 1200px; padding: 1rem 2rem 0; margin: 0 auto; }
.btn-coffee { display: inline-flex; align-items: center; gap: 0.5rem; background: #FFDD00; color: #000000; font-weight: 600; padding: 0.5rem 1rem; border-radius: 99px; text-decoration: none; font-size: 0.9rem; transition: transform 0.2s; }
.btn-coffee:hover { transform: scale(1.05); }

.features-banner { display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem; margin: 2rem 0 3rem; padding: 1.5rem; background: var(--card-bg); border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.feature-item { display: flex; align-items: center; gap: 0.75rem; color: var(--text-main); }
.feature-item i { font-size: 2rem; color: var(--primary); padding: 0.5rem; background: rgba(59, 130, 246, 0.1); border-radius: 12px; }
.feature-item div { display: flex; flex-direction: column; text-align: left; }
.feature-item strong { font-size: 1rem; }
.feature-item span { font-size: 0.85rem; color: var(--text-muted); }

/* Clean Ad Placeholder */
.ad-container { display: flex; justify-content: center; margin-bottom: 3rem; }
.ad-box { display: flex; align-items: center; gap: 1rem; background: var(--card-bg); border: 1px solid var(--border); padding: 0.75rem 1rem; border-radius: 8px; max-width: 400px; text-decoration: none; color: var(--text-main); transition: border-color 0.2s; position: relative; }
.ad-box:hover { border-color: var(--text-muted); }
.ad-label { position: absolute; top: -10px; left: 10px; background: var(--bg); font-size: 0.7rem; padding: 0 0.4rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.ad-img { width: 40px; height: 40px; background: var(--border); border-radius: 4px; }
.ad-text { font-size: 0.85rem; line-height: 1.4; }
.ad-text strong { display: block; color: var(--primary); }

/* --- Global Ad Styles --- */
.ad-container { display: flex; justify-content: center; width: 100%; }
.ad-box {
  display: flex; align-items: center; gap: 1rem;
  background: var(--card-bg); border: 1px solid var(--border);
  padding: 0.75rem 1rem; border-radius: 8px;
  text-decoration: none; color: var(--text-main);
  transition: all 0.2s ease; position: relative;
  box-shadow: var(--shadow-sm);
}
.ad-box:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ad-label {
  position: absolute; top: -10px; left: 10px;
  background: var(--bg); font-size: 0.65rem; padding: 0 0.5rem;
  color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  border-radius: 4px;
}
.ad-img { width: 44px; height: 44px; border-radius: 6px; flex-shrink: 0; }
.ad-text { font-size: 0.85rem; line-height: 1.4; display: flex; flex-direction: column; }
.ad-text strong { color: var(--text-main); font-size: 0.95rem; }
.ad-text span { color: var(--text-muted); }

/* Dark mode tweaks for ads */
[data-theme="dark"] .ad-box { background: var(--card-bg); }
[data-theme="dark"] .ad-img { background-color: #334155 !important; }
