/**
 * Settings Page Styles
 * Notification preferences and account settings UI
 */

/* Toggle Switch Component */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-gray-400);
  transition: background-color 0.3s ease;
  border-radius: 24px;
  border: 1px solid var(--color-gray-500);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--color-white);
  transition: transform 0.3s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); /* --color-primary-500 at 30% opacity */
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form Controls */
.form-input,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-gray-300);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-gray-800);
  background-color: var(--color-white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* --color-primary-500 at 10% opacity */
}

.form-input:disabled {
  background-color: var(--color-gray-100);
  cursor: not-allowed;
  opacity: 0.6;
}

.form-select {
  /* SVG uses encoded color: %236b7280 = #6b7280 = --color-gray-500 */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Notification Types Table */
.notification-types-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.notification-types-table thead {
  background-color: var(--color-gray-50);
  border-bottom: 2px solid var(--color-gray-200);
}

.notification-types-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--color-gray-700);
  white-space: nowrap;
}

.notification-types-table th:first-child {
  width: auto;
}

.notification-types-table th:not(:first-child) {
  text-align: center;
  width: 80px;
}

.notification-types-table tbody tr {
  border-bottom: 1px solid var(--color-gray-200);
  transition: background-color 0.15s ease;
}

.notification-types-table tbody tr:hover {
  background-color: var(--color-gray-50);
}

.notification-types-table tbody tr:last-child {
  border-bottom: none;
}

.notification-types-table td {
  padding: 1rem;
}

.notification-types-table td:not(:first-child) {
  text-align: center;
}

.notification-types-table input[type="checkbox"] {
  cursor: pointer;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--color-white);
  background-color: var(--color-primary-500);
  border: 1px solid transparent;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-600);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); /* --color-primary-500 at 30% opacity */
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--color-gray-700);
  background-color: var(--color-white);
  border: 1px solid var(--color-gray-400);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-gray-50);
  border-color: var(--color-gray-400);
}

.btn-secondary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* --color-primary-500 at 10% opacity */
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slide-down {
  animation: slideDown 0.2s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
  .notification-types-table {
    font-size: 0.75rem;
  }

  .notification-types-table th,
  .notification-types-table td {
    padding: 0.5rem;
  }

  .notification-types-table th:not(:first-child),
  .notification-types-table td:not(:first-child) {
    width: 60px;
  }

  .toggle-switch {
    width: 40px;
    height: 20px;
  }

  .toggle-slider:before {
    height: 14px;
    width: 14px;
  }

  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
  }
}

/* Sticky Sidebar */
@media (min-width: 1024px) {
  .sticky {
    position: sticky;
    top: 6rem;
  }
}

/* Loading Spinner */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Transition Classes */
.transition-colors {
  transition-property: background-color, border-color, color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Card Shadows */
.shadow-md {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Rounded Corners */
.rounded {
  border-radius: 0.25rem;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-full {
  border-radius: 9999px;
}

/* Spacing Utilities */
.space-y-1 > * + * {
  margin-top: 0.25rem;
}

.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.space-y-3 > * + * {
  margin-top: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

/* Flex Utilities */
.flex {
  display: flex;
}

.flex-1 {
  flex: 1 1 0%;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

/* Grid Utilities */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

/* =============================================================================
   Consent Toggle Utilities (Alpine.js toggle on consent.html)
   ============================================================================= */

/* Track backgrounds */
.bg-emerald-500 {
  background-color: #10b981;
}

.bg-gray-500 {
  background-color: #6b7280;
}

/* Icon colors */
.text-emerald-600 {
  color: #059669;
}

.text-gray-500 {
  color: #6b7280;
}

/* Thumb position transforms */
.translate-x-0 {
  transform: translateX(0);
}

.translate-x-8 {
  transform: translateX(2rem);
}

/* Focus ring */
.focus-visible\:ring-2:focus-visible {
  box-shadow: 0 0 0 2px #3b82f6;
}

.focus-visible\:ring-blue-500:focus-visible {
  --tw-ring-color: #3b82f6;
}

.focus-visible\:ring-offset-2:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3b82f6;
}

/* Transition duration */
.duration-200 {
  transition-duration: 200ms;
}
