/* ============================================================
   TALKBACK — COMPONENT STYLES
   ============================================================
   File: css/components.css
   Purpose: Reusable UI components for the entire application.
   
   Load order:
   1. variables.css
   2. reset.css
   3. components.css   ← THIS FILE
   4. layout.css
   5. app.css
   
   COMPONENTS INDEX:
   1.  Buttons
   2.  Inputs & Forms
   3.  Cards
   4.  Avatar
   5.  Badge / Status
   6.  User Row
   7.  Channel Row
   8.  Top Bar
   9.  Bottom Navigation
   10. Modal
   11. Drawer
   12. Toast
   13. Confirmation Dialog
   14. Empty State
   15. Loading / Skeleton
   16. PTT Button
   17. Audio Activity Indicator
   18. Speaker Display
   19. Emergency Panel
   20. Map Marker
   21. Dropdown Menu
   22. Tabs
   23. Toggle Switch
   24. Search Bar
   ============================================================ */


/* ============================================================
   1. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-primary);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: var(--transition-colors),
              box-shadow var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Button Icons */
.btn__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.btn__icon--left {
  margin-right: var(--space-1);
}

.btn__icon--right {
  margin-left: var(--space-1);
}

/* --- Sizes --- */

.btn--xs {
  padding: 4px 10px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  gap: var(--space-1);
}

.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}

.btn--md {
  padding: 10px var(--space-6);
  font-size: var(--text-base);
}

.btn--lg {
  padding: var(--space-3) var(--space-8);
  font-size: var(--text-md);
  border-radius: var(--radius-xl);
}

.btn--xl {
  padding: var(--space-4) var(--space-10);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
}

.btn--full {
  width: 100%;
}

/* --- Variants --- */

.btn--primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-active);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn--outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn--outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.btn--danger {
  background: var(--danger);
  color: var(--text-on-danger);
  border-color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  box-shadow: var(--shadow-danger);
  transform: translateY(-1px);
}

.btn--success {
  background: var(--success);
  color: var(--text-on-success);
  border-color: var(--success);
}

.btn--success:hover:not(:disabled) {
  background: var(--success-hover);
  border-color: var(--success-hover);
  box-shadow: var(--shadow-success);
  transform: translateY(-1px);
}

/* --- Icon-only Button --- */

.btn--icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
}

.btn--icon-sm {
  padding: var(--space-1);
  min-width: 32px;
  min-height: 32px;
}

.btn--icon-lg {
  padding: var(--space-3);
  min-width: 52px;
  min-height: 52px;
}

/* --- Loading State --- */

.btn--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn--loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}


/* ============================================================
   2. INPUTS & FORMS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.form-label--required::after {
  content: ' *';
  color: var(--danger);
}

.form-input {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--input-padding-x);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  color: var(--input-text);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.form-input:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.form-input:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.form-input--error {
  border-color: var(--border-error);
}

.form-input--error:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.form-input--sm {
  height: var(--input-height-sm);
  font-size: var(--text-sm);
  padding: 0 var(--space-3);
}

.form-input--lg {
  height: var(--input-height-lg);
  font-size: var(--text-lg);
}

/* Textarea */
.form-textarea {
  width: 100%;
  min-height: 100px;
  padding: var(--space-3) var(--input-padding-x);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  color: var(--input-text);
  font-size: var(--text-base);
  resize: vertical;
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.form-textarea:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Select */
.form-select {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--space-10) 0 var(--input-padding-x);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  color: var(--input-text);
  font-size: var(--text-base);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239898a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.form-select:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Helper / Error Text */
.form-helper {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: var(--leading-normal);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  line-height: var(--leading-normal);
}

/* Input with Icon */
.input-with-icon {
  position: relative;
}

.input-with-icon .form-input {
  padding-left: 44px;
}

.input-with-icon__icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ============================================================
   3. CARDS
   ============================================================ */

.card {
  background: var(--card-bg, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default);
}

.card--interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card--interactive:active {
  transform: translateY(0);
}

.card--flat {
  border: none;
  background: var(--bg-tertiary);
}

.card--accent {
  border-color: var(--accent-border);
}

.card--danger {
  border-color: var(--danger-border);
}

.card__header {
  padding: var(--card-padding);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card__body {
  padding: var(--card-padding);
}

.card__footer {
  padding: var(--card-padding);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Compact Card */
.card--compact .card__header,
.card--compact .card__body,
.card--compact .card__footer {
  padding: var(--card-padding-compact);
}


/* ============================================================
   4. AVATAR
   ============================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-weight: var(--weight-semibold);
  color: white;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.avatar--xs {
  width: var(--avatar-xs);
  height: var(--avatar-xs);
  font-size: 10px;
}

.avatar--sm {
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  font-size: var(--text-xs);
}

.avatar--md {
  width: var(--avatar-md);
  height: var(--avatar-md);
  font-size: var(--text-sm);
}

.avatar--lg {
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  font-size: var(--text-md);
}

.avatar--xl {
  width: var(--avatar-xl);
  height: var(--avatar-xl);
  font-size: var(--text-xl);
}

.avatar--2xl {
  width: var(--avatar-2xl);
  height: var(--avatar-2xl);
  font-size: var(--text-2xl);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Avatar with presence dot */
.avatar-with-presence {
  position: relative;
  display: inline-flex;
}

.avatar-with-presence__dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-primary);
}

.avatar-with-presence__dot--available {
  background: var(--presence-available);
}

.avatar-with-presence__dot--busy {
  background: var(--presence-busy);
}

.avatar-with-presence__dot--dnd {
  background: var(--presence-dnd);
}

.avatar-with-presence__dot--speaking {
  background: var(--presence-speaking);
  animation: presencePulse 1.5s ease infinite;
}

.avatar-with-presence__dot--offline {
  background: var(--presence-offline);
}

@keyframes presencePulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--presence-speaking); }
  50% { box-shadow: 0 0 0 4px transparent; }
}

