/* Root Variables */
:root {
  --background-color: #fafafa;
  --text-color: #222222;
  --header-footer-bg: #ffffff;
  --header-footer-text: #222222;
  --tab-bar-bg: #ffffff;
  --tab-text: #555555;
  --active-tab-text: #c9a227; /* Royal Gold */
  --container-bg: #ffffff;
  --container-shadow: rgba(0, 0, 0, 0.1);
  --metal-rates-bg: #f4f4f4;
  --metal-type-border: #dddddd;
  --metal-type-bg: #ffffff;
  --metal-type-shadow: rgba(0, 0, 0, 0.05);
  --metal-rates-text: #c9a227;
  --contact-info-text: #222222;
  --link-color: #2980b9;
  --last-updated-text: #888888;
  --content-bg-light: #ffffff;
  --content-text-dark: #333333;
}

html {
  scroll-behavior: smooth;
}

/* Dark Mode Styles */
body.dark-mode {
  --background-color: #121212; /* Rich dark background */
  --text-color: #e0e0e0; /* Softer off-white */
  --header-footer-bg: #1e1e1e;
  --header-footer-text: #e0e0e0;
  --tab-bar-bg: #1e1e1e;
  --tab-text: #cccccc;
  --active-tab-text: #e6b800; /* Golden for dark mode */
  --container-bg: #1e1e1e;
  --container-shadow: rgba(0, 0, 0, 0.4);
  --metal-rates-bg: #1a1a1a;
  --metal-type-border: #333333;
  --metal-type-bg: #1a1a1a;
  --metal-type-shadow: rgba(0, 0, 0, 0.3);
  --metal-rates-text: #e6b800;
  --contact-info-text: #e0e0e0;
  --link-color: #4fc3f7; /* Lighter blue for dark mode */
  --last-updated-text: #aaaaaa;
  --dialog-bg-light: rgba(30, 30, 30, 0.9);
  --content-bg-light: #1e1e1e;
  --content-text-dark: #e0e0e0;
}

/* General Styles */
body {
  font-family: 'Roboto', Arial, sans-serif; /* Modern, clean font */
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* Header */
header {
  background-color: var(--header-footer-bg);
  padding: 20px 30px; /* Large padding for desktop */
  position: fixed;
  top: 0;
  width: 100%;
  box-sizing: border-box; /* Ensure padding doesn't increase width */
  z-index: 1000;
  box-shadow: 0 2px 4px var(--container-shadow);
  display: flex;
  justify-content: flex-start; /* Align content to the left */
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center; /* Vertically align items */
  justify-content: space-between; /* Logo and text left, buttons right */
  gap: 12px; /* Larger gap for desktop */
  max-width: 100%; /* Prevent overflow */
  flex-wrap: nowrap; /* Keep items in one line */
  width: 100%; /* Ensure container spans header */
}

.company-logo {
  height: 60px; /* Default for external CSS, overridden by inline CSS */
  width: auto; /* Maintain aspect ratio */
  object-fit: contain; /* Ensure image scales properly */
}

.company-title {
  font-size: 2.2rem; /* Increased font size for desktop */
  color: var(--active-tab-text); /* Golden color */
  font-weight: bold;
  line-height: 40px; /* Match logo height for vertical alignment */
  white-space: nowrap; /* Prevent text wrapping */
}

.header-buttons {
  display: flex;
  align-items: center; /* Vertically align buttons */
  gap: 10px; /* Larger gap for desktop */
  margin-left: auto; /* Push buttons to the right */
}

.header-button {
  font-size: 1.5rem; /* Large font size for desktop */
  color: var(--header-footer-text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 5px;
  transition: background-color 0.3s, color 0.3s;
  line-height: 40px; /* Match logo height for vertical alignment */
}

.header-button:hover,
.header-button:focus {
  background-color: var(--metal-rates-bg);
  color: var(--active-tab-text);
}

/* Navigation */
.fixed-nav {
  background-color: var(--tab-bar-bg);
  padding: 10px 15px;
  position: fixed;
  top: 100px; /* Adjusted for larger header */
  width: 100%;
  box-sizing: border-box;
  z-index: 900;
  box-shadow: 0 2px 4px var(--container-shadow);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: var(--tab-text);
  text-decoration: none;
  font-size: 1.1rem;
  padding: 8px 16px;
  border-radius: 5px;
  transition: background-color 0.3s, color 0.3s;
}

.nav-link:hover,
.nav-link:focus {
  background-color: var(--metal-rates-bg);
  color: var(--active-tab-text);
}

/* Video Container */
.video-container {
  width: 90%;
  max-width: 800px; /* Larger max-width for better visibility */
  margin: 160px auto 30px; /* Adjusted for larger header */
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

video {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

/* Rates Section */
#rates-section {
  max-width: 1200px;
  margin: 20px auto;
  padding: 20px;
  background-color: var(--container-bg);
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--container-shadow);
}

#rates-section h2 {
  font-size: 2rem;
  color: var(--metal-rates-text);
  text-align: center;
  margin-bottom: 20px;
}

.metal-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Smaller min width */
  gap: 15px; /* Reduced gap */
  margin: 15px 0; /* Reduced margin */
}

