:root {
  --background-color: #f0f0f0;
  --container-background: #fff;
  --text-color: #333;
  --secondary-text-color: #666;
  --border-color: #ccc;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --dropdown-background: #f9f9f9;
  --dropdown-hover-background: #e2e6ea;
  --result-background: #f8f9fa;
  --result-border: #e9ecef;
  --button-background: #007bff;
  --button-hover-background: #0056b3;
  --toggle-button-background: #6c757d;
  --toggle-button-hover-background: #5a6268;
  --focus-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
  --lotto-number-bg: #e0e0e0;
  --lotto-number-color: #333;
  --lotto-bonus-color: #dc3545;
}

.dark { /* Changed from .dark-mode */
  --background-color: #282c34;
  --container-background: #3c414d;
  --text-color: #e0e0e0;
  --secondary-text-color: #a0a0a0;
  --border-color: #555;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --dropdown-background: #4a4e5a;
  --dropdown-hover-background: #5d6270;
  --result-background: #333742;
  --result-border: #444a57;
  --button-background: #61afef;
  --button-hover-background: #4a90d2;
  --toggle-button-background: #a9a9a9; /* Lighter toggle button in dark mode */
  --toggle-button-hover-background: #888888;
  --focus-shadow: 0 0 0 0.2rem rgba(97,175,239,.25);
  --lotto-number-bg: #555;
  --lotto-number-color: #eee;
  --lotto-bonus-color: #ef939c;
}

body {
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  align-items: center; /* Align to center vertically */
  min-height: 100vh;
  background-color: var(--background-color);
  margin: 0;
  /* Removed padding-top and padding-bottom from body */
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  text-align: center;
  background-color: var(--container-background);
  padding: 2em; /* Keep padding for internal content */
  border-radius: 10px;
  box-shadow: 0 0 10px var(--shadow-color);
  width: 90%; /* Wider container */
  max-width: 1000px; /* Max width for larger screens */
  box-sizing: border-box; /* Include padding and border in the element's total width and height */
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  margin: auto; /* Ensures horizontal centering within the flex parent */
}

header {
  position: relative; /* Add position relative to header for absolute positioning of child elements */
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 0.5em;
  color: var(--text-color);
}

header p {
  font-size: 1.2em;
  color: var(--secondary-text-color);
  margin-bottom: 2em;
}

/* Dropdown Menu Styles */
.dropdown {
  position: relative;
  display: inline-block;
  margin-bottom: 2em;
}

.dropbtn {
  background-color: var(--button-background); /* Use general button background */
  color: white;
  padding: 16px 24px;
  font-size: 16px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s ease;
  box-shadow: 0 2px 4px var(--shadow-color); /* Added shadow */
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: var(--dropdown-background);
  min-width: 250px; /* Increased width for more content */
  box-shadow: 0px 8px 16px 0px var(--shadow-color);
  z-index: 1;
  border-radius: 5px;
  padding: 1em;
  text-align: left;
  left: 50%; /* Center dropdown */
  transform: translateX(-50%); /* Center dropdown */
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.dropdown-category {
  margin-bottom: 1em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border-color);
}

.dropdown-category:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.dropdown-category h3 {
  margin-top: 0;
  font-size: 1.1em;
  color: var(--text-color);
  padding-bottom: 0.5em;
  margin-bottom: 0.5em;
}

.dropdown-content a {
  color: var(--text-color);
  padding: 8px 16px;
  text-decoration: none;
  display: block;
  transition: background-color 0.2s ease;
  border-radius: 3px;
}

.dropdown-content a:hover {background-color: var(--dropdown-hover-background);}

.dropdown:hover .dropdown-content {display: block;}

.dropdown:hover .dropbtn {background-color: var(--button-hover-background);}


/* General Tool Page Styles */
main {
  margin-top: 2em;
  margin-bottom: 2em;
}

