:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --primary-color: #007bff;
  --secondary-color: #6c757d;
  --border-color: #ced4da;
  --input-bg: #f8f9fa;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
  --bg-color: #1a1a1a;
  --text-color: #f0f0f0;
  --primary-color: #4da3ff;
  --secondary-color: #a1a1a1;
  --border-color: #4a4a4a;
  --input-bg: #2c2c2c;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--primary-color);
}

.navbar {
  background-color: var(--primary-color);
  padding: 1rem;
}

.navbar-brand {
  font-weight: bold;
  color: var(--bg-color) !important;
}

.nav-link {
  color: var(--bg-color) !important;
}

.list-group-item {
  background-color: var(--bg-color);
  border-color: var(--border-color);
}

.list-group-item a {
  text-decoration: none;
  color: var(--text-color);
}

.list-group-item a:hover {
  text-decoration: underline;
}

.tool-container {
  max-width: 800px;
  margin: 1rem auto;
  padding: 1.5rem;
  background-color: var(--bg-color);
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

@media (max-width: 576px) {
  .tool-container {
    margin: 0.5rem;
    padding: 1rem;
    border-radius: 4px;
  }
}

.input-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
}

.input-group {
  overflow: visible; /* Make sure the container allows the textarea to expand */
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
}

.input-group textarea {
  width: 100%;
  min-height: 150px;
  max-height: 500px; /* Add a max height to avoid too much expansion */
  height: auto;
  resize: vertical; /* Allow vertical resize */
  overflow-y: auto; /* Allow scrolling when content exceeds height */
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: monospace;
  line-height: 1.4;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  background-color: var(--input-bg);
  color: var(--text-color);
  box-sizing: border-box;
}

/* Uniform inputs/selects */
.input-group input[type="text"],
.input-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  background-color: var(--input-bg);
  color: var(--text-color);
  box-sizing: border-box;
}

/* Fix for select dropdown display */
.input-group select {
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  background-image: none;
  /* Force proper text color inheritance */
  color: var(--text-color) !important;
}

/* Dark mode select fix */
body.dark-mode .input-group select {
  color: #f0f0f0 !important;
  background-color: #2c2c2c !important;
}

/* Light mode select fix */
body:not(.dark-mode) .input-group select {
  color: #333333 !important;
  background-color: #f8f9fa !important;
}

/* Ensure select text is visible */
.input-group select option {
  background-color: var(--bg-color);
  color: var(--text-color);
}


/* Ensure the container adjusts to the textarea content */
.input-group {
  overflow: visible;
  margin-bottom: 1.5rem;
}

button {
  background-color: var(--primary-color);
  color: var(--bg-color);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  margin-right: 0.75rem;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0056b3;
}

.result-area {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  margin-top: 1.5rem;
  color: var(--text-color);
}

.success {
  color: #28a745;
}

.error {
  color: #dc3545;
}

.failure {
  color: #ffc107;
}

/* Theme switcher styles */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
  margin-right: 1rem;
}

@media (max-width: 576px) {
  .theme-switch-wrapper {
    display: none;
  }
  
  .navbar .theme-switch-wrapper.mobile {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 0.5rem 0;
  }
}

.theme-switch {
  display: inline-block;
  height: 34px;
  position: relative;
  width: 60px;
}

.theme-switch input {
  display: none;
}

.slider {
  background-color: #ccc;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
}

