/* ============================================
   Forms
   ============================================ */
.drive-form {
  background-color: transparent;
  border: none;
  padding: 0;
  width: 100%;
  max-width: var(--form-max-width);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
  margin-left: auto;
  margin-right: auto;
}

.form-section {
  background-color: var(--color-surface);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.form-section-content {
  padding: var(--spacing-lg);
  border-radius: var(--border-radius-lg);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

.field {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

/* Two fields on one row (e.g. first + last name); stacks on narrow screens. */
.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-xl);
}

@media (min-width: 520px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Password input with an inline show/hide toggle. */
.password-field {
  position: relative;
}

/* Reserve room for the toggle. Uses three classes so it out-specifies the base
   `.field input[type="password"]` padding shorthand, and stays type-agnostic so
   the space is kept when the field is revealed (type="text"). */
.field .password-field .password-input {
  padding-right: 3.25rem;
}

/* Out-specifies the global `form button` base (0,0,0,2) so the toggle stays a
   bare icon button instead of a full-size form button. */
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 3rem;
  height: 100%;
  min-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--color-text-light);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .password-toggle:hover {
    background: none;
    color: var(--color-primary);
  }
}

.password-toggle .icon {
  display: block;
}

/* Suppress the browser's own reveal/clear controls (Edge) so only our toggle
   shows — otherwise password fields get two eyes. */
.password-field input::-ms-reveal,
.password-field input::-ms-clear {
  display: none;
}

.field label {
  display: block;
  margin-bottom: calc(var(--spacing-unit) * 0.625);
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.5;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="datetime-local"],
.field input[type="number"],
.field textarea,
.form-input {
  width: 100%;
  padding: var(--spacing-lg) calc(var(--spacing-unit) * 1.25);
  min-height: 48px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background-color: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, background-color var(--duration-fast) ease;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.form-textarea {
  min-height: 100px;
  padding-top: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  line-height: 1.6;
  resize: vertical;
}

@media (hover: hover) {
  .field input:hover,
  .field textarea:hover {
    border-color: var(--color-primary-light);
  }
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
  background-color: var(--color-surface);
}

.field small {
  display: block;
  margin-top: var(--spacing-sm);
  color: var(--color-text-light);
  font-size: 0.875rem;
  line-height: 1.5;
}

.form-hint {
  color: var(--color-text-light);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
}

.error-messages {
  background: linear-gradient(135deg, var(--color-error-soft) 0%, var(--color-error-soft-strong) 100%);
  border: 2px solid var(--color-error-soft-border);
  border-radius: var(--border-radius-sm);
  padding: calc(var(--spacing-unit) * 1.25);
  margin-bottom: var(--spacing-2xl);
  box-shadow: var(--shadow-sm);
}

.error-messages h3 {
  color: var(--color-error-strong);
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
}

.error-messages ul {
  margin-left: var(--spacing-xl);
  color: var(--color-error-strong);
  font-size: 0.875rem;
  list-style-type: disc;
}

.error-messages li {
  margin-bottom: var(--spacing-xs);
}

.form-footer {
  margin-top: var(--spacing-xl);
  text-align: center;
}

.form-footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  padding: var(--spacing-sm);
  display: inline-block;
  transition: color var(--duration-base) ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .form-footer a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
  }
}

.form-footer a:active {
  color: var(--color-primary-dark);
  opacity: 0.8;
}

/* Form Title */
.form-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--spacing-xl) 0;
  text-align: center;
  letter-spacing: -0.01em;
}

/* Branded auth header (sign-up/sign-in): dial mark + display heading. */
.auth-header {
  text-align: center;
  margin-bottom: var(--spacing-2xl);
}

.auth-mark {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--spacing-lg);
  border-radius: 13px;
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin: 0;
}

.auth-subtitle {
  margin-top: var(--spacing-sm);
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Settings container/section base — must precede the mobile media query below:
   same-specificity rules cascade by source order regardless of which is behind
   a media query, so a later unconditional rule here would silently win over
   its override. Every section is a full-width row at every screen size. */
.settings-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2xl);
}

.settings-section {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-sm);
}

