/* ==========================================================================
   GLPI Control Center - portal-viewer.css
   --------------------------------------------------------------------------
   Estilos do Portal Viewer (Sprint 4).
   Modular, responsivo, acessível.
   ========================================================================== */

/* ── Modal Overlay ──────────────────────────────────────────────────────── */
.pv-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.pv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
}

/* ── Dialog ─────────────────────────────────────────────────────────────── */
.pv-dialog {
  position: relative;
  z-index: 1;
  width: min(900px, 100%);
  height: min(80vh, 700px);
  max-height: calc(100vh - 48px);
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border, #2e3347);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pvSlideUp 0.22s ease;
}

@keyframes pvSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.pv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #2e3347);
  flex-shrink: 0;
}

.pv-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pv-header-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent, #4f7ef7), var(--accent2, #6c5ce7));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.pv-header-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #e8eaf6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.pv-header-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3, #5a6080);
  background: var(--surface3, #2a2e42);
  padding: 2px 6px;
  border-radius: 4px;
}

.pv-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3, #5a6080);
  flex-shrink: 0;
}

.pv-status-dot.loading {
  background: var(--yellow, #ffc107);
  animation: pvPulse 1.5s ease-in-out infinite;
}

.pv-status-dot.loaded {
  background: var(--green, #00c896);
  box-shadow: 0 0 6px rgba(0, 200, 150, 0.4);
}

.pv-status-dot.error {
  background: var(--red, #ff5555);
}

@keyframes pvPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pv-status-text {
  font-size: 12px;
  color: var(--text2, #9299b8);
}

.pv-close-btn {
  background: none;
  border: 1px solid var(--border, #2e3347);
  color: var(--text2, #9299b8);
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.pv-close-btn:hover {
  color: var(--text, #e8eaf6);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ── Content ────────────────────────────────────────────────────────────── */
.pv-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* ── Loading State ──────────────────────────────────────────────────────── */
.pv-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 16px;
  color: var(--text2, #9299b8);
  font-size: 14px;
}

.pv-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border, #2e3347);
  border-top-color: var(--accent, #4f7ef7);
  border-radius: 50%;
  animation: pvSpin 0.8s linear infinite;
}

@keyframes pvSpin {
  to { transform: rotate(360deg); }
}

/* ── Progress Bar ───────────────────────────────────────────────────────── */
.pv-progress {
  width: 100%;
  height: 3px;
  background: var(--border, #2e3347);
  overflow: hidden;
  flex-shrink: 0;
}

.pv-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent, #4f7ef7), var(--accent2, #6c5ce7));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Iframe ─────────────────────────────────────────────────────────────── */
.pv-iframe-container {
  width: 100%;
  height: 100%;
  display: none;
}

.pv-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ── Mensagens de Estado ────────────────────────────────────────────────── */
.pv-blocked-msg,
.pv-fallback-msg,
.pv-error-msg {
  display: none;
  text-align: center;
  padding: 40px 24px;
}

.pv-msg-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.pv-msg-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #e8eaf6);
  margin: 0 0 8px;
}

.pv-msg-hint {
  font-size: 13px;
  color: var(--text2, #9299b8);
  margin: 0;
  line-height: 1.5;
}

/* ── Countdown ──────────────────────────────────────────────────────────── */
.pv-countdown-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface3, #2a2e42);
  color: var(--accent, #4f7ef7);
  font-size: 14px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  margin: 0 4px;
  animation: pvCountdownPulse 1s ease-in-out infinite;
}

@keyframes pvCountdownPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

/* ── Status Dot: Fallback ───────────────────────────────────────────────── */
.pv-status-dot.fallback {
  background: var(--accent, #4f7ef7);
  animation: pvPulse 1s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(79, 126, 247, 0.4);
}

/* ── Loading Text Animation ─────────────────────────────────────────────── */
.pv-loading-text {
  animation: pvTextFade 2s ease-in-out infinite;
}

@keyframes pvTextFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.pv-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border, #2e3347);
  flex-shrink: 0;
}

.pv-footer-spacer {
  flex: 1;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.pv-btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
}

.pv-btn-primary {
  background: linear-gradient(135deg, var(--accent, #4f7ef7), var(--accent2, #6c5ce7));
  color: #fff;
}

.pv-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.pv-btn-secondary {
  background: transparent;
  border: 1px solid var(--border, #2e3347);
  color: var(--text2, #9299b8);
}

.pv-btn-secondary:hover {
  color: var(--text, #e8eaf6);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ══════════════════════════════════════════════════════════════════════════
   EMAIL VIEW
   ══════════════════════════════════════════════════════════════════════════ */

.pv-email-view {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pv-email-info {
  background: var(--surface2, #222535);
  border: 1px solid var(--border, #2e3347);
  border-radius: 12px;
  padding: 4px 0;
}

.pv-email-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pv-email-field:last-child {
  border-bottom: none;
}

.pv-email-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3, #5a6080);
}

.pv-email-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text, #e8eaf6);
}

.pv-email-value.mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}

.pv-email-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--yellow, #ffc107);
}

.pv-email-notice-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.pv-email-template {
  background: var(--surface2, #222535);
  border: 1px solid var(--border, #2e3347);
  border-radius: 12px;
  overflow: hidden;
}

.pv-email-template-title {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2, #9299b8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pv-email-template-subject {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pv-email-template-body {
  margin: 0;
  padding: 14px 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text, #e8eaf6);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.pv-email-actions {
  display: flex;
  gap: 12px;
}

.pv-email-copied {
  text-align: center;
  padding: 10px;
  background: rgba(0, 200, 150, 0.12);
  border: 1px solid rgba(0, 200, 150, 0.2);
  border-radius: 8px;
  color: var(--green, #00c896);
  font-size: 13px;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════════════
   MANUAL VIEW
   ══════════════════════════════════════════════════════════════════════════ */

.pv-manual-view {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pv-manual-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(79, 126, 247, 0.1);
  border: 1px solid rgba(79, 126, 247, 0.2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--accent, #4f7ef7);
}

.pv-instructions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pv-instruction {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.pv-instruction-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface3, #2a2e42);
  color: var(--text2, #9299b8);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pv-instruction span:last-child {
  font-size: 13px;
  color: var(--text, #e8eaf6);
  line-height: 1.5;
  padding-top: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVIDADE
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .pv-modal {
    padding: 12px;
  }

  .pv-dialog {
    height: calc(100vh - 24px);
    max-height: none;
    border-radius: 12px;
  }

  .pv-header {
    padding: 12px 16px;
  }

  .pv-header-title {
    font-size: 14px;
  }

  .pv-content {
    overflow-y: auto;
  }

  .pv-email-view {
    padding: 16px;
  }

  .pv-email-actions {
    flex-direction: column;
  }

  .pv-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .pv-footer-spacer {
    display: none;
  }

  .pv-btn {
    flex: 1;
    text-align: center;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .pv-header-meta {
    display: none;
  }

  .pv-email-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .pv-email-template-body {
    font-size: 11px;
    max-height: 150px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   FULLSCREEN (tablet/desktop)
   ══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1200px) {
  .pv-dialog {
    width: min(1000px, 90vw);
    height: 85vh;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   ACESSIBILIDADE
   ══════════════════════════════════════════════════════════════════════════ */

.pv-modal:focus {
  outline: none;
}

.pv-btn:focus-visible,
.pv-close-btn:focus-visible {
  outline: 2px solid var(--accent, #4f7ef7);
  outline-offset: 2px;
}

/* Reduzir movimento para usuários que preferem */
@media (prefers-reduced-motion: reduce) {
  .pv-modal,
  .pv-dialog,
  .pv-spinner,
  .pv-status-dot {
    animation: none;
  }
}
