/* ==========================================================================
   Pulse Analytics - Base Styles & Reset
   ==========================================================================
   Global reset, base typography, scrollbars, selection, form defaults.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Google Fonts Import
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   CSS Reset / Normalize
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  tab-size: 4;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-app);
  height: 100%;
  overflow: hidden;
}

/* Remove default list styles */
ul, ol {
  list-style: none;
}

/* Media defaults */
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

/* Table defaults */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Remove built-in form typography */
button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

button,
select {
  text-transform: none;
}

button,
[type='button'],
[type='reset'],
[type='submit'] {
  -webkit-appearance: button;
  appearance: button;
  cursor: pointer;
  background: none;
  border: none;
}

/* Remove inner border and padding in Firefox */
::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

/* Remove outline for non-keyboard focus */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Remove textarea resize handle, allow vertical only */
textarea {
  resize: vertical;
}

/* Remove number input spinners */
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type='number'] {
  -moz-appearance: textfield;
}

/* Remove search input styling */
input[type='search']::-webkit-search-decoration,
input[type='search']::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Placeholder styling */
::placeholder {
  color: var(--text-placeholder);
  opacity: 1;
}

/* Hidden utility */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Scrollbar Styling
   -------------------------------------------------------------------------- */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-gray-300);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-gray-400);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-gray-300) transparent;
}

/* Sidebar dark scrollbar */
.sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

.sidebar {
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* --------------------------------------------------------------------------
   Selection
   -------------------------------------------------------------------------- */
::selection {
  background-color: var(--color-indigo-200);
  color: var(--color-indigo-900);
}

::-moz-selection {
  background-color: var(--color-indigo-200);
  color: var(--color-indigo-900);
}

/* --------------------------------------------------------------------------
   Base Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

h5 {
  font-size: var(--text-md);
}

h6 {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
}

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

p:last-child {
  margin-bottom: 0;
}

small {
  font-size: var(--text-xs);
}

strong, b {
  font-weight: var(--font-semibold);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--bg-muted);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
  color: var(--color-indigo-700);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-gray-900);
  color: var(--color-gray-100);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-6) 0;
}

/* --------------------------------------------------------------------------
   Link Defaults
   -------------------------------------------------------------------------- */
a {
  color: var(--text-link);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--text-link-hover);
}

a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Form Element Defaults
   -------------------------------------------------------------------------- */
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-1-5);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-red-600);
  margin-top: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--color-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  transition: var(--transition-fast);
  appearance: none;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-placeholder);
}

/* Input sizes */
.form-input--sm {
  padding: var(--space-1-5) var(--space-2-5);
  font-size: var(--text-sm);
}

.form-input--lg {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-md);
}

/* Input states */
.form-input--error,
.form-select--error,
.form-textarea--error {
  border-color: var(--border-error);
}

.form-input--error:focus,
.form-select--error:focus,
.form-textarea--error:focus {
  box-shadow: var(--shadow-focus-error);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background-color: var(--color-gray-50);
  color: var(--text-disabled);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 0 1 .708 0L8 8.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  padding-right: var(--space-10);
}

/* Textarea */
.form-textarea {
  min-height: 100px;
  line-height: var(--leading-relaxed);
}

/* Checkbox & Radio base */
.form-checkbox,
.form-radio {
  width: 1rem;
  height: 1rem;
  color: var(--color-primary);
  border: 1.5px solid var(--border-strong);
  background-color: var(--color-white);
  transition: var(--transition-fast);
  cursor: pointer;
  flex-shrink: 0;
}

.form-checkbox {
  border-radius: var(--radius-sm);
}

.form-radio {
  border-radius: var(--radius-full);
}

.form-checkbox:checked,
.form-radio:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Form group */
.form-group {
  margin-bottom: var(--space-5);
}

.form-row {
  display: grid;
  gap: var(--space-5);
}

.form-row--2 {
  grid-template-columns: repeat(2, 1fr);
}

.form-row--3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 640px) {
  .form-row--2,
  .form-row--3 {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.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;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-muted {
  color: var(--text-tertiary);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

.font-medium {
  font-weight: var(--font-medium);
}

.font-semibold {
  font-weight: var(--font-semibold);
}
