/* components/settings-modal/settings-modal.css */
/* Settings Modal Component - BEM Methodology */

/* ========================================
   SETTINGS DIALOG
   ======================================== */

.c-settings {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90vw;
  max-width: 600px;
  max-height: 90vh;
  padding: 0;
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-l);
  box-shadow: var(--ds-shadow-xl);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: all var(--ds-duration-normal) var(--ds-ease-out);
  z-index: var(--nav-z-modal);
}

.c-settings[open] {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Dialog backdrop */
.c-settings::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ========================================
   SETTINGS HEADER
   ======================================== */

.c-settings__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-l);
  border-bottom: 1px solid var(--ds-color-border);
  flex-shrink: 0;
}

.c-settings__title {
  margin: 0;
  font-size: var(--ds-font-size-xl);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--ds-color-text);
}

.c-settings__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--ds-radius-m);
  color: var(--ds-color-icon);
  cursor: pointer;
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
}

.c-settings__close:hover {
  background: var(--ds-color-surface-hover);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text);
}

.c-settings__close:focus-visible {
  outline: var(--ds-focus-ring-width) solid var(--ds-focus-ring-color);
  outline-offset: var(--ds-focus-ring-offset);
}

/* ========================================
   SETTINGS BODY
   ======================================== */

.c-settings__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--ds-space-l);
  min-height: 0;
}

/* ========================================
   SETTINGS GROUPS
   ======================================== */

.c-settings__group {
  margin-bottom: var(--ds-space-xl);
  padding: 0;
  border: none;
}

.c-settings__group:last-child {
  margin-bottom: 0;
}

.c-settings__group-title {
  display: block;
  margin-bottom: var(--ds-space-m);
  font-size: var(--ds-font-size-m);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--ds-color-text);
  padding-bottom: var(--ds-space-s);
  border-bottom: 1px solid var(--ds-color-border);
}

.c-settings__group-description {
  margin: calc(var(--ds-space-s) * -1) 0 var(--ds-space-m) 0;
  font-size: var(--ds-font-size-s);
  color: var(--ds-color-text-weak);
  line-height: 1.5;
}

/* ========================================
   SETTINGS CONTROLS
   ======================================== */

/* Radio Group */
.c-settings__radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-s);
}

.c-settings__radio {
  display: flex;
  align-items: center;
  padding: var(--ds-space-s) var(--ds-space-m);
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-m);
  cursor: pointer;
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
  position: relative;
}

.c-settings__radio:hover {
  background: var(--ds-color-surface-hover);
  border-color: var(--ds-color-border-strong);
}

.c-settings__radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.c-settings__radio input[type="radio"]:checked + span::before {
  content: '';
  position: absolute;
  left: var(--ds-space-m);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--ds-color-accent);
  border-radius: 50%;
  background: var(--ds-color-surface);
}

.c-settings__radio input[type="radio"]:checked + span::after {
  content: '';
  position: absolute;
  left: calc(var(--ds-space-m) + 6px);
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--ds-color-accent);
  border-radius: 50%;
}

.c-settings__radio input[type="radio"]:focus-visible + span {
  outline: var(--ds-focus-ring-width) solid var(--ds-focus-ring-color);
  outline-offset: var(--ds-focus-ring-offset);
  border-radius: var(--ds-radius-m);
}

.c-settings__radio span {
  display: flex;
  align-items: center;
  gap: var(--ds-space-m);
  padding-left: calc(20px + var(--ds-space-m));
  position: relative;
  user-select: none;
  font-size: var(--ds-font-size-m);
  color: var(--ds-color-text);
}

.c-settings__radio input[type="radio"]:not(:checked) + span::before {
  content: '';
  position: absolute;
  left: var(--ds-space-m);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--ds-color-border-strong);
  border-radius: 50%;
  background: var(--ds-color-surface);
}

/* Checkbox Group */
.c-settings__checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-s);
}

.c-settings__checkbox {
  display: flex;
  align-items: center;
  padding: var(--ds-space-s) var(--ds-space-m);
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-m);
  cursor: pointer;
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
  position: relative;
}

.c-settings__checkbox:hover {
  background: var(--ds-color-surface-hover);
  border-color: var(--ds-color-border-strong);
}

.c-settings__checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.c-settings__checkbox input[type="checkbox"]:checked + span::before {
  content: '';
  position: absolute;
  left: var(--ds-space-m);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--ds-color-accent);
  border-radius: var(--ds-radius-s);
  background: var(--ds-color-accent);
}

.c-settings__checkbox input[type="checkbox"]:checked + span::after {
  content: '';
  position: absolute;
  left: calc(var(--ds-space-m) + 5px);
  top: 50%;
  width: 10px;
  height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: translateY(-60%) rotate(-45deg);
}

