/**
 * SlimBar - Toolbar Styles
 * Zero jQuery, Zero Layout Shift, Under 15KB
 * @version 1.0.0
 */

:root {
  --az-bg: #ffffff;
  --az-fg: #1e293b;
  --az-accent: #4f46e5;
  --az-focus-color: #4f46e5;
  --az-border: #e2e8f0;
  --az-shadow: 0 4px 24px rgba(0, 0, 0, 0.14);
  --az-radius: 12px;
  --az-trigger-size: 48px;
  --az-scale: 100%;
}

/* Font Size Scaling - applies to entire page */
html {
  font-size: var(--az-scale);
}

/* Focus Outline Styles */
.az-focus-active :focus-visible {
  outline: 3px solid var(--az-focus-color, #4f46e5) !important;
  outline-offset: 3px !important;
}

/* Animation Pause Styles */
.az-anim-paused *,
.az-anim-paused *::before,
.az-anim-paused *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Exclude toolbar from animation pause */
.az-anim-paused .az-toolbar,
.az-anim-paused .az-toolbar * {
  animation-duration: 200ms !important;
  transition-duration: 200ms !important;
}

/* Toolbar Container */
.az-toolbar {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--az-fg);
  pointer-events: none;
  width: auto;
  height: auto;
}

.az-toolbar * {
  box-sizing: border-box;
}

/* Position Variants */
.az-position-bottom-right,
.az-position-bottom-left,
.az-position-top-right,
.az-position-top-left {
  /* Ensure toolbar is always visible */
  min-width: 48px;
  min-height: 48px;
}

.az-position-bottom-right {
  bottom: 20px;
  right: 20px;
}

.az-position-bottom-left {
  bottom: 20px;
  left: 20px;
}

.az-position-top-right {
  top: 20px;
  right: 20px;
}

.az-position-top-left {
  top: 20px;
  left: 20px;
}

/* Trigger Button */
.az-trigger {
  width: var(--az-trigger-size);
  height: var(--az-trigger-size);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--az-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  pointer-events: auto;
  position: relative;
  z-index: 10000;
}

.az-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.18);
}

.az-trigger:focus-visible {
  outline: 3px solid var(--az-accent);
  outline-offset: 3px;
}

.az-trigger-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.az-trigger-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

/* Panel */
.az-panel {
  position: absolute;
  width: 280px;
  background: var(--az-bg);
  border-radius: var(--az-radius);
  box-shadow: var(--az-shadow);
  border: 1px solid var(--az-border);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.95) translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

/* Panel positioning based on toolbar position */
.az-position-bottom-right .az-panel {
  bottom: calc(var(--az-trigger-size) + 12px);
  right: 0;
  transform-origin: bottom right;
}

.az-position-bottom-left .az-panel {
  bottom: calc(var(--az-trigger-size) + 12px);
  left: 0;
  transform-origin: bottom left;
}

.az-position-top-right .az-panel {
  top: calc(var(--az-trigger-size) + 12px);
  right: 0;
  transform-origin: top right;
}

.az-position-top-left .az-panel {
  top: calc(var(--az-trigger-size) + 12px);
  left: 0;
  transform-origin: top left;
}

.az-panel-open {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Panel Header */
.az-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--az-border);
}

.az-panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--az-fg);
}

.az-panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--az-fg);
  transition: background-color 0.15s ease;
}

.az-panel-close:hover {
  background-color: #f1f5f9;
}

.az-panel-close:focus-visible {
  outline: 2px solid var(--az-accent);
  outline-offset: 2px;
}

.az-panel-close svg {
  width: 18px;
  height: 18px;
}

/* Controls Container */
.az-controls {
  padding: 12px;
}

/* Control Section */
.az-control-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--az-border);
}

.az-control-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

/* Control Header */
.az-control-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.az-control-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--az-accent);
}

.az-control-icon svg {
  width: 100%;
  height: 100%;
}

.az-control-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--az-fg);
}

/* Contrast Options */
.az-contrast-options {
  display: flex;
  gap: 8px;
}