/* Avatar Group */
.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  border: 2px solid var(--bg-primary);
  margin-left: -8px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}


/* ============================================================
   5. BADGE / STATUS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info-border);
}

.badge--neutral {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Status Dot inside Badge */
.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.badge__dot--live {
  background: var(--success);
  animation: dotPulse 2s ease infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}


/* ============================================================
   6. USER ROW
   ============================================================ */

.user-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  transition: background var(--duration-fast) var(--ease-default);
  cursor: pointer;
  min-height: var(--touch-target-min);
}

.user-row:hover {
  background: var(--surface-hover);
}

.user-row:active {
  background: var(--surface-active);
}

.user-row__info {
  flex: 1;
  min-width: 0;
}

.user-row__name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row__meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}


/* ============================================================
   7. CHANNEL ROW
   ============================================================ */

.channel-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  transition: background var(--duration-fast) var(--ease-default);
  cursor: pointer;
  min-height: var(--touch-target-min);
}

.channel-row:hover {
  background: var(--surface-hover);
}

.channel-row:active {
  background: var(--surface-active);
}

.channel-row--active {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

.channel-row__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.channel-row--active .channel-row__icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.channel-row__info {
  flex: 1;
  min-width: 0;
}

.channel-row__name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-row__meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.channel-row__speaker {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.channel-row__member-count {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}


/* ============================================================
   8. TOP BAR
   ============================================================ */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--nav-border);
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  transition: background-color var(--duration-normal) var(--ease-default);
}

.top-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.top-bar__center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.top-bar__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 768px) {
  .top-bar {
    height: var(--nav-height-mobile);
  }
}


/* ============================================================
   9. BOTTOM NAVIGATION
   ============================================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--nav-border);
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-2);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: var(--weight-medium);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  transition: color var(--duration-fast) var(--ease-default);
  cursor: pointer;
  text-decoration: none;
}

.bottom-nav__item:hover {
  color: var(--text-secondary);
}

.bottom-nav__item--active {
  color: var(--accent);
}

.bottom-nav__icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__label {
  white-space: nowrap;
}

/* Notification dot on bottom nav */
.bottom-nav__item--has-notification .bottom-nav__icon {
  position: relative;
}

.bottom-nav__item--has-notification .bottom-nav__icon::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--danger);
  border: 2px solid var(--bg-primary);
}