.c-settings__checkbox input[type="checkbox"]:focus-visible + span {
  outline: var(--ds-focus-ring-width) solid var(--ds-focus-ring-color);
  outline-offset: var(--ds-focus-ring-offset);
  border-radius: var(--ds-radius-m);
}

.c-settings__checkbox span {
  display: flex;
  align-items: center;
  gap: var(--ds-space-m);
  padding-left: calc(20px + var(--ds-space-m));
  position: relative;
  user-select: none;
  font-size: var(--ds-font-size-m);
  color: var(--ds-color-text);
}

.c-settings__checkbox input[type="checkbox"]:not(:checked) + span::before {
  content: '';
  position: absolute;
  left: var(--ds-space-m);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--ds-color-border-strong);
  border-radius: var(--ds-radius-s);
  background: var(--ds-color-surface);
}

/* Select Group */
.c-settings__select-group {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-s);
}

.c-settings__select-group label {
  font-size: var(--ds-font-size-s);
  font-weight: var(--ds-font-weight-medium);
  color: var(--ds-color-text-weak);
}

.c-settings__select {
  width: 100%;
  padding: var(--ds-space-s) var(--ds-space-m);
  padding-right: calc(var(--ds-space-m) * 2.5);
  background: var(--ds-color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--ds-space-s) center;
  background-size: 20px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-m);
  color: var(--ds-color-text);
  font-size: var(--ds-font-size-m);
  cursor: pointer;
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
  appearance: none;
}

.c-settings__select:hover {
  border-color: var(--ds-color-border-strong);
}

.c-settings__select:focus {
  outline: none;
  border-color: var(--ds-color-accent);
  box-shadow: 0 0 0 3px rgba(13, 86, 150, 0.1);
}

/* Switch/Toggle */
.c-settings__switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-s) 0;
}

.c-settings__switch-label {
  font-size: var(--ds-font-size-m);
  color: var(--ds-color-text);
  user-select: none;
}

.c-settings__switch-toggle {
  position: relative;
  width: 48px;
  height: 24px;
  background: var(--ds-color-border-strong);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--ds-duration-fast) var(--ds-ease-out);
  flex-shrink: 0;
}

.c-settings__switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.c-settings__switch input[type="checkbox"]:checked + .c-settings__switch-toggle {
  background: var(--ds-color-accent);
}

.c-settings__switch-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform var(--ds-duration-fast) var(--ds-ease-out);
}

.c-settings__switch input[type="checkbox"]:checked + .c-settings__switch-toggle::after {
  transform: translateX(24px);
}

.c-settings__switch input[type="checkbox"]:focus-visible + .c-settings__switch-toggle {
  outline: var(--ds-focus-ring-width) solid var(--ds-focus-ring-color);
  outline-offset: var(--ds-focus-ring-offset);
}

/* ========================================
   SETTINGS FOOTER
   ======================================== */

.c-settings__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ds-space-m);
  padding: var(--ds-space-l);
  border-top: 1px solid var(--ds-color-border);
  background: var(--ds-color-surface-raised);
  flex-shrink: 0;
}

/* ========================================
   SETTINGS TABS
   ======================================== */

.c-settings__tabs {
  display: flex;
  gap: var(--ds-space-xs);
  margin-bottom: var(--ds-space-l);
  padding-bottom: var(--ds-space-m);
  border-bottom: 1px solid var(--ds-color-border);
}

.c-settings__tab {
  padding: var(--ds-space-s) var(--ds-space-m);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ds-color-text-weak);
  font-size: var(--ds-font-size-m);
  font-weight: var(--ds-font-weight-medium);
  cursor: pointer;
  transition: all var(--ds-duration-fast) var(--ds-ease-out);
  border-radius: var(--ds-radius-m) var(--ds-radius-m) 0 0;
}

.c-settings__tab:hover {
  color: var(--ds-color-text);
  background: var(--ds-color-surface-hover);
}

.c-settings__tab:focus-visible {
  outline: var(--ds-focus-ring-width) solid var(--ds-focus-ring-color);
  outline-offset: -2px;
}

.c-settings__tab[aria-selected="true"] {
  color: var(--ds-color-accent);
  border-bottom-color: var(--ds-color-accent);
}

.c-settings__panel {
  display: none;
}

.c-settings__panel[aria-hidden="false"] {
  display: block;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .c-settings {
    width: 95vw;
    max-width: none;
    max-height: 95vh;
  }
  
  .c-settings__header,
  .c-settings__body,
  .c-settings__footer {
    padding: var(--ds-space-m);
  }
  
  .c-settings__radio-group,
  .c-settings__checkbox-group {
    gap: var(--ds-space-xs);
  }
  
  .c-settings__tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   DARK THEME ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .c-settings__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="dark"] .c-settings__select:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

[data-theme="dark"] .c-settings::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .c-settings {
    display: none;
  }
}