/* --- Base and Variables --- */
:root {
  --primary-color: #0056b3; /* A richer blue */
  --secondary-color: #00796b; /* Teal for accents or alternative primary */
  --accent-color: #ff8c00; /* Dark orange for call to actions or highlights */
  --light-gray: #f8f9fa;
  --medium-gray: #e9ecef;
  --dark-gray: #343a40;
  --text-color: #212529;
  --bs-primary-rgb: 0, 86, 179; /* For Bootstrap components that use RGB */
}

body {
  padding-top: 70px; /* Adjusted for slightly taller navbar if needed */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f4f7f6; /* Softer background */
  color: var(--text-color);
  transition: background-color 0.3s ease;
}

main {
  flex: 1;
}

/* --- Navbar --- */
/* --- Navbar --- */
.navbar {
  /* Using the primary color for the navbar background */
  background-color: var(--primary-color) !important; 
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15); /* Slightly adjusted shadow for depth */
  padding-top: 0.75rem; /* Adjusted padding */
  padding-bottom: 0.75rem;
}

.navbar-brand {
  font-weight: bold;
  color: #ffffff !important; /* Bright white for the brand against the blue */
  font-size: 1.3rem; /* Slightly larger brand text */
  transition: color 0.2s ease-in-out;
}
.navbar-brand:hover {
  color: var(--accent-color) !important; /* Accent color on hover for brand */
}
.navbar-brand i {
  margin-right: 0.5rem; /* Increased icon margin */
  color: var(--accent-color); /* Icon in accent color */
  font-size: 1.5rem; /* Larger icon */
  vertical-align: middle;
}

/* Styling for navbar links (Bootstrap's .navbar-dark handles initial light color) */
.navbar-dark .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85) !important; /* Brighter default link color */
  font-weight: 500;
  padding-left: 1rem;
  padding-right: 1rem;
  border-radius: 4px; /* Subtle rounding for hover effect */
  transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link.active {
  color: #ffffff !important; /* White text on hover/active */
  background-color: var(--secondary-color) !important; /* Teal background on hover/active for contrast */
  /* Or use a slightly lighter/darker shade of primary: background-color: #004a99 !important; */
}

/* Navbar toggler icon styling (Bootstrap .navbar-dark handles the icon color) */
.navbar-dark .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.25); /* Lighter border for toggler */
}

/* --- Hero Section --- */
.hero-section {
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  color: white;
  padding-top: 4rem;
  padding-bottom: 3rem;
  text-align: center;
  margin-bottom: 2rem; /* Space before first converter */
}

.hero-section h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.hero-section .lead {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}
.hero-section p:not(.lead) {
  font-size: 1rem;
  opacity: 0.8;
}


/* --- Converter Sections & Cards --- */
.converter-section {
  margin-bottom: 2.5rem; /* Increased space between converter cards */
  padding-top: 70px; 
  margin-top: -70px; /* Adjusted to match padding-top for anchor accuracy */
}

.card {
  border: none; /* Remove default border */
  border-left: 5px solid var(--primary-color); /* Accent border */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-radius: 8px; /* Slightly more rounded corners */
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.card-header {
  background-color: var(--light-gray); /* Light background for header */
  border-bottom: 1px solid var(--medium-gray);
  padding: 1rem 1.25rem;
  border-top-left-radius: 0; /* Align with accent border */
  border-top-right-radius: 8px;
}

.card-title-custom { /* Styling for H2 within card-header */
  font-size: 1.75rem;
  color: var(--primary-color);
  font-weight: 600;
}

.card-header p.text-muted {
  font-size: 0.9rem !important;
}

.card-body {
  padding: 1.5rem; /* More padding in card body */
}

/* Form elements */
.form-label {
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: #333;
}

.form-control, .form-select {
  border-radius: 0.25rem;
  border: 1px solid #ced4da;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover {
  background-color: #004080; /* Darken primary color */
  border-color: #003366;
  transform: translateY(-1px);
}
.btn-primary:active {
   transform: translateY(0px);
}

/* --- Result and Formula Display --- */
.result-display {
  font-size: 1.25rem; /* Slightly larger */
  font-weight: bold;
  color: var(--secondary-color); /* Teal for results */
  background-color: var(--medium-gray);
  padding: 0.75rem 1rem; /* More padding */
  border-radius: 0.3rem;
  min-height: 2.5em;
  animation: fadeInResult 0.5s ease-out; /* Fade in animation */
  word-wrap: break-word;
}
.result-display strong {
  color: var(--dark-gray); /* Differentiate "Result:" text */
}


@keyframes fadeInResult {
  from {
      opacity: 0;
      transform: translateY(10px);
  }
  to {
      opacity: 1;
      transform: translateY(0);
  }
}

.formula-display {
  font-size: 0.9rem; /* Slightly larger */
  color: #555; /* Darker muted color */
  margin-top: 0.5rem;
  word-wrap: break-word;
  background-color: #fafafa;
  padding: 0.5rem;
  border-radius: 0.25rem;
  border: 1px dashed #ddd;
}
.formula-display em {
  font-style: normal;
}


/* --- Disclaimer --- */
.disclaimer {
  font-size: 0.75rem; /* Kept small */
  color: #777;
  margin-top: 1.25rem;
  border-top: 1px solid #e0e0e0;
  padding-top: 0.75rem;
}

/* --- Ad Placeholders --- */
.ad-placeholder {
  min-height: 90px;
  border: 2px dashed var(--medium-gray); /* Softer dashed border */
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--light-gray);
  margin: 2.5rem auto; /* More margin */
  border-radius: 4px;
}

.ad-placeholder p {
  color: #888;
  margin: 0;
  font-style: italic;
}

/* --- Footer --- */
footer {
  background-color: var(--dark-gray); /* Consistent with navbar */
  color: #ccc;
  padding-top: 2rem;
  padding-bottom: 1rem; /* Adjusted padding */
  margin-top: 3rem; /* Ensure space from last content */
}
footer p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
footer a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s ease;
}
footer a:hover {
  color: #fff;
  text-decoration: underline;
}


/* --- Utility & Scroll --- */
html {
  scroll-padding-top: 70px; /* Match body padding-top */
  scroll-behavior: smooth;
}

/* Ensure select dropdowns in forms take full available width in their column */
.form-select, .form-control {
  width: 100%;
}

/* Style for h5 in drilling fluids card */
.card-body h5.card-title {
  color: var(--primary-color);
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--medium-gray);
}
.card-body h5.card-title:first-of-type {
  margin-top: 0; /* Remove top margin for the first h5 */
}