/* ============================================================
   10. MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-default),
              visibility var(--duration-normal) var(--ease-default);
}

.modal-overlay--active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: var(--z-modal);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-out);
}

.modal-overlay--active .modal {
  transform: scale(1) translateY(0);
}

.modal__header {
  padding: var(--space-6) var(--space-6) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.modal__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  transition: var(--transition-colors);
  flex-shrink: 0;
}

.modal__close:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.modal__body {
  padding: 0 var(--space-6) var(--space-6);
}

.modal__footer {
  padding: var(--space-4) var(--space-6) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

@media (max-width: 480px) {
  .modal {
    max-width: 100%;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 85vh;
    align-self: flex-end;
  }
}


/* ============================================================
   11. DRAWER
   ============================================================ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-drawer);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-default),
              visibility var(--duration-normal) var(--ease-default);
}

.drawer-overlay--active {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  max-width: 85vw;
  background: var(--surface-elevated);
  border-right: 1px solid var(--border);
  z-index: var(--z-drawer);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--duration-normal) var(--ease-out);
}

.drawer--right {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
}

.drawer--active {
  transform: translateX(0);
}

.drawer__header {
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--nav-height);
}

.drawer__body {
  padding: var(--space-4);
}


/* ============================================================
   12. TOAST
   ============================================================ */

.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-4));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 400px;
  width: calc(100% - var(--space-8));
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  border: 1px solid var(--toast-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  pointer-events: all;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.toast--success .toast__icon {
  color: var(--success);
}

.toast--error .toast__icon {
  color: var(--danger);
}

.toast--warning .toast__icon {
  color: var(--warning);
}

.toast--info .toast__icon {
  color: var(--info);
}

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast__message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-snug);
}

.toast__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: var(--transition-colors);
}

.toast__close:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

@media (max-width: 480px) {
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    max-width: 100%;
    width: auto;
  }
}


/* ============================================================
   13. CONFIRMATION DIALOG
   ============================================================ */

.confirm-dialog {
  text-align: center;
}

.confirm-dialog__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}

.confirm-dialog__icon--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-dialog__icon--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.confirm-dialog__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.confirm-dialog__message {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

.confirm-dialog__actions {
  display: flex;
  gap: var(--space-3);
}

.confirm-dialog__actions .btn {
  flex: 1;
}


/* ============================================================
   14. EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  min-height: 300px;
}

.empty-state__icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-2xl);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
  color: var(--text-tertiary);
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state__message {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 360px;
  margin-bottom: var(--space-6);
}


/* ============================================================
   15. LOADING / SKELETON
   ============================================================ */

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spinnerRotate 0.7s linear infinite;
}

.spinner--sm {
  width: 16px;
  height: 16px;
}

.spinner--lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

@keyframes spinnerRotate {
  to { transform: rotate(360deg); }
}

/* Full Page Loader */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  gap: var(--space-4);
  padding: var(--space-6);
}

.page-loader__text {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
}

/* Skeleton */
.skeleton {
  background: var(--skeleton-base);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--skeleton-shine) 50%,
    transparent 100%
  );
  animation: skeletonShimmer 1.5s ease infinite;
}

@keyframes skeletonShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton--text {
  height: 14px;
  width: 80%;
  border-radius: var(--radius-xs);
}

.skeleton--text-sm {
  height: 12px;
  width: 60%;
}

.skeleton--title {
  height: 20px;
  width: 50%;
  border-radius: var(--radius-sm);
}

.skeleton--avatar {
  border-radius: var(--radius-full);
}

.skeleton--card {
  height: 120px;
  border-radius: var(--radius-2xl);
}

.skeleton--btn {
  height: var(--input-height);
  border-radius: var(--radius-lg);
  width: 120px;
}


/* ============================================================
   16. PTT BUTTON
   ============================================================ */

.ptt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.ptt__ring {
  width: var(--ptt-ring-size);
  height: var(--ptt-ring-size);
  border-radius: var(--radius-full);
  border: 2px solid var(--ptt-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.ptt__button {
  width: var(--ptt-size);
  height: var(--ptt-size);
  border-radius: var(--radius-full);
  background: var(--ptt-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: background var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
  touch-action: none;
}

.ptt__button:hover {
  transform: scale(1.03);
}

.ptt__button:active,
.ptt--active .ptt__button {
  transform: scale(0.96);
  background: var(--ptt-bg-active);
}

.ptt__button-icon {
  color: white;
  pointer-events: none;
}

/* PTT Active State */
.ptt--active .ptt__ring {
  border-color: var(--ptt-ring-active);
  box-shadow: 0 0 0 4px var(--ptt-glow);
  animation: pttActivePulse 1.5s ease infinite;
}

@keyframes pttActivePulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--ptt-glow); }
  50% { box-shadow: 0 0 0 12px transparent; }
}