.slider:before {
  background-color: #fff;
  bottom: 4px;
  content: "";
  height: 26px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 26px;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Enhanced Responsive design */
@media (max-width: 768px) {
  body {
    font-size: 0.9rem;
  }
  
  h1 {
    font-size: 1.8rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .navbar {
    padding: 0.5rem 1rem;
  }
  
  .navbar-brand {
    font-size: 1.1rem;
  }
  
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .input-group input[type="text"],
  .input-group textarea,
  .input-group select {
    font-size: 1rem;
    padding: 0.75rem;
  }
  
  .input-group textarea {
    min-height: 120px;
  }

  button {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    width: 100%;
  }
  
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-group button {
    margin-right: 0;
  }
  
  .list-group-item {
    padding: 1rem;
  }
  
  .list-group-item a {
    font-size: 0.9rem;
  }
}

@media (max-width: 576px) {
  .navbar {
    padding: 0.25rem 0.5rem;
  }
  
  .theme-switch-wrapper {
    display: none;
  }
  
  .home-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .alert {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  .result-area {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
}

/* Styles for the home button */
.home-button {
  margin-left: 0.75rem;
  transition: all 0.3s ease;
}

.home-button:hover {
  background-color: var(--secondary-color);
  color: var(--bg-color);
}

@media (max-width: 768px) {
  .home-button {
    margin-left: 0.5rem;
  }
}

@media (max-width: 576px) {
  .home-button {
    margin-left: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }
}

/* Timezone Converter Styles */
.converter-form {
  max-width: 100%;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.convert-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background-color: var(--primary-color);
  color: var(--bg-color);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s ease;
  margin-top: 1rem;
}

/* Compare rows layout */
.tozone-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.tozone-row select {
  flex: 1 1 auto;
}
.tozone-row .remove-btn {
  padding: 0.5rem 0.75rem;
  line-height: 1;
}

.convert-btn:hover {
  background-color: #0056b3;
}

.result-container {
  margin-top: 2rem;
  text-align: center;
}

.result-box {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1.5rem;
  display: inline-block;
  min-width: 300px;
  max-width: 100%;
  box-sizing: border-box;
}

.result-text {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
  color: var(--text-color);
  word-wrap: break-word;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .result-box {
    min-width: auto;
    width: 100%;
  }

  .result-text {
    font-size: 1rem;
  }
}

/* Digital Clock Styles */
.current-times {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}

.digital-clock {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  text-align: center;
  width: 48%;
}

.digital-clock h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: var(--text-color);
}

.clock-display {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary-color);
  background-color: var(--bg-color);
  padding: 0.5rem;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .current-times {
    flex-direction: column;
  }

  .digital-clock {
    width: 100%;
    margin-bottom: 1rem;
  }

  .clock-display {
    font-size: 1.5rem;
  }
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
  .list-group-item a {
    padding: 0.75rem 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .list-group-item i {
    margin-right: 12px;
    font-size: 1.3em;
    min-width: 20px;
  }
  
  /* Better form controls */
  input, select, textarea {
    min-height: 44px;
  }
  
  button {
    min-height: 44px;
    font-weight: 500;
  }
  
  /* Improved error page mobile layout */
  .alert .btn {
    margin: 0.25rem;
    min-width: 120px;
  }
  
  .d-flex.gap-3 {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem !important;
  }
}

/* Timezone Converter Enhancements */
.time-input-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Make timezone dropdowns wider and more visible */
.converter-form #fromZone {
  min-width: 300px;
  width: 100%;
  max-width: 400px;
  padding: 0.75rem;
  font-size: 1rem;
  background-color: var(--input-bg);
  border: 2px solid var(--border-color);
  border-radius: 6px;
}

.converter-form .tozone-select {
  min-width: 250px;
  width: 100%;
  max-width: 350px;
  padding: 0.75rem;
  font-size: 1rem;
  background-color: var(--input-bg);
  border: 2px solid var(--border-color);
  border-radius: 6px;
}

.converter-form #fromZone:focus,
.converter-form .tozone-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
  outline: none;
}

.input-with-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-with-buttons input {
  flex: 1;
}

.input-with-buttons #timePicker {
  display: block;
}

.input-with-buttons #time {
  display: none;
}

.input-with-buttons.text-mode #timePicker {
  display: none;
}

.input-with-buttons.text-mode #time {
  display: block;
}

.input-with-buttons button {
  white-space: nowrap;
  min-width: auto;
}

.current-times-container {
  margin: 2rem 0;
  padding: 1rem;
  background-color: var(--input-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.current-times-container h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.current-times {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.current-time-item {
  text-align: center;
  padding: 0.75rem;
  background-color: var(--bg-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.timezone-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.25rem;
}

.current-time {
  font-size: 1.1rem;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  color: var(--primary-color);
}

.current-time-item.error {
  color: #dc3545;
  font-size: 0.8rem;
}

@media (max-width: 576px) {
  .input-with-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .input-with-buttons input {
    margin-bottom: 0;
  }
  
  .input-with-buttons button {
    width: auto;
    align-self: center;
    min-width: 80px;
  }
  
  .time-input-container {
    gap: 0.75rem;
  }
  
  .current-times {
    grid-template-columns: 1fr;
  }
  
  .current-times-container {
    margin: 1rem 0;
    padding: 0.75rem;
  }
}

/* Notepad sidebar styles */
.notepad-sidebar {
  position: fixed;
  top: 0;
  right: -400px;
  width: 350px;
  height: 100vh;
  background-color: var(--bg-color);
  border-left: 1px solid var(--border-color);
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.notepad-sidebar.open {
  right: 0;
}

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

.notepad-header h3 {
  margin: 0;
  color: var(--primary-color);
}

.notepad-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-color);
}

.notepad-content {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.notepad-textarea {
  flex: 1;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--input-bg);
  color: var(--text-color);
  resize: none;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

.notepad-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  background-color: var(--input-bg);
}

.notepad-stats {
  font-size: 0.8rem;
  color: var(--secondary-color);
}

.notepad-buttons {
  display: flex;
  gap: 0.5rem;
}

.notepad-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

.notepad-btn.save {
  background-color: var(--primary-color);
  color: var(--bg-color);
}

.notepad-btn.save:hover {
  background-color: #0056b3;
}

.notepad-btn.download {
  background-color: #28a745;
  color: var(--bg-color);
}

.notepad-btn.download:hover {
  background-color: #218838;
}

.notepad-btn.clear {
  background-color: #dc3545;
  color: var(--bg-color);
}

.notepad-btn.clear:hover {
  background-color: #c82333;
}

.notepad-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.notepad-overlay.open {
  display: block;
}

/* Responsive adjustments for notepad */
@media (max-width: 576px) {
  .notepad-sidebar {
    width: 100%;
    right: -100%;
  }
  
  .notepad-sidebar.open {
    right: 0;
  }
  
  .notepad-textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Landscape orientation optimizations */
@media (max-width: 812px) and (orientation: landscape) {
  .container {
    padding-top: 1rem;
  }
  
  .tool-container {
    margin: 0.5rem;
    padding: 1rem;
  }
  
  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }
}
