/**
 * Reusable UI Components
 *
 * Drawers, modals, alerts, cards, and other patterns used across pages.
 * Extracted from beauty.css and pages.css for CSP compliance and reusability.
 */

/* ============================================================================
 * DRAWERS - Slide-in panels from right edge
 * ============================================================================ */

/* Base drawer - slides in from right */
.drawer {
  position: fixed;
  top: 3rem;
  bottom: 3rem;
  right: 0;
  width: 450px;
  height: auto;
  background: var(--color-background);
  border-left: 1px solid var(--color-border);
  box-shadow: -2px 0 10px var(--color-shadow);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  border-radius: 0.5rem 0 0 0.5rem;
}

.drawer.open {
  transform: translateX(0);
}

/* Wider drawer variant */
.drawer-wide {
  width: 480px;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-background-header);
  flex-shrink: 0;
}

.drawer-header h3 {
  margin: 0;
  font-size: 1rem;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.drawer-footer {
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Close button for drawers */
.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover {
  background-color: var(--color-editable-background);
  border-radius: 0.25rem;
}

/* ============================================================================
 * MODALS - Centered overlay dialogs
 * ============================================================================ */

/* Modal backdrop - covers screen */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Hidden state for toggle-able modals */
.modal-backdrop.hidden {
  display: none;
}

/* Modal content box */
.modal-box {
  background: var(--color-background);
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 6px var(--color-shadow);
}

.modal-box-wide {
  max-width: 800px;
}

.modal-box h3 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.modal-box h3.error-title {
  color: var(--color-danger);
}

/* Modal footer with buttons */
.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Single button (right-aligned) */
.modal-footer-single {
  margin-top: 1.5rem;
  text-align: right;
}

/* Technical details in error modals */
.modal-details {
  margin-top: 1rem;
}

.modal-details summary {
  cursor: pointer;
}

.modal-details pre {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--color-background-subtle);
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.875rem;
}

/* ============================================================================
 * ALERTS - Informational banners
 * ============================================================================ */

.alert-info {
  background-color: var(--color-warning-background);
  color: var(--color-warning-text);
  border-left: 4px solid var(--color-warning-border);
  padding: var(--space-md);
  border-radius: 0.25rem;
  margin-bottom: 1rem;
}

.alert-info a {
  color: var(--color-warning-text);
  text-decoration: underline;
  font-weight: bold;
}

.alert-warning {
  background-color: var(--color-warning-background);
  border: 1px solid var(--color-warning-border);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.alert-warning pre {
  background: var(--color-background-paper);
  padding: 0.5rem;
  border-radius: 4px;
  overflow-x: auto;
}

/* Info banner - left-bordered callout */
.info-banner {
  background: var(--color-greenbar-alternate);
  border-left: 4px solid var(--color-primary);
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
}

/* ============================================================================
 * CARDS - Content containers
 * ============================================================================ */

/* Basic card */
.card {
  background-color: var(--color-background-paper);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.card-header h3 {
  margin: 0;
}

.card-body {
  /* Content area */
}

.card-footer {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}


/* ============================================================================
 * RADIO GROUP - Segmented control with ARIA radiogroup semantics
 * ============================================================================ */

.radio-group {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.radio-group [role="radio"] {
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-right: 1px solid var(--color-border);
  background: var(--color-background);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  color: var(--color-text);
}

.radio-group [role="radio"]:last-child {
  border-right: none;
}

.radio-group [role="radio"][aria-checked="true"] {
  background: var(--color-primary);
  color: var(--color-on-filled);
}

.radio-group [role="radio"]:hover:not([aria-checked="true"]) {
  background: var(--color-background-header);
}

/* ============================================================================
 * BADGES - Small status indicators
 * ============================================================================ */

.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
}

.badge-success {
  background-color: var(--color-badge-success-background);
  color: var(--color-badge-success-text);
}

.badge-danger {
  background-color: var(--color-badge-danger-background);
  color: var(--color-badge-danger-text);
}

.badge-warning {
  background-color: var(--color-warning-background);
  color: var(--color-warning-text);
}

/* ============================================================================
 * ACTION BOX - Prompts user for input
 * ============================================================================ */

.action-box {
  background-color: var(--color-secondary-light);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  border-radius: 4px;
}

/* ============================================================================
 * EMPTY STATE - When no data to display
 * ============================================================================ */

.empty-state {
  text-align: center;
  color: var(--color-text);
  opacity: 0.7;
  padding: 2rem;
}

/* ============================================================================
 * ACCOUNT/ITEM LISTS - Selectable lists in modals
 * ============================================================================ */

.radio-list-vertical label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.radio-list-vertical label:hover {
  background-color: var(--color-greenbar-alternate);
}

.radio-list-vertical-inline-input {
  margin-left: 1.75rem;
  margin-top: var(--space-sm);
  margin-bottom: var(--space-md);
}

/* ============================================================================
 * HINT TEXT - Secondary explanatory text
 * ============================================================================ */

.hint-text {
  color: var(--color-text);
  opacity: 0.7;
  font-size: 0.875rem;
}

/* ============================================================================
 * ICONS - Unicode character icons with consistent sizing
 * ============================================================================ */

.icon {
  font-size: 1.25rem;
  line-height: 1;
  vertical-align: middle;
}

.icon-sm {
  font-size: 1rem;
}

.icon-lg {
  font-size: 1.5rem;
}

/* ============================================================================
 * HIGHLIGHT ANIMATION - Flash effect for newly added elements
 * Uses box-shadow instead of background to work with tables that have
 * background styling (like .greenbar)
 * ============================================================================ */

.highlight-new {
  animation: highlight-flash 1.5s ease-out;
}

@keyframes highlight-flash {
  0% { box-shadow: inset 0 0 0 100px var(--color-highlight); }
  100% { box-shadow: inset 0 0 0 100px transparent; }
}
