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

body {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f4f4f4; /* Main background from image */
  color: #333;
  line-height: 1.6;
}

/* Update .cat-label (Darker for contrast) */
.cat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: #555; /* Changed from #999 */
  letter-spacing: 1px;
  margin-bottom: 5px;
  font-weight: bold;
}

/* Add this NEW class (Replaces H3 in cards) */
.card-title {
  margin-bottom: 10px;
  color: #2c3e50;
  font-size: 18px;
  font-weight: bold;
  padding-right: 20px;
}

/* Update Footer links (Darker) */
#global-footer p {
  color: #444; /* Darker than before */
}
#global-footer a {
  color: #222;
  text-decoration: underline;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

/* Site Header Styling */
#inject-header {
  min-height: 85px; /* Reserves space to prevent Layout Shift */
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

.ad-slot-reserved {
  min-height: 100px; /* Forces the box to exist before the ad loads */
  background-color: #f9f9f9;
  display: block; /* Ensures it isn't hidden */
  width: 100%; /* Ensures it has width */
  margin: 20px 0;
  text-align: center;
  position: relative;
}

.ad-slot-reserved:empty {
  display: none;
}

.ad-slot-reserved::before {
  content: "Advertisement";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  padding: 0 8px;
  background-color: #f4f4f4;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 10;
}

.site-brand-link {
  text-decoration: none;
  color: #333;
  display: block; /* Makes the whole area clickable */
  padding: 20px 0;
}

.site-brand-name {
  font-size: 24px;
  font-weight: bold;
  display: block;
  line-height: 1.2;
}

.site-brand-tagline {
  font-size: 14px;
  color: #666;
  display: block;
  margin-top: 5px;
}

/* Ad Banners */
.ad-banner {
  background-color: #e9ecef;
  border: 1px solid #ccc;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  margin-top: 25px;
  color: #666;
}

h1 {
  margin-bottom: 20px;
  font-weight: normal;
  font-size: 24px;
}

/* Layout Wrapper (Grid) */
.content-wrapper {
  display: flex;
  gap: 20px;
  align-items: start;
}

/* Left Column - Calculator */
.calculator-card {
  flex: 2; /* Takes up 2/3rds space */
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Card Styling */
.card-header {
  background-color: var(--header-bg);
  padding: 10px 15px;
  font-weight: bold;
  border-bottom: 1px solid #ddd;
}

.card-body {
  padding: 20px;
}

/* Form Elements */
.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

input[type="number"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px;
}

.calculate-btn {
  width: 100%;
  padding: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  margin-top: 10px;
}

.calculate-btn:hover {
  background-color: var(--accent-color);
}

/* Result Box */
.result-box {
  margin-top: 25px;
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.result-header {
  background-color: #dbe2e8;
  padding: 8px 15px;
  font-weight: bold;
  font-size: 14px;
  border-bottom: 1px solid #ccc;
}

.result-content {
  padding: 15px;
}

.result-content p {
  margin-bottom: 5px;
  font-size: 14px;
}

/* Footer Styling */
#global-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid #ddd;
    color: #777;
    font-size: 14px;
}

#global-footer a {
  color: #555;
  text-decoration: none;
  margin: 0 5px;
}

#global-footer a:hover {
  text-decoration: underline;
  color: #000;
}

/* Buy Me a Coffee/Beer Link */
.bmac-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    background-color: #FFDD00;
    color: #000 !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.15s ease;
}

.bmac-link:hover {
    background-color: #ffce00;
    transform: scale(1.03);
    text-decoration: none !important;
}

/* SEO Content Styling */

.seo-separator {
  height: 1px;
  background-color: #ddd;
  margin: 40px 0;
}

.seo-content {
  color: #444;
}

.seo-content h2 {
  font-size: 20px;
  color: var(--primary-color); /* Uses the page-specific theme color */
  margin-bottom: 15px;
  border-left: 4px solid var(--accent-color);
  padding-left: 10px;
}

.seo-content h3 {
  font-size: 18px;
  color: #333;
  margin-top: 25px;
  margin-bottom: 10px;
}

.seo-content p {
  margin-bottom: 15px;
  font-size: 15px;
  line-height: 1.7;
}

.seo-content ul {
  margin-bottom: 20px;
  padding-left: 20px;
}

.seo-content li {
  margin-bottom: 8px;
  font-size: 15px;
}

/* Internal links inside content should stand out */
.seo-content a {
  color: var(--primary-color);
  text-decoration: underline;
  font-weight: 500;
}

.seo-content a:hover {
  color: var(--accent-color);
}

