/* ============================================================
   ALERT SYSTEM — Self-contained styles (namespaced with .als-)
   ============================================================ */

/* ---- Floating Alert Button (bottom-right) ---- */
.als-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.als-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(239, 68, 68, 0.7);
}
.als-fab:active { transform: scale(0.95); }

/* Notification permission badge on FAB */
.als-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #eab308;
  border: 2px solid #0a0a1a;
  display: none;
}
.als-fab-badge.show { display: block; }

/* ---- Send Alert Modal ---- */
.als-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 9500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.als-modal-overlay.active { display: flex; }

.als-modal {
  background: #141428;
  border: 1px solid #2a2a48;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
}

.als-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #2a2a48;
}
.als-modal-header h3 {
  font-size: 18px;
  color: #f0f0ff;
  margin: 0;
}
.als-modal-close {
  background: none;
  border: none;
  color: #a0a0c0;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  width: auto;
}
.als-modal-close:hover { color: #f0f0ff; background: rgba(255,255,255,0.05); }

.als-modal-body { padding: 24px; }

/* Alert Type Picker Grid */
.als-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.als-type-card {
  padding: 14px 12px;
  border-radius: 10px;
  border: 2px solid #2a2a48;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: auto;
}
.als-type-card:hover {
  border-color: var(--als-card-color, #7c3aed);
  background: rgba(255,255,255,0.05);
  transform: translateY(-1px);
  box-shadow: none;
}
.als-type-card.selected {
  border-color: var(--als-card-color, #7c3aed);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 20px rgba(var(--als-card-rgb, 124,58,237), 0.3);
}
.als-type-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  margin-bottom: 6px;
}
.als-type-name {
  font-size: 13px;
  font-weight: 600;
  color: #f0f0ff;
  margin-bottom: 2px;
}
.als-type-desc {
  font-size: 11px;
  color: #a0a0c0;
  line-height: 1.3;
}

/* Message textarea */
.als-msg-input {
  width: 100%;
  min-height: 80px;
  background: #0a0a1a;
  border: 1px solid #2a2a48;
  border-radius: 8px;
  color: #f0f0ff;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 16px;
}
.als-msg-input:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* Send button */
.als-send-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.als-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.als-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* ---- Full-Screen Alert Overlay ---- */
.als-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 30px;
  animation: als-fadeIn 0.3s ease;
}
.als-overlay.active { display: flex; }

@keyframes als-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes als-pulse {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.75; }
}

.als-overlay-bg {
  position: absolute;
  inset: 0;
  animation: als-pulse 2s ease-in-out infinite;
}

.als-overlay-content {
  position: relative;
  text-align: center;
  max-width: 600px;
  z-index: 1;
}

.als-overlay-icon {
  font-size: 72px;
  margin-bottom: 16px;
  animation: als-bounce 0.6s ease;
}

