/*
 * Dashboard - Pager dashboard styles
 * QR code display and notification channel management
 */

.pager-dashboard {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--pico-spacing) * 2) var(--pico-spacing);
}

/* --- QR Code Hero Section --- */

.qr-hero {
  text-align: center;
  margin-bottom: calc(var(--pico-spacing) * 2.5);
}

.qr-card {
  display: inline-block;
  padding: var(--pico-spacing);
  margin: 0;
  border-radius: var(--pico-border-radius);
  box-shadow:
    0 0 0 1px rgba(255, 176, 0, 0.1),
    0 0 60px rgba(255, 176, 0, 0.15);
  transition: box-shadow 0.3s ease;
}

.qr-card:hover {
  box-shadow:
    0 0 0 1px rgba(255, 176, 0, 0.2),
    0 0 80px rgba(255, 176, 0, 0.25);
}

.qr-card svg {
  display: block;
  width: 180px;
  height: 180px;
}

.qr-hint {
  margin-top: var(--pico-spacing);
  margin-bottom: 0.5em;
  color: var(--pico-muted-color);
  font-size: 0.9rem;
}

.qr-actions {
  margin: 0;
}

.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.85rem;
  color: var(--pico-primary);
  text-decoration: none;
  padding: 0.4em 0.8em;
  border-radius: var(--pico-border-radius);
  transition: background 0.15s ease, color 0.15s ease;
}

.pdf-link:hover {
  background: rgba(255, 176, 0, 0.1);
  color: var(--pico-primary-hover);
}

.pdf-link svg {
  width: 16px;
  height: 16px;
}

/* --- Channels Section --- */

.channels-section {
  text-align: left;
}

.channels-header {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pico-muted-color);
  margin-bottom: var(--pico-spacing);
  display: flex;
  align-items: center;
  gap: var(--pico-spacing);
}

.channels-header::before,
.channels-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--pico-muted-border-color);
}

/* --- Channel Cards Stack --- */

.channels-stack {
  display: flex;
  flex-direction: column;
  gap: calc(var(--pico-spacing) * 0.75);
}

/* --- Channel Card --- */

.channel-card {
  padding: calc(var(--pico-spacing) * 1.25);
  margin: 0;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.channel-card:hover {
  border-color: color-mix(in srgb, var(--pico-muted-border-color) 50%, var(--pico-primary) 50%);
}

/* State modifiers */
.channel-card--active {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.03);
}

.channel-card--active:hover {
  border-color: rgba(34, 197, 94, 0.6);
}

.channel-card--pending {
  border-color: rgba(255, 176, 0, 0.3);
  background: rgba(255, 176, 0, 0.03);
}

/* Native details accordion support */
.channel-card details {
  margin: 0;
}

.channel-card details[open] {
  /* Expanded state styling */
}

.channel-card:has(details[open]) {
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 3px var(--pico-primary-focus);
}

/* Remove default disclosure triangle and Pico's chevron */
.channel-card summary {
  list-style: none;
  cursor: pointer;
}

.channel-card summary::-webkit-details-marker {
  display: none;
}

.channel-card summary::marker {
  display: none;
  content: "";
}

/* Hide Pico CSS chevron (uses ::after pseudo-element) */
.channel-card summary::after {
  display: none !important;
}

/* Delete button positioned absolutely when outside details */
.channel-card {
  position: relative;
}

.channel-card .channel-delete {
  position: absolute;
  top: calc(var(--pico-spacing) * 1.25);
  right: calc(var(--pico-spacing) * 1.25);
  z-index: 10;
}

/* Always show delete button when absolutely positioned */
.channel-card .channel-delete .btn-delete {
  opacity: 0.5;
}

.channel-card .channel-delete .btn-delete:hover,
.channel-card .channel-delete .btn-delete:focus {
  opacity: 1;
}

/* --- Channel Header (icon + info + button in a row) --- */

.channel-header {
  display: flex;
  align-items: center;
  gap: var(--pico-spacing);
}

.channel-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: var(--pico-primary);
}

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

.channel-icon--telegram svg {
  width: 36px;
  height: 36px;
  margin: 2px;
}

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--pico-color);
}

.channel-status {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  margin: 0.2em 0 0 0;
  display: flex;
  align-items: center;
  gap: 0.35em;
  white-space: nowrap;
}

.channel-status--active {
  color: #22c55e;
}

.channel-status--pending {
  color: var(--pico-primary);
}

.status-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Channel identifier (email/username) - displayed prominently */
.channel-identifier {
  display: block;
  font-size: 0.85rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, Monaco, Consolas, monospace;
  color: var(--pico-color);
  margin-top: 0.35em;
  letter-spacing: -0.01em;
  word-break: break-all;
}