/* Desktop Form Styles */
@media (min-width: 769px) {
  .authentication-form-container .drive-form {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-3xl);
    box-shadow: var(--shadow-md);
    max-width: 480px;
    width: 100%;
  }

  /* Forms with a two-up name row (sign-up) get more width so the paired fields
     aren't cramped; single-column forms (sign-in) keep the narrower default. */
  .authentication-form-container .drive-form:has(.field-row) {
    max-width: 560px;
  }

  /* Hide separate page header on desktop, show title inside form */
  .authentication-form-container .page-header {
    display: none;
  }

  .authentication-form-container .form-title {
    display: block;
  }

  /* Full-width buttons in authentication forms on desktop */
  .authentication-form-container .actions {
    flex-direction: column;
    width: 100%;
  }

  .authentication-form-container .actions .button,
  .authentication-form-container .actions .button-primary {
    width: 100%;
    min-height: 52px;
    font-size: 1.0625rem;
  }

  /* Hide mobile-only settings session block on desktop */
  .settings-section-session {
    display: none;
  }

  .drive-form-page {
    max-width: var(--form-max-width);
    margin-left: auto;
    margin-right: auto;
  }
}

/* Mobile Form Styles */
@media (max-width: 768px) {
  .drive-form {
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: none;
    gap: var(--spacing-lg);
  }

  /* Hide separate page header on mobile, show title inside form */
  .authentication-form-container .page-header {
    display: none;
  }

  .authentication-form-container .form-title {
    display: block;
    font-size: 1.25rem;
    margin-bottom: var(--spacing-lg);
  }

  .form-section {
    border-radius: var(--border-radius);
    box-shadow: none;
  }

  .form-section-content {
    padding: var(--spacing-lg);
  }

  .form-actions {
    margin-top: 0;
    padding-top: calc(var(--spacing-unit) * 1.25);
  }

  .field label {
    font-size: 0.8125rem;
    margin-bottom: calc(var(--spacing-unit) * 0.625);
  }

  .field input,
  .field textarea,
  .form-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--spacing-lg) var(--spacing-lg);
    min-height: 44px;
  }

  .form-textarea {
    min-height: 100px;
  }

  /* Mobile settings layout - stack everything */
  .settings-container {
    gap: var(--spacing-lg);
  }

  .settings-section {
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
  }
}

/* Settings page styles */
.settings-section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--spacing-sm) 0;
}

.settings-section-description {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0 0 var(--spacing-lg) 0;
}

.settings-section .drive-form {
  margin: 0;
}

.location-status {
  border-radius: var(--border-radius-sm);
}

.location-set {
  color: var(--color-success);
  font-size: 0.875rem;
  margin: 0;
}

.location-not-set {
  color: var(--color-text-light);
  font-size: 0.875rem;
  margin: 0;
}

.ios-note {
  display: none;
  margin-top: var(--spacing-lg);
  padding: var(--spacing-lg);
  background: var(--color-day-badge-bg);
  border: 1px solid var(--color-day-badge-icon);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-day-badge-text);
}

/* Notification status styles (similar to location status) */
.notification-status {
  margin-bottom: var(--spacing-lg);
}

.notification-status-text {
  font-size: 0.875rem;
  margin: 0;
}

.notification-status-text.enabled {
  color: var(--color-success);
}

.notification-status-text.disabled {
  color: var(--color-text-light);
}

.notification-status-text.error {
  color: var(--color-danger);
}

/* Toggle switch container */
.notification-toggle-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.toggle-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text);
  user-select: none;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.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-border);
  transition: background-color var(--duration-base) ease, box-shadow var(--duration-fast) ease;
  border-radius: 34px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: transform var(--duration-base) var(--ease-out);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

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

.toggle-switch input:disabled + .toggle-slider {
  cursor: not-allowed;
  opacity: 0.5;
  background-color: var(--color-border-light);
}

.toggle-switch input:disabled + .toggle-slider:before {
  background-color: var(--color-border);
}

@media (hover: hover) {
  .toggle-slider:hover {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(37, 99, 235, 0.1);
  }

  .toggle-switch input:disabled + .toggle-slider:hover {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  }
}

/* Dark mode error state tweaks */
[data-theme="dark"] .error-messages,
body[data-theme="dark"] .error-messages {
  background: linear-gradient(135deg, var(--color-error-soft) 0%, var(--color-error-soft-strong) 100%);
  border-color: #b91c1c;
}

[data-theme="dark"] .error-messages h3,
body[data-theme="dark"] .error-messages h3,
[data-theme="dark"] .error-messages ul,
body[data-theme="dark"] .error-messages ul {
  color: var(--color-error-soft-strong);
}