@keyframes als-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.als-overlay-title {
  font-size: 42px;
  font-weight: 900;
  color: white;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.als-overlay-message {
  font-size: 20px;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 10px rgba(0,0,0,0.4);
  margin-bottom: 8px;
  line-height: 1.4;
}

.als-overlay-meta {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 24px;
}

.als-overlay-dismiss {
  padding: 12px 36px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  width: auto;
  text-transform: uppercase;
  letter-spacing: 1px;
  backdrop-filter: blur(4px);
}
.als-overlay-dismiss:hover {
  background: rgba(255,255,255,0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* ---- Manage Alert Types Modal ---- */
.als-manage-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}
.als-manage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #2a2a48;
  border-radius: 8px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.02);
}
.als-manage-color {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.als-manage-info { flex: 1; min-width: 0; }
.als-manage-name {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0ff;
}
.als-manage-desc {
  font-size: 12px;
  color: #a0a0c0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.als-manage-actions {
  display: flex;
  gap: 6px;
}
.als-manage-edit,
.als-manage-delete {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #2a2a48;
  background: rgba(255,255,255,0.03);
  color: #a0a0c0;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.als-manage-edit:hover { color: #7c3aed; border-color: #7c3aed; }
.als-manage-delete:hover { color: #ef4444; border-color: #ef4444; }

/* Add/Edit form inside manage modal */
.als-edit-form {
  padding: 16px;
  border: 1px solid #2a2a48;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.05);
  margin-bottom: 12px;
}
.als-edit-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.als-edit-row:last-child { margin-bottom: 0; }
.als-edit-label {
  font-size: 12px;
  color: #a0a0c0;
  margin-bottom: 4px;
}
.als-edit-input {
  width: 100%;
  padding: 8px 10px;
  background: #0a0a1a;
  border: 1px solid #2a2a48;
  border-radius: 6px;
  color: #f0f0ff;
  font-size: 13px;
  font-family: inherit;
}
.als-edit-input:focus {
  outline: none;
  border-color: #7c3aed;
}
.als-edit-color-input {
  width: 44px;
  height: 36px;
  border: 1px solid #2a2a48;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 2px;
}
.als-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}
.als-edit-save,
.als-edit-cancel {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  width: auto;
  font-weight: 600;
}
.als-edit-save {
  background: #7c3aed;
  border: none;
  color: white;
}
.als-edit-cancel {
  background: transparent;
  border: 1px solid #2a2a48;
  color: #a0a0c0;
}

.als-add-btn {
  width: 100%;
  padding: 10px;
  border: 2px dashed #2a2a48;
  border-radius: 8px;
  background: transparent;
  color: #a0a0c0;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 16px;
}
.als-add-btn:hover {
  border-color: #7c3aed;
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.05);
  box-shadow: none;
  transform: none;
}

/* ---- Alert History (tab in manage modal) ---- */
.als-history-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid #2a2a48;
}
.als-history-tab {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #a0a0c0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  width: auto;
}
.als-history-tab:hover { color: #f0f0ff; box-shadow: none; transform: none; }
.als-history-tab.active {
  color: #7c3aed;
  border-bottom-color: #7c3aed;
}

.als-history-list {
  max-height: 350px;
  overflow-y: auto;
}
.als-history-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid #2a2a48;
  border-radius: 8px;
  margin-bottom: 8px;
}
.als-history-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.als-history-info { flex: 1; }
.als-history-name {
  font-size: 13px;
  font-weight: 600;
  color: #f0f0ff;
}
.als-history-msg {
  font-size: 12px;
  color: #a0a0c0;
  margin-top: 2px;
}
.als-history-time {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

/* ---- Notification permission banner ---- */
.als-notif-banner {
  display: none;
  padding: 10px 16px;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #eab308;
  align-items: center;
  gap: 10px;
}
.als-notif-banner.show { display: flex; }
.als-notif-banner button {
  padding: 6px 14px;
  background: #eab308;
  border: none;
  border-radius: 6px;
  color: #0a0a1a;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  width: auto;
}

/* ---- Persistent Top Banner (notification permission) ---- */
.als-top-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8999;
  padding: 12px 20px;
  background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
  color: white;
  font-size: 14px;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.als-top-banner.show { display: flex; }
.als-top-banner span { flex: 1; }
.als-top-banner button {
  padding: 8px 18px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 6px;
  color: white;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  width: auto;
  text-transform: none;
  letter-spacing: 0;
}
.als-top-banner button:hover {
  background: rgba(255,255,255,0.3);
  transform: none;
  box-shadow: none;
}
.als-top-banner-dismiss {
  padding: 4px 8px !important;
  background: transparent !important;
  border: none !important;
  font-size: 18px !important;
  opacity: 0.7;
}
.als-top-banner-dismiss:hover { opacity: 1 !important; }

/* ---- Mobile Responsive ---- */
@media (max-width: 600px) {
  .als-type-grid { grid-template-columns: 1fr; }
  .als-overlay-title { font-size: 28px; letter-spacing: 1px; }
  .als-overlay-message { font-size: 16px; }
  .als-overlay-icon { font-size: 56px; }
  .als-fab { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 20px; }
  .als-top-banner { flex-direction: column; text-align: center; }
}