.az-contrast-option {
  flex: 1;
  padding: 10px 8px;
  border: 2px solid var(--az-border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.az-contrast-option:hover {
  border-color: var(--az-accent);
}

.az-contrast-option:focus-visible {
  outline: 2px solid var(--az-accent);
  outline-offset: 2px;
}

.az-contrast-option[aria-pressed="true"],
.az-contrast-option.az-contrast-active {
  border-color: var(--az-accent);
  background: #eef2ff;
  color: var(--az-accent);
}

.az-contrast-dark-preview {
  background: #000000;
  color: #ffffff;
  border-color: #333;
}

.az-contrast-dark-preview[aria-pressed="true"],
.az-contrast-dark-preview.az-contrast-active {
  border-color: #ffff00;
  background: #000000;
  color: #ffff00;
}

.az-contrast-light-preview {
  background: #ffffff;
  color: #000000;
  border-color: #ccc;
}

.az-contrast-light-preview[aria-pressed="true"],
.az-contrast-light-preview.az-contrast-active {
  border-color: #0000ff;
  background: #ffffff;
  color: #0000ff;
}

/* Font Controls */
.az-font-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.az-font-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--az-border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--az-fg);
  transition: all 0.15s ease;
}

.az-font-btn:hover:not(:disabled) {
  border-color: var(--az-accent);
  background: #f8fafc;
}

.az-font-btn:focus-visible {
  outline: 2px solid var(--az-accent);
  outline-offset: 2px;
}

.az-font-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.az-font-btn svg {
  width: 20px;
  height: 20px;
}

.az-font-display {
  font-size: 18px;
  font-weight: 700;
  color: var(--az-accent);
  min-width: 60px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Control Row (for Focus and Animation) */
.az-control-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.az-control-row:hover {
  background-color: #f8fafc;
  border-color: var(--az-border);
}

.az-control-row:focus-visible {
  outline: 2px solid var(--az-accent);
  outline-offset: 2px;
}

.az-control-row[aria-pressed="true"] {
  background-color: #eef2ff;
  border-color: var(--az-accent);
}

.az-control-row .az-control-icon {
  width: 20px;
  height: 20px;
}

.az-control-row .az-control-label {
  flex: 1;
  font-weight: 500;
}

.az-control-indicator {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  padding: 2px 8px;
  background: #f1f5f9;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.az-control-row[aria-pressed="true"] .az-control-indicator {
  background: var(--az-accent);
  color: #ffffff;
}

.az-control-status {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #22c55e;
}

.az-control-status svg {
  width: 100%;
  height: 100%;
}

/* Reset Section */
.az-reset-section {
  padding-top: 8px;
  margin-top: 8px;
}

.az-reset-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--az-border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--az-fg);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.az-reset-btn:hover {
  border-color: #ef4444;
  background: #fef2f2;
  color: #ef4444;
}

.az-reset-btn:focus-visible {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
}

.az-reset-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.az-reset-icon svg {
  width: 100%;
  height: 100%;
}

/* Live Region */
.az-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* RTL Support */
[dir="rtl"] .az-position-bottom-right .az-panel {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

[dir="rtl"] .az-position-bottom-left .az-panel {
  left: auto;
  right: 0;
  transform-origin: bottom right;
}

[dir="rtl"] .az-position-top-right .az-panel {
  right: auto;
  left: 0;
  transform-origin: top left;
}

[dir="rtl"] .az-position-top-left .az-panel {
  left: auto;
  right: 0;
  transform-origin: top right;
}

[dir="rtl"] .az-control-row {
  text-align: right;
}

[dir="rtl"] .az-contrast-options {
  flex-direction: row-reverse;
}

[dir="rtl"] .az-font-controls {
  flex-direction: row-reverse;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
  .az-panel {
    width: calc(100vw - 40px);
    max-width: 300px;
  }
  
  .az-position-bottom-right,
  .az-position-bottom-left {
    bottom: 16px;
  }
  
  .az-position-top-right,
  .az-position-top-left {
    top: 16px;
  }
  
  .az-position-bottom-right,
  .az-position-top-right {
    right: 16px;
  }
  
  .az-position-bottom-left,
  .az-position-top-left {
    left: 16px;
  }
}

/* Ensure toolbar is on top of common z-indexes */
.az-toolbar {
  z-index: 2147483647;
}

/* Hide when printing */
@media print {
  .az-toolbar {
    display: none !important;
  }
}
