/**
 * Material Design 3 Components Specification
 * Pure CSS implementations adhering strictly to MD3 tokens, state layers, and shapes
 */

/* ==========================================================================
   Buttons (Filled, Tonal, Outlined, Text, Elevated)
   ========================================================================== */
.md3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  box-sizing: border-box;
  min-width: 64px;
  height: 40px;
  padding: 0 24px;
  border: none;
  outline: none;
  cursor: pointer;
  user-select: none;
  font: var(--md-sys-typescale-label-large);
  border-radius: var(--md-sys-shape-corner-full);
  transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}

.md3-btn .material-symbols-outlined {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

/* State Layer overlay */
.md3-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-color: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  pointer-events: none;
}
.md3-btn:hover::before { opacity: var(--md-sys-state-hover-opacity); }
.md3-btn:focus-visible::before { opacity: var(--md-sys-state-focus-opacity); }
.md3-btn:active::before { opacity: var(--md-sys-state-pressed-opacity); }

/* Filled Button */
.md3-btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.md3-btn-filled:hover {
  box-shadow: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30);
}

/* Filled Tonal Button */
.md3-btn-tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.md3-btn-tonal:hover {
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Outlined Button */
.md3-btn-outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
  padding: 0 23px;
}
.md3-btn-outlined:focus-visible {
  border-color: var(--md-sys-color-primary);
}

/* Text Button */
.md3-btn-text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  padding: 0 12px;
}

/* Elevated Button */
.md3-btn-elevated {
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-primary);
  box-shadow: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30);
}
.md3-btn-elevated:hover {
  box-shadow: 0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30);
}

/* ==========================================================================
   Icon Buttons
   ========================================================================== */
.md3-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  outline: none;
  transition: color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  overflow: hidden;
}
.md3-icon-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-color: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  pointer-events: none;
}
.md3-icon-btn:hover::before { opacity: var(--md-sys-state-hover-opacity); }
.md3-icon-btn:focus-visible::before { opacity: var(--md-sys-state-focus-opacity); }
.md3-icon-btn:active::before { opacity: var(--md-sys-state-pressed-opacity); }

.md3-icon-btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.md3-icon-btn-tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* ==========================================================================
   Cards (Elevated, Filled, Outlined)
   ========================================================================== */
.md3-card {
  position: relative;
  border-radius: var(--md-sys-shape-corner-large);
  padding: 24px;
  box-sizing: border-box;
  transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

/* Outlined Card (default in MD3 for clear boundaries) */
.md3-card-outlined {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

/* Filled Card */
.md3-card-filled {
  background-color: var(--md-sys-color-surface-container-highest);
  border: none;
}

/* Elevated Card */
.md3-card-elevated {
  background-color: var(--md-sys-color-surface-container-low);
  border: none;
  box-shadow: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.20);
}

/* ==========================================================================
   Chips (Assist, Filter, Suggestion)
   ========================================================================== */
.md3-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.md3-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-large);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
              border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.md3-chip .material-symbols-outlined {
  font-size: 18px;
  color: var(--md-sys-color-primary);
}

.md3-chip:hover {
  background-color: var(--md-sys-color-surface-container-low);
}

.md3-chip.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}
.md3-chip.active .material-symbols-outlined {
  color: var(--md-sys-color-on-secondary-container);
}

/* ==========================================================================
   Segmented Buttons
   ========================================================================== */
.md3-segmented-button-group {
  display: inline-flex;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  overflow: hidden;
  height: 40px;
  background-color: var(--md-sys-color-surface);
}

.md3-segmented-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-large);
  cursor: pointer;
  border-right: 1px solid var(--md-sys-color-outline);
  transition: background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  position: relative;
}
.md3-segmented-button:last-child {
  border-right: none;
}
.md3-segmented-button:hover {
  background-color: var(--md-sys-color-surface-container-high);
}
.md3-segmented-button.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

/* ==========================================================================
   Tabs (Primary MD3 Tabs)
   ========================================================================== */
.md3-tabs-primary {
  display: flex;
  position: relative;
  background-color: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  overflow-x: auto;
  scrollbar-width: none;
}
.md3-tabs-primary::-webkit-scrollbar {
  display: none;
}

.md3-tab {
  flex: 1;
  min-width: 120px;
  max-width: 360px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-title-small);
  cursor: pointer;
  position: relative;
  transition: color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}
.md3-tab:hover {
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
}
.md3-tab.active {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}
.md3-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background-color: var(--md-sys-color-primary);
}

/* ==========================================================================
   Alert Callouts (Note, Tip, Important, Warning)
   ========================================================================== */
.md3-callout {
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 16px 20px;
  margin: 16px 0;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  font: var(--md-sys-typescale-body-medium);
}
.md3-callout .material-symbols-outlined {
  font-size: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}
.md3-callout-title {
  font: var(--md-sys-typescale-title-small);
  margin-bottom: 4px;
  font-weight: 700;
}
.md3-callout-note {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-left: 4px solid var(--md-sys-color-primary);
}
.md3-callout-note .material-symbols-outlined {
  color: var(--md-sys-color-primary);
}
.md3-callout-tip {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-left: 4px solid var(--md-sys-color-secondary);
}
.md3-callout-tip .material-symbols-outlined {
  color: var(--md-sys-color-secondary);
}
.md3-callout-important {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  border-left: 4px solid var(--md-sys-color-tertiary);
}
.md3-callout-important .material-symbols-outlined {
  color: var(--md-sys-color-tertiary);
}
.md3-callout-warning {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-left: 4px solid var(--md-sys-color-error);
}
.md3-callout-warning .material-symbols-outlined {
  color: var(--md-sys-color-error);
}

/* ==========================================================================
   Badges
   ========================================================================== */
.md3-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-small);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.md3-badge-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.md3-badge-tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.md3-badge-tertiary {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}
