/**
 * Preferences UI Styles
 *
 * @format
 */

.preferences-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  overflow-y: auto;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  isolation: isolate;
}

.preferences-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
}

.preferences-modal:not(.active) {
  pointer-events: none;
}

.preferences-modal.active .preferences-container {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.preferences-container {
  background: #fff !important;
  color: #232323 !important;
  border-radius: 1.1em !important;
  box-shadow: 0 4px 32px #0002 !important;
  max-width: 98vw !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  padding: 2.2em 2em 1.5em 2em !important;
  margin: 0 auto !important;
  font-size: 1.08em !important;
  overflow-x: hidden !important;
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  position: relative;
  z-index: 10000;
  pointer-events: auto;
}

@media (max-width: 700px) {
  .preferences-container {
    padding: 1.2em 0.7em 1em 0.7em !important;
    font-size: 1em !important;
    border-radius: 0.8em !important;
    gap: 0.7em;
  }
}

.preferences-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2em;
  gap: 0.7em;
}

.preferences-header h3 {
  margin: 0;
  font-size: 1.25em;
  font-weight: 700;
  color: var(--accent, #2563eb);
}

.close-preferences {
  font-size: 1.2em !important;
  padding: 0.2em 0.7em !important;
  border-radius: 0.5em !important;
  background: none !important;
  color: #666 !important;
  border: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  line-height: 1.1;
  position: relative;
  z-index: 10001;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
}

.preferences-tabs {
  display: flex;
  gap: 0.5em;
  margin-bottom: 1.2em;
  overflow-x: auto;
  padding-bottom: 0.2em;
}

.preferences-tab {
  padding: 0.6em 1.1em;
  border-radius: 0.5em;
  font-size: 1em;
  font-weight: 500;
  background: #f3f4f6;
  color: #333;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  min-width: 4.5em;
}

.preferences-tab.active {
  background: var(--accent, #2563eb);
  color: #fff;
  border-color: var(--accent, #2563eb);
}

.preference-group {
  margin-bottom: 1.2em;
  background: #f9fafb;
  border-radius: 0.7em;
  padding: 1.1em 1em 0.7em 1em;
  box-shadow: 0 1px 6px #0001;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
}

.preference-group:last-child {
  margin-bottom: 0.5em;
}

.preference-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2em;
  padding: 0.7em 0.2em;
  border-radius: 0.5em;
  background: #fff;
  border: 1px solid #e5e7eb;
  transition: background 0.2s;
}

.preference-label {
  font-weight: 500;
  font-size: 1em;
  color: #374151;
  flex: 1 1 60%;
  min-width: 0;
}

.preference-control {
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex: 1 1 40%;
  min-width: 0;
  justify-content: flex-end;
}

.pref-select,
.pref-input {
  padding: 0.5em 1em;
  border-radius: 0.5em;
  font-size: 1em;
  background: #e1f5fe;
  color: #01579b;
  border: 1px solid #b3e5fc;
  min-width: 4.5em;
  max-width: 100%;
}

.pref-select:disabled {
  background: #f3f4f6;
  color: #64748b;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .preference-group {
    padding: 0.7em 0.3em 0.5em 0.3em;
    gap: 0.5em;
  }
  .preference-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3em;
    padding: 0.5em 0.1em;
  }
  .preference-label,
  .preference-control {
    font-size: 0.98em;
    width: 100%;
    min-width: 0;
  }
}

/* --- Preferences Modal Action Buttons (bottom) --- */
.preferences-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
  justify-content: flex-end;
  margin-top: 1.2em;
  margin-bottom: 0.2em;
}

