// Reusable Form Controls for Resources Pages
// Aperture Science / Portal-themed form inputs and controls

// Form Groups
.form-group,
.control-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;

  label {
    font-weight: 600;
    color: #66ccff;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    text-shadow: 0 0 8px rgba(0, 150, 255, 0.4);
    display: block;
    margin-bottom: 0.5rem;

    // Override for checkbox labels (when checkbox is inside label)
    &:has(input[type="checkbox"]) {
      display: flex;
      align-items: center;
      text-transform: none;
      font-size: 1rem;
      text-shadow: none;
      letter-spacing: normal;
    }
  }

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="color"],
  select {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 150, 255, 0.4);
    border-radius: 4px;
    font-size: 1rem;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: rgba(5, 15, 30, 0.7);
    color: rgba(200, 220, 255, 0.95);
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);

    &:focus {
      outline: none;
      border-color: rgba(0, 150, 255, 0.7);
      box-shadow:
        0 0 15px rgba(0, 150, 255, 0.3),
        inset 0 2px 8px rgba(0, 0, 0, 0.4);
      background: rgba(5, 15, 30, 0.9);
    }

    &::placeholder {
      color: rgba(100, 150, 200, 0.5);
    }
  }

  // Color inputs
  input[type="color"] {
    width: 100%;
    height: 40px;
    cursor: pointer;
  }

  // Range inputs (sliders)
  input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(
      90deg,
      rgba(0, 100, 180, 0.3) 0%,
      rgba(0, 150, 255, 0.5) 100%
    );
    border-radius: 3px;
    outline: none;
    border: 1px solid rgba(0, 150, 255, 0.4);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);

    // Webkit browsers (Chrome, Safari, Edge)
    &::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 18px;
      height: 18px;
      background: linear-gradient(
        135deg,
        rgba(0, 150, 255, 0.9) 0%,
        rgba(0, 120, 200, 0.8) 100%
      );
      border: 2px solid rgba(0, 150, 255, 0.6);
      border-radius: 50%;
      cursor: pointer;
      box-shadow:
        0 0 10px rgba(0, 150, 255, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
      transition: all 0.3s ease;

      &:hover {
        background: linear-gradient(
          135deg,
          rgba(0, 180, 255, 1) 0%,
          rgba(255, 120, 0, 0.6) 100%
        );
        box-shadow:
          0 0 15px rgba(0, 150, 255, 0.8),
          0 0 20px rgba(255, 120, 0, 0.3);
        transform: scale(1.1);
      }
    }

    // Firefox
    &::-moz-range-thumb {
      width: 18px;
      height: 18px;
      background: linear-gradient(
        135deg,
        rgba(0, 150, 255, 0.9) 0%,
        rgba(0, 120, 200, 0.8) 100%
      );
      border: 2px solid rgba(0, 150, 255, 0.6);
      border-radius: 50%;
      cursor: pointer;
      box-shadow:
        0 0 10px rgba(0, 150, 255, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
      transition: all 0.3s ease;

      &:hover {
        background: linear-gradient(
          135deg,
          rgba(0, 180, 255, 1) 0%,
          rgba(255, 120, 0, 0.6) 100%
        );
        box-shadow:
          0 0 15px rgba(0, 150, 255, 0.8),
          0 0 20px rgba(255, 120, 0, 0.3);
        transform: scale(1.1);
      }
    }

    &::-moz-range-track {
      background: linear-gradient(
        90deg,
        rgba(0, 100, 180, 0.3) 0%,
        rgba(0, 150, 255, 0.5) 100%
      );
      border-radius: 3px;
      border: 1px solid rgba(0, 150, 255, 0.4);
    }
  }

  // Checkboxes
  input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(5, 15, 30, 0.7);
    border: 2px solid rgba(0, 150, 255, 0.4);
    border-radius: 3px;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);

    &:checked {
      background: linear-gradient(
        135deg,
        rgba(0, 150, 255, 0.5) 0%,
        rgba(0, 120, 200, 0.4) 100%
      );
      border-color: rgba(0, 150, 255, 0.7);
      box-shadow:
        0 0 10px rgba(0, 150, 255, 0.4),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    &:checked::after {
      content: "✓";
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: #66ccff;
      font-size: 14px;
      font-weight: bold;
      text-shadow: 0 0 5px rgba(0, 150, 255, 0.8);
    }

    &:hover {
      border-color: rgba(0, 150, 255, 0.6);
      box-shadow:
        0 0 8px rgba(0, 150, 255, 0.3),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    &:focus {
      outline: none;
      border-color: rgba(0, 150, 255, 0.8);
      box-shadow:
        0 0 12px rgba(0, 150, 255, 0.5),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
    }
  }

  // Select dropdowns
  select {
    cursor: pointer;

    option {
      background: rgba(5, 15, 30, 0.95);
      color: rgba(200, 220, 255, 0.95);
    }
  }
}

// Shared button base styles
.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  border: 1px solid rgba(0, 150, 255, 0.5);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
  overflow: hidden;

  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(0, 150, 255, 0.3),
      transparent
    );
    transition: left 0.5s ease;
  }

  &:hover::before {
    left: 100%;
  }
}

// Primary Button
.btn-primary {
  background: linear-gradient(
    135deg,
    rgba(0, 120, 200, 0.3) 0%,
    rgba(0, 100, 180, 0.2) 100%
  );
  color: #66ccff;

  &:hover {
    background: linear-gradient(
      135deg,
      rgba(0, 150, 255, 0.4) 0%,
      rgba(255, 100, 0, 0.3) 100%
    );
    border-color: rgba(0, 150, 255, 0.8);
    box-shadow:
      0 0 20px rgba(0, 150, 255, 0.4),
      0 0 30px rgba(255, 120, 0, 0.2);
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 150, 255, 0.6);
    transform: translateY(-2px);
  }

  &:active {
    transform: translateY(0);
  }
}

// Secondary Button
.btn-secondary {
  background: linear-gradient(
    135deg,
    rgba(0, 100, 180, 0.2) 0%,
    rgba(0, 80, 150, 0.15) 100%
  );
  color: #66ccff;

  &:hover {
    background: linear-gradient(
      135deg,
      rgba(0, 120, 200, 0.3) 0%,
      rgba(255, 100, 0, 0.2) 100%
    );
    border-color: rgba(0, 150, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 150, 255, 0.3);
    color: #fff;
    text-shadow: 0 0 8px rgba(0, 150, 255, 0.5);
  }

  &:active {
    transform: translateY(0);
  }
}

// Stats Form (specific layout for forms in stats apps)
.stats-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
  position: relative;
  z-index: 1;

  @include media-up(md) {
    flex-direction: row;
    align-items: flex-end;
  }
}