.metal-type {
  text-align: center;
  border: 1px solid var(--metal-type-border);
  border-radius: 8px;
  background-color: var(--metal-type-bg);
  padding: 8px; /* Reduced padding */
  transition: transform 0.3s;
  min-width: 120px; /* Smaller minimum width */
}

.metal-type:hover {
  transform: translateY(-5px);
}

.metal-type h3 {
  font-size: 1.2rem; /* Smaller font size */
  margin-bottom: 8px;
  color: var(--text-color);
}

.metal-type p {
  font-size: 1.5rem; /* Smaller font size for rates */
  color: var(--metal-rates-text);
  font-weight: bold;
  margin: 5px 0; /* Reduced margin */
}

.rate {
  font-size: 0.9rem; /* Smaller font size for 'per gm' */
  color: var(--text-color);
}

.last-updated {
  font-size: 1rem;
  color: var(--last-updated-text);
  text-align: center;
  margin-top: 20px;
}

/* Contact Section */
#contact-section {
  max-width: 1200px;
  margin: 20px auto;
  padding: 20px;
  background-color: var(--container-bg);
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--container-shadow);
}

.contact-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: center;
}

.map-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.map-container iframe {
  width: 100%;
  height: 300px;
  border-radius: 10px;
  box-shadow: 0 2px 4px var(--container-shadow);
}

.contact-info p {
  font-size: 1.2rem;
  color: var(--contact-info-text);
}

.contact-info strong {
  font-size: 1.3rem;
}

.contact-info a {
  color: var(--link-color);
  text-decoration: none;
}

.contact-info a:hover,
.contact-info a:focus {
  text-decoration: underline;
}

.social-links img {
  width: 40px;
  height: 40px;
  margin: 0 10px;
  transition: transform 0.3s;
}

.social-links img:hover {
  transform: scale(1.1);
}

/* Flashing Animation */
.flashing {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Tab Bar */
.tab-bar {
  background-color: var(--tab-bar-bg);
  padding: 10px 0;
  display: flex;
  justify-content: center;
  gap: 20px;
  position: fixed;
  bottom: 0;
  width: 100%;
  box-shadow: 0 -2px 4px var(--container-shadow);
}

.tab {
  padding: 10px 20px;
  color: var(--tab-text);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.3s;
}

.tab.active {
  color: var(--active-tab-text);
  border-bottom: 2px solid var(--active-tab-text);
}

.tab img {
  width: 30px;
  height: 30px;
}

/* Buttons */
.button {
  background-color: var(--metal-rates-text);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 1.1rem;
  transition: background-color 0.3s, transform 0.3s;
}

.button:hover {
  background-color: #cc9f00; /* Darker gold */
  transform: translateY(-2px);
}

/* Switch Toggle */
.switch {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.slider {
  background-color: #cccccc;
  border-radius: 20px;
}

input:checked + .slider {
  background-color: var(--active-tab-text);
}

.slider:before {
  background-color: #ffffff;
}

/* Responsiveness */
@media (max-width: 1024px) {
  .contact-info {
    grid-template-columns: 1fr;
  }

  .video-container {
    max-width: 600px;
  }
}

@media (max-width: 768px) {
  header {
    padding: 6px 8px; /* Very small padding for mobile */
  }

  .logo-container {
    gap: 4px; /* Very small gap for mobile */
  }

  .company-logo {
    height: 20px; /* Default for external CSS, overridden by inline CSS */
  }

  .company-title {
    font-size: 1rem; /* Increased font size for mobile */
    line-height: 16px; /* Match smaller logo height for mobile */
  }

  .header-buttons {
    gap: 4px; /* Very small gap for mobile */
    margin-left: auto; /* Keep buttons on the right */
  }

  .header-button {
    font-size: 0.9rem; /* Very small font size for mobile */
    padding: 4px 6px;
    line-height: 16px; /* Match smaller logo height for mobile */
  }

  .fixed-nav {
    top: 32px; /* Adjusted for very small header */
  }

  .nav-links {
    gap: 10px;
  }

  .nav-link {
    font-size: 1rem;
    padding: 6px 12px;
  }

  .metal-info {
    grid-template-columns: 1fr; /* Single column for smaller screens */
  }

  .metal-type {
    min-width: 100px; /* Smaller min-width for mobile */
  }

  .map-container iframe {
    height: 250px;
  }

  .tab-bar {
    gap: 10px;
  }

  .tab img {
    width: 25px;
    height: 25px;
  }

  .video-container {
    margin-top: 52px; /* Adjusted for smaller header */
  }
}

@media (min-width: 1024px) {
  .tab-bar {
    display: none; /* Hide tab bar on desktop */
  }
}

/* Accessibility */
a:focus,
button:focus,
.tab:focus {
  outline: 2px solid var(--active-tab-text);
  outline-offset: 2px;
}