.btn-preference,
.preferences-actions button {
  font-size: 1em !important;
  padding: 0.55em 1.2em !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border-radius: 0.5em !important;
  box-shadow: 0 1px 4px #0001;
  background: var(--accent, #2563eb);
  color: #fff;
  border: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  margin: 0;
  line-height: 1.2;
}

.btn-preference.danger {
  background: #d90429 !important;
}

.btn-preference.primary {
  background: var(--primary, #2563eb) !important;
}

.btn-preference:focus,
.preferences-actions button:focus {
  box-shadow: 0 0 0 2px var(--accent, #2563eb);
}

@media (max-width: 600px) {
  .preferences-actions {
    flex-direction: column;
    gap: 0.5em;
    align-items: stretch;
  }
  .btn-preference,
  .preferences-actions button {
    font-size: 0.98em !important;
    padding: 0.7em 0.7em !important;
    width: 100%;
    min-width: 0 !important;
    min-height: 0 !important;
  }
}

/* --- Preferences Modal Top Buttons (close, etc.) --- */
.close-preferences {
  font-size: 1.3em !important;
  padding: 0.2em 0.5em !important;
  border-radius: 0.5em !important;
  background: none !important;
  color: #666 !important;
  border: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  line-height: 1.1;
}

.close-preferences:focus {
  box-shadow: 0 0 0 2px var(--accent, #2563eb);
}

/* --- Hide overflow for modal content --- */
.preferences-container {
  overflow-x: hidden;
}

/* --- Fix for modal content being hidden under top buttons --- */
.preferences-container {
  padding-top: 2.5em !important;
}

@media (max-width: 600px) {
  .preferences-container {
    padding-top: 2em !important;
  }
}

/* Preferences toast/feedback area */
#preferencesToast {
  position: fixed;
  left: 50%;
  bottom: 2.5em;
  transform: translateX(-50%);
  background: #2563eb;
  color: #fff;
  padding: 0.9em 2em;
  border-radius: 0.7em;
  font-size: 1.08em;
  font-weight: 600;
  box-shadow: 0 2px 12px #0002;
  z-index: 11000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, bottom 0.3s;
}
#preferencesToast.show {
  opacity: 1;
  bottom: 3.5em;
  pointer-events: auto;
}

/* Hide file input for import button */
#importPrefsInput {
  display: none;
}

/* Toggle switch styling */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  background: #ccc;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.toggle-switch:before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch.active {
  background: var(--primary-color, #007bff);
}

.toggle-switch.active:before {
  transform: translateX(26px);
}

.toggle-switch:hover {
  opacity: 0.8;
}

.toggle-switch:focus {
  outline: 2px solid var(--primary-color, #007bff);
  outline-offset: 2px;
}

/* Color picker styling */
.color-picker {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.color-preview {
  width: 32px;
  height: 32px;
  border: 2px solid #ddd;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
}

.color-input::-webkit-color-swatch {
  border: none;
}

.color-input::-moz-color-swatch {
  border: none;
}

/* Driver list styling */
.driver-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5em;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 0.5em;
}

.driver-list-item:last-child {
  margin-bottom: 0;
}

.btn-edit-driver,
.btn-remove-driver {
  padding: 0.25em 0.5em;
  font-size: 0.8em;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  margin-left: 0.5em;
}

.btn-edit-driver {
  background: #007bff;
  color: white;
}

.btn-remove-driver {
  background: #dc3545;
  color: white;
}

.driver-empty {
  color: #666;
  font-style: italic;
  padding: 1em;
  text-align: center;
}

/* Preference feedback styling */
.preference-feedback {
  padding: 0.5em;
  border-radius: 4px;
  margin-top: 0.5em;
  display: none;
}

.preference-feedback.show {
  display: block;
}

.preference-feedback.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.preference-feedback.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Toast notification styling */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1em;
  border-radius: 4px;
  color: white;
  font-weight: 500;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 10000;
  max-width: 300px;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  background: #28a745;
}

.toast.error {
  background: #dc3545;
}

.toast.info {
  background: #17a2b8;
}

/* Help icon styling */
.help-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #007bff;
  color: white;
  font-size: 12px;
  text-align: center;
  line-height: 16px;
  cursor: help;
  margin-left: 0.5em;
}