/* Ensure injected containers don't collapse if empty (prevents layout shift) */
#inject-ad-top,
#inject-ad-middle,
#inject-ad-bottom {
  min-height: 100px;
}

.breadcrumbs {
  font-size: 12px;
  margin-bottom: 15px;
  color: #666;
}

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

.breadcrumbs a:hover {
  text-decoration: underline;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding: 8px 0;
}

.result-row:last-child {
  border-bottom: none;
}

.copy-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  transition: background 0.2s;
}

.copy-btn:hover {
  background-color: #ddd;
}

/* =========================================
   CATEGORY SPECIFIC THEMES
   ========================================= */

/* --- HEALTH THEME OVERRIDES --- */
body.category-health {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; /* Softer font */
  background-color: #f0f8ff; /* Alice Blue background */
}

/* Rounder Cards */
body.category-health .calculator-card,
body.category-health aside,
body.category-health .result-box,
body.category-health input,
body.category-health .calculate-btn {
  border-radius: 12px; /* Much rounder */
}

/* Softer Inputs */
body.category-health input {
  background-color: #f9fcff;
  border: 1px solid #b3e5fc;
  padding: 12px; /* Bigger touch targets */
}

/* Softer Buttons */
body.category-health .calculate-btn {
  background-image: linear-gradient(
    to right,
    var(--primary-color),
    var(--accent-color)
  );
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

body.category-health .calculate-btn:hover {
  transform: translateY(-2px);
}

/* Result Box Styling for Health */
body.category-health .result-box {
  background-color: #e1f5fe;
  border: none;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

body.category-health .result-header {
  background: transparent;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

/* Sidebar Active Link Style for Health */
body.category-health .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #e1f5fe; /* Highlight background */
  border-radius: 0 8px 8px 0;
}

/* --- FINANCE THEME OVERRIDES (Optional, makes it look more 'Banking') --- */
body.category-finance {
  font-family: "Segoe UI", "Arial", serif; /* Trustworthy serif font for headers? */
}

body.category-finance h1,
body.category-finance .card-header,
body.category-finance .calculate-btn {
  font-family: "Segoe UI", "Arial", sans-serif; /* Keep UI elements sans-serif */
}

body.category-finance .calculator-card {
  border-top: 4px solid var(--primary-color); /* Professional accent line */
}

/* =========================================
   IMPROVED SIDEBAR STYLING
   ========================================= */

aside {
  flex: 1;
  background: #fff;
  border: 1px solid #e1e4e8; /* Softer border */
  border-radius: 8px; /* Matches your main card radius */
  padding: 25px; /* Adds breathing room inside the white box */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03); /* Very subtle lift */
  height: fit-content; /* Ensures it doesn't stretch weirdly */
}

/* Category Headers (Finance Tools / Health Tools) */
.sidebar-category-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #95a5a6;
  letter-spacing: 1.5px;
  margin-top: 35px; /* Significant space between sections */
  margin-bottom: 12px;
  border-bottom: 1px solid #f0f0f0; /* Subtle divider line */
  padding-bottom: 5px;
}

/* Remove margin from the very first title so it sits flush at top */
.sidebar-category-title:first-child {
  margin-top: 0;
}

/* The List Container */
.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Individual List Items */
.sidebar-list li {
  margin-bottom: 4px;
}

/* The Links */
.sidebar-list a {
  display: flex; /* Aligns text and badge nicely */
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem; /* Bigger clickable area */
  text-decoration: none;
  color: #555;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.2s ease;
  border-left: 3px solid transparent; /* Placeholder for hover effect */
}

/* Hover State */
.sidebar-list a:hover {
  background-color: #f8f9fa;
  color: #333;
  padding-left: 16px; /* Subtle "nudge" animation */
}

/* Active Page State */
.sidebar-list a.active-link {
  background-color: var(--header-bg); /* Uses the page-specific theme color! */
  color: var(--primary-color); /* Uses the page-specific text color! */
  font-weight: 600;
  border-left: 3px solid var(--primary-color);
  cursor: default;
}

/* Remove the hover nudge for the active link */
.sidebar-list a.active-link:hover {
  padding-left: 12px;
}

/* Popular Badge */
.badge {
  font-size: 0.75rem;
  opacity: 0.5;
  text-transform: lowercase;
}

/* --- MATH THEME OVERRIDES --- */
body.category-math {
  font-family: "Verdana", sans-serif;
}

body.category-math .calculator-card {
  border-top: 4px solid var(--primary-color);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

body.category-math .calculate-btn {
  background-color: var(--primary-color);
  border-radius: 4px; /* Slightly squarer buttons for math */
}

body.category-math .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #f3e5f5;
  color: var(--accent-color);
}