/* PTT Denied State */
.ptt--denied .ptt__button {
  background: var(--ptt-bg-denied);
  box-shadow: var(--shadow-danger);
}

.ptt--denied .ptt__ring {
  border-color: var(--danger-border);
}

/* PTT Connecting State */
.ptt--connecting .ptt__button {
  opacity: 0.7;
  animation: pttConnecting 1s ease infinite;
}

@keyframes pttConnecting {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* PTT Label */
.ptt__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-tertiary);
}

.ptt--active .ptt__label {
  color: var(--accent);
}

/* Large PTT */
.ptt--large .ptt__ring {
  width: var(--ptt-ring-size-large);
  height: var(--ptt-ring-size-large);
}

.ptt--large .ptt__button {
  width: var(--ptt-size-large);
  height: var(--ptt-size-large);
}


/* ============================================================
   17. AUDIO ACTIVITY INDICATOR
   ============================================================ */

.audio-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 18px;
}

.audio-bars__bar {
  width: 3px;
  border-radius: var(--radius-full);
  background: var(--accent);
  animation: audioBar 0.8s ease-in-out infinite alternate;
}

.audio-bars__bar:nth-child(1) { height: 6px; animation-delay: 0s; }
.audio-bars__bar:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.audio-bars__bar:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.audio-bars__bar:nth-child(4) { height: 10px; animation-delay: 0.15s; }
.audio-bars__bar:nth-child(5) { height: 14px; animation-delay: 0.05s; }

@keyframes audioBar {
  0% { transform: scaleY(0.3); opacity: 0.5; }
  100% { transform: scaleY(1); opacity: 1; }
}

/* Static version (not animating) */
.audio-bars--static .audio-bars__bar {
  animation: none;
  opacity: 0.3;
}


/* ============================================================
   18. SPEAKER DISPLAY
   ============================================================ */

.speaker-display {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xl);
}

.speaker-display__avatar {
  flex-shrink: 0;
}

.speaker-display__info {
  flex: 1;
  min-width: 0;
}

.speaker-display__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.speaker-display__status {
  font-size: var(--text-xs);
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.speaker-display__bars {
  flex-shrink: 0;
}


/* ============================================================
   19. EMERGENCY PANEL
   ============================================================ */

.emergency-panel {
  background: var(--danger-soft);
  border: 2px solid var(--danger-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  text-align: center;
}

.emergency-panel__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  animation: emergencyPulse 1.5s ease infinite;
}

@keyframes emergencyPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--emergency-glow); }
  50% { box-shadow: 0 0 0 16px transparent; }
}

.emergency-panel__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--danger);
  margin-bottom: var(--space-2);
}

.emergency-panel__message {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

.emergency-panel__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}


/* ============================================================
   20. MAP MARKER
   ============================================================ */

.map-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -100%);
}

.map-marker__dot {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: white;
  box-shadow: var(--shadow-md);
  border: 2px solid white;
}

.map-marker__label {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  background: var(--surface-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}


/* ============================================================
   21. DROPDOWN MENU
   ============================================================ */

.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 180px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.98);
  transition: opacity var(--duration-fast) var(--ease-default),
              visibility var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default);
}

.dropdown__menu--active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
  min-height: var(--touch-target-min);
}

.dropdown__item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.dropdown__item--danger {
  color: var(--danger);
}

.dropdown__item--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}

.dropdown__item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ============================================================
   22. TABS
   ============================================================ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab__count {
  font-size: var(--text-xs);
  background: var(--bg-tertiary);
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-weight: var(--weight-semibold);
}

.tab--active .tab__count {
  background: var(--accent-soft);
  color: var(--accent);
}


/* ============================================================
   23. TOGGLE SWITCH
   ============================================================ */

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: var(--space-3);
  min-height: var(--touch-target-min);
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-quaternary);
  transition: background var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
  position: relative;
}

.toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: white;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-default);
}

.toggle__input:checked + .toggle__track {
  background: var(--accent);
}

.toggle__input:checked + .toggle__track .toggle__thumb {
  transform: translateX(20px);
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}


/* ============================================================
   24. SEARCH BAR
   ============================================================ */

.search-bar {
  position: relative;
  width: 100%;
}

.search-bar__input {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--input-padding-x) 0 44px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-full);
  color: var(--input-text);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.search-bar__input:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.search-bar__icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-bar__clear {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
}

.search-bar__clear--visible {
  opacity: 1;
  visibility: visible;
}

.search-bar__clear:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}