.help-icon:hover {
  background: #0056b3;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .card,
  .preferences-container {
    padding: 0.5em;
  }
  .progress-card {
    padding: 0.7em 0.5em 1em 0.5em;
  }
  .preferences-modal .preferences-container {
    padding: 0.5em 0.25em;
    max-width: 99vw;
  }
  .preferences-tabs {
    font-size: 0.95em;
    gap: 0.1em;
  }
  .preferences-tab {
    padding: 0.4em 0.7em;
    font-size: 0.97em;
  }
}

/* Responsive modal improvements */
.responsive-modal {
  max-width: 98vw !important;
  min-width: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
  max-height: 90vh !important;
  overflow-y: auto !important;
  margin: 0 auto !important;
  border-radius: 1em !important;
  padding: clamp(1em, 3vw, 2em) !important;
  background: #fff !important;
  box-shadow: 0 2px 24px #0003 !important;
  font-size: clamp(1rem, 2.5vw, 1.15rem) !important;
}

@media (max-width: 600px) {
  .responsive-modal {
    padding: 1em 0.5em !important;
    border-radius: 0.7em !important;
    font-size: 1rem !important;
  }
  .preferences-tab,
  .preference-group,
  .preferences-container {
    font-size: 1rem !important;
  }
  .quick-add-btns button,
  .quick-add-btn {
    font-size: 1em !important;
    min-width: 2.5em !important;
    padding: 0.5em 0.7em !important;
  }
}

/* Table responsiveness */
#logTable {
  width: 100%;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 1px 8px #0001;
  border-radius: 0.7em;
  overflow: hidden;
}
#logTable th,
#logTable td {
  padding: 0.7em 0.5em;
  text-align: left;
  word-break: break-word;
}
@media (max-width: 700px) {
  #logTable th,
  #logTable td {
    padding: 0.5em 0.2em;
    font-size: 0.98em;
  }
  #logTable {
    font-size: 0.98em;
  }
}
@media (max-width: 480px) {
  #logTable th,
  #logTable td {
    padding: 0.4em 0.1em;
    font-size: 0.93em;
  }
  #logTable {
    font-size: 0.93em;
  }
}

/* Button and input tap target improvements */
button,
input[type="button"],
input[type="submit"] {
  min-height: 2.5em;
  min-width: 2.5em;
  font-size: 1em;
  border-radius: 0.5em;
  padding: 0.5em 1em;
}
@media (hover: none) and (pointer: coarse) {
  button,
  input[type="button"],
  input[type="submit"] {
    min-height: 3em;
    min-width: 3em;
    font-size: 1.1em;
    padding: 0.7em 1.2em;
  }
}

/* Form and section spacing */
#quick-entry,
#log-table-section {
  margin-bottom: 1.5em;
}

.margin-bottom-1-5em {
  margin-bottom: 1.5em;
}

.storage-mode-static {
  background: #f3f6fa;
  color: #64748b;
  cursor: not-allowed;
}

.primary-color-preview {
  background: #007bff !important;
}

.accent-color-preview {
  background: #28a745 !important;
}

.min-width-140px {
  min-width: 140px;
}

.margin-top-1-5em {
  margin-top: 1.5em;
}

.visually-hidden {
  display: none !important;
}

.preferences-close-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 0.5em;
  padding: 0.7em 2em;
  font-size: 1.1em;
  font-weight: 600;
  box-shadow: 0 2px 8px #0001;
  transition: background 0.2s;
}

.preferences-close-btn:hover,
.preferences-close-btn:focus {
  background: #1e40af;
}

/* Preferences section styling */
.preferences-section {
  display: none;
  padding: 1rem 0;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.preferences-section.active {
  display: block;
  opacity: 1;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.preferences-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--primary-color, #007bff);
  font-size: 1.1em;
}

.preferences-section h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1em;
  font-weight: 600;
}

.preferences-section p {
  margin: 0 0 0.5rem 0;
  color: #666;
  font-size: 0.9em;
}

.dark-theme .preferences-section p {
  color: #aaa;
}

.dark-theme .preferences-section h3 {
  color: var(--primary-color, #0d6efd);
}