/* --- SEARCH & FILTER CONTROLS --- */
.controls-wrapper {
  margin-bottom: 30px;
}

/* Row 1: Search */
.search-container {
  margin-bottom: 15px;
}

.search-input {
  width: 100%;
  padding: 12px 15px;
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background-color: #fff;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: #333;
  outline: none;
}

/* Row 2: Filters & Sort */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: space-between;
  align-items: center;
}

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  background: #fff;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: #f4f4f4;
  border-color: #bbb;
}

.filter-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

.sort-container select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-size: 13px;
  color: #555;
  background: #fff;
  cursor: pointer;
}

/* --- FAVORITES SECTION --- */
.favorites-section {
  display: none; /* Hidden by default */
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px dashed #ddd;
}

.favorites-header {
  font-size: 18px;
  font-weight: bold;
  color: #444; /* Orange star color */
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- UPDATED CARD STYLES --- */
.grid-card {
  position: relative; /* Needed for absolute star positioning */
}

/* The Star Button */
.star-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 18px;
  color: #ccc; /* Default grey */
  cursor: pointer;
  z-index: 2;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
  padding: 5px;
}

.star-btn:hover {
  transform: scale(1.2);
  color: #999;
}

/* State: Card is Favorited */
.grid-card.is-favorite .star-btn {
  color: #ff9800; /* Orange */
}

.grid-card.is-favorite {
  border-color: #ffcc80;
  background: #fffbf5;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: #777;
  background: #f9f9f9;
  border-radius: 8px;
  display: none;
}

/* --- TIME THEME OVERRIDES --- */
body.category-time {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background-color: #e8eaf6; /* Indigo Tint */
}

body.category-time .calculator-card {
  border-top: 4px solid var(--primary-color);
}

body.category-time .result-box {
  background-color: #fff;
  border: 1px solid #c5cae9;
}

body.category-time .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #e8eaf6;
  color: var(--accent-color);
}

/* --- CONSTRUCTION THEME OVERRIDES --- */
body.category-construction {
  font-family: "Roboto", "Arial", sans-serif; /* Strong, industrial font */
  background-color: #eceff1; /* Concrete Grey */
}

body.category-construction .calculator-card {
  border-top: 4px solid var(--primary-color);
}

/* Make tabs match theme */
body.category-construction .mode-tabs input:checked + span {
  color: var(--primary-color);
  font-weight: 800;
}

body.category-construction .calculate-btn {
  background-color: #37474f; /* Dark Grey Button */
  color: #fff;
}
body.category-construction .calculate-btn:hover {
  background-color: var(--primary-color); /* Orange on hover */
}

/* Sidebar Active State */
body.category-construction .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #cfd8dc;
  color: #000;
}

/* --- EDUCATION THEME OVERRIDES --- */
body.category-education {
  background-color: #e0f2f1;
}

body.category-education .calculator-card {
  border-top: 4px solid var(--primary-color);
}

body.category-education .calculate-btn {
  border-radius: 20px; /* Chalkboard eraser shape? */
  background-color: #00897b;
}

body.category-education .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #b2dfdb;
  color: #004d40;
}

/* --- TRAVEL THEME OVERRIDES --- */
body.category-travel {
  font-family: "Verdana", sans-serif;
  background-color: #eceff1;
}

body.category-travel .calculator-card {
  border-top: 4px solid var(--primary-color);
}

body.category-travel .calculate-btn {
  background-color: #455a64;
}

body.category-travel .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #cfd8dc;
  color: #263238;
}

/* --- LIFESTYLE THEME OVERRIDES --- */
body.category-lifestyle {
  font-family: "Comic Sans MS", "Chalkboard SE", sans-serif; /* Friendly/Casual font */
  font-family: "Segoe UI", sans-serif; /* Fallback to standard if Comic Sans is too much */
  background-color: #fff8e1; /* Very light orange/yellow */
}

body.category-lifestyle .calculator-card {
  border-top: 4px solid var(--primary-color);
}

body.category-lifestyle .calculate-btn {
  background-color: #ff6f00; /* Amber */
  border-radius: 50px; /* Pill shape */
}

body.category-lifestyle .sidebar-list a.active-link {
  border-left: 4px solid var(--primary-color);
  background-color: #ffe0b2;
  color: #e65100;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .content-wrapper {
    flex-direction: column;
  }

  .calculator-card,
  aside {
    width: 100%;
  }
}

.sort-container {
  display: none;
}