textarea, input[type="number"], select {
  width: calc(100% - 20px); /* Full width minus padding */
  padding: 10px;
  margin-bottom: 1em;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 1em;
  box-sizing: border-box; /* Include padding in width */
  background-color: var(--container-background);
  color: var(--text-color);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

textarea:focus, input[type="number"]:focus, select:focus {
  border-color: var(--button-background);
  box-shadow: var(--focus-shadow);
  outline: none;
}

button {
  background-color: var(--button-background); /* Use general button background */
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1em;
  margin: 0.5em 0.5em;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 4px var(--shadow-color); /* Added shadow */
}

button:hover {
  background-color: var(--button-hover-background); /* Use general button hover background */
}

/* Theme Toggle Container */
.theme-toggle-container {
  position: fixed;
  top: 1em;
  right: 1em;
  z-index: 1000; /* Ensure it's above other content */
}

/* Theme Toggle Button Specific Style (now generic for all buttons, but overridden for the toggle) */
#theme-toggle {
  background-color: var(--toggle-button-background);
  color: white;
  padding: 0.8em 1.5em;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1em;
  transition: background-color 0.3s ease;
  box-shadow: 0 2px 4px var(--shadow-color);
}

#theme-toggle:hover {
  background-color: var(--toggle-button-hover-background);
}


#result {
  margin-top: 2em;
  padding: 1.5em;
  border: 1px solid var(--result-border);
  border-radius: 8px;
  background-color: var(--result-background);
  min-height: 50px;
  text-align: left;
  word-wrap: break-word; /* Ensure long words wraps */
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

#result p {
  margin: 0.5em 0;
  color: var(--text-color);
}

#result span {
  font-weight: bold;
  color: var(--button-background); /* Keep a contrasting color for emphasis */
}

/* Lotto Generator Specific Styles */
.lotto-set {
  display: flex; /* Use flexbox for horizontal arrangement */
  justify-content: center;
  align-items: center;
  margin: 1em 0;
  font-size: 1.2em;
  font-weight: bold;
}

.lotto-ball {
  display: inline-flex; /* Use inline-flex for circular items */
  justify-content: center;
  align-items: center;
  background-color: var(--lotto-number-bg);
  color: var(--lotto-number-color);
  border-radius: 50%;
  width: 40px; /* Slightly larger balls */
  height: 40px;
  font-size: 1.1em;
  margin: 0 0.3em;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.lotto-set .bonus-ball {
  background-color: var(--lotto-bonus-color);
  color: white;
}

.lotto-set p {
  display: flex;
  align-items: center;
  margin: 0;
}

.lotto-set p span {
  margin: 0 0.5em; /* Spacing for the '+' sign */
}

/* Back to Main Button Style */
.back-to-main-button {
  position: absolute;
  top: 1em;
  left: 1em;
  background-color: var(--toggle-button-background);
  color: white;
  padding: 0.5em 1em;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.back-to-main-button:hover {
  background-color: var(--toggle-button-hover-background);
}



/* Radio button group styling for VAT Calculator */
.radio-group {
  margin-bottom: 1em;
}

.radio-group input[type="radio"] {
  width: auto; /* Override full width for radio buttons */
  margin-right: 0.5em;
  margin-left: 1em;
}

.radio-group label {
  margin-right: 1em;
  color: var(--secondary-text-color);
}

footer {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border-color);
  color: var(--secondary-text-color);
  font-size: 0.9em;
  transition: border-top 0.3s ease, color 0.3s ease;
}

/* Tool Grid and Card Styles */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5em;
  margin-top: 2em;
}

.tool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5em;
  background-color: var(--container-background);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--shadow-color);
  text-decoration: none;
  color: var(--text-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  min-height: 150px; /* Ensure cards have a minimum height */
}

.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px var(--shadow-color);
  background-color: var(--dropdown-hover-background);
}

.tool-card h3 {
  font-size: 1.5em;
  margin-top: 0;
  margin-bottom: 0.5em;
  color: var(--text-color);
}

.tool-card p {
  font-size: 0.9em;
  color: var(--secondary-text-color);
  margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    width: 95%;
    padding: 1em;
  }

  header h1 {
    font-size: 2em;
  }

  header p {
    font-size: 1em;
  }

  /* Adjustments for tool-grid on small screens */
  .tool-grid {
    grid-template-columns: 1fr; /* Single column on small screens */
    gap: 1em;
  }

  .tool-card {
    padding: 1em;
    min-height: 120px;
  }

  .tool-card h3 {
    font-size: 1.2em;
  }

  .tool-card p {
    font-size: 0.8em;
  }

  textarea, input[type="number"], select, button {
    font-size: 0.9em;
    padding: 8px;
  }
}