/* --- Channel Form (expandable area) --- */

.channel-form {
  margin-top: var(--pico-spacing);
  padding-top: var(--pico-spacing);
  border-top: 1px solid var(--pico-muted-border-color);
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Inline Forms --- */

.inline-form {
  margin: 0;
}

.channel-form .form-row {
  display: flex;
  gap: 0.75em;
  align-items: stretch;
}

/* Email input - must take available space */
.channel-form .form-row input[type="email"] {
  flex: 1 1 100% !important;
  min-width: 0 !important;
  width: auto !important;
  margin: 0 !important;
}

/* Submit button - only as wide as content */
.channel-form .form-row input[type="submit"] {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: max-content !important;
  margin: 0 !important;
  white-space: nowrap;
  padding-inline: 1.5em;
}

/* Mobile: stack everything vertically */
@media (max-width: 480px) {
  .channel-form .form-row {
    flex-direction: column;
    gap: 0.5em;
  }

  .channel-form .form-row input[type="email"],
  .channel-form .form-row input[type="submit"] {
    flex: none !important;
    width: 100% !important;
  }
}

.setup-hint {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  margin: 0 0 var(--pico-spacing) 0;
}

.setup-hint strong {
  color: var(--pico-color);
  font-weight: 500;
}

/* Form error message */
.form-error {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: calc(var(--pico-spacing) * 0.6);
  margin-bottom: var(--pico-spacing);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--pico-border-radius);
  color: #f87171;
  font-size: 0.85rem;
}

.form-error svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Telegram Widget --- */

.telegram-help {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  margin: 0 0 var(--pico-spacing) 0;
}

.telegram-widget {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* --- Channels Prompt (guidance for users) --- */

.channels-prompt {
  display: flex;
  align-items: flex-start;
  gap: 0.75em;
  margin-top: calc(var(--pico-spacing) * 1.5);
  padding: var(--pico-spacing);
  background: rgba(255, 176, 0, 0.05);
  border: 1px solid rgba(255, 176, 0, 0.15);
  border-radius: var(--pico-border-radius);
}

.channels-prompt svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--pico-primary);
  margin-top: 0.1em;
}

.channels-prompt p {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  margin: 0;
  line-height: 1.5;
}

/* --- Delete Button & Popover Confirmation --- */

/*
 * Design philosophy:
 * - Icon-only button, minimal footprint
 * - Nearly invisible until card hover reveals it
 * - Subtle danger indication on button hover
 * - Elegant popover confirmation (not inline clutter)
 */

/* Delete button - icon only, subtle by default */
.btn-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--pico-muted-color);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-delete svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

/* Reveal on card hover */
.channel-card:hover .btn-delete,
.btn-delete:focus {
  opacity: 0.6;
}

/* Button hover - danger state */
.btn-delete:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

.btn-delete:hover svg {
  transform: scale(1.1);
}

/* Button focus */
.btn-delete:focus {
  opacity: 1;
  outline: none;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
}

/* Active state */
.btn-delete:active {
  transform: scale(0.95);
}

/* Keep visible when popover is open */
.delete-popover-wrapper[data-confirm-delete-open-value="true"] .btn-delete {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* --- Popover wrapper --- */
.delete-popover-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* --- Popover --- */
.delete-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  min-width: 180px;
  padding: 12px 14px;
  background: #1a1a24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;

  /* Animation */
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

/* Arrow */
.delete-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 12px;
  width: 10px;
  height: 10px;
  background: #1a1a24;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  transform: rotate(45deg);
}

/* Visible state */
.delete-popover.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Popover content */
.delete-popover-text {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--pico-color);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

/* Confirm button - override Pico's button styles */
.delete-popover .btn-confirm,
.delete-popover .btn-confirm:is(button, input[type="submit"], [role="button"]) {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  color: #fff !important;
  background: #dc2626 !important;
  border: none !important;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  --pico-background-color: #dc2626;
  --pico-border-color: #dc2626;
  --pico-color: #fff;
}

.delete-popover .btn-confirm:hover,
.delete-popover .btn-confirm:is(button, input[type="submit"], [role="button"]):hover {
  background: #ef4444 !important;
  --pico-background-color: #ef4444;
  --pico-border-color: #ef4444;
}

.delete-popover .btn-confirm:focus,
.delete-popover .btn-confirm:is(button, input[type="submit"], [role="button"]):focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4);
}

.delete-popover .btn-confirm:active {
  transform: scale(0.98);
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .btn-delete {
    opacity: 0.5;
  }

  .delete-popover {
    right: -8px;
    min-width: 160px;
  }
}
