/* ==========================================================================
   Hospital Jaraguá - Validador de Atestados Digitais
   Design System & Estilos Principais
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #00875a;
  --primary-hover: #006644;
  --primary-light: #e3fcef;
  --primary-glow: rgba(0, 135, 90, 0.2);
  
  --secondary: #0b2240;
  --secondary-light: #1e3a5f;
  
  --accent: #0065ff;
  --accent-light: #deebff;
  
  --success: #36b37e;
  --success-bg: #e3fcef;
  --success-border: #abf5d1;
  
  --danger: #de350b;
  --danger-bg: #ffebe6;
  --danger-border: #ffbdad;
  
  --warning: #ffab00;
  --warning-bg: #fffae6;
  
  --bg-page: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  
  --text-primary: #091e42;
  --text-secondary: #5e6c84;
  --text-muted: #8993a4;
  
  --border-color: #ebecf0;
  --border-focus: #4c9aff;
  
  --shadow-sm: 0 2px 4px rgba(9, 30, 66, 0.08);
  --shadow-md: 0 8px 16px -4px rgba(9, 30, 66, 0.12), 0 0 1px rgba(9, 30, 66, 0.31);
  --shadow-lg: 0 16px 32px -8px rgba(9, 30, 66, 0.16), 0 0 1px rgba(9, 30, 66, 0.31);
  --shadow-glow: 0 0 24px rgba(0, 135, 90, 0.25);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Background Pattern */
.bg-decor {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 380px;
  background: linear-gradient(135deg, #0b2240 0%, #004b32 60%, #00875a 100%);
  z-index: -1;
  border-bottom-left-radius: 40px;
  border-bottom-right-radius: 40px;
  box-shadow: var(--shadow-md);
}

/* Header */
.app-header {
  padding: 24px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-container {
  max-width: 900px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #ffffff;
}

.logo-symbol {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.logo-symbol svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.header-badge {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #36b37e;
  border-radius: 50%;
  box-shadow: 0 0 8px #36b37e;
}

/* Main Container */
.main-wrapper {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 40px 16px;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-bottom: 24px;
  transition: var(--transition);
}

/* Validation Status Hero Banner */
.status-hero {
  padding: 32px 24px;
  text-align: center;
  position: relative;
}

.status-hero.valid {
  background: linear-gradient(180deg, #f0fff4 0%, #ffffff 100%);
  border-bottom: 2px solid var(--success-border);
}

.status-hero.invalid {
  background: linear-gradient(180deg, #fff5f5 0%, #ffffff 100%);
  border-bottom: 2px solid var(--danger-border);
}

.seal-icon-wrapper {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.seal-icon-wrapper.valid {
  background: var(--success-bg);
  border: 2px solid var(--success-border);
  box-shadow: 0 0 0 8px rgba(54, 179, 126, 0.15);
  animation: pulseSuccess 2s infinite;
}

.seal-icon-wrapper.invalid {
  background: var(--danger-bg);
  border: 2px solid var(--danger-border);
  box-shadow: 0 0 0 8px rgba(222, 53, 11, 0.15);
}

@keyframes pulseSuccess {
  0% { box-shadow: 0 0 0 0 rgba(54, 179, 126, 0.4); }
  70% { box-shadow: 0 0 0 14px rgba(54, 179, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(54, 179, 126, 0); }
}

.seal-icon-wrapper svg {
  width: 44px;
  height: 44px;
}

.status-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.status-title.valid { color: #006644; }
.status-title.invalid { color: var(--danger); }

.status-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
}

/* Quick Details Grid */
.details-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface-alt);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  justify-items: center;
}

.detail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Document Frame (Official Certificate View) */
.document-frame-container {
  padding: 28px;
}

.document-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.doc-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.document-paper {
  background: #ffffff;
  border: 1px solid #c1c7d0;
  border-radius: var(--radius-md);
  padding: 32px 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
}

/* Document Header Grid (Logo, Title, QR Code) */
.doc-header-grid {
  display: grid;
  grid-template-columns: 140px 1fr 100px;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1.5px solid var(--border-color);
}

.doc-header-col-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.doc-header-col-left .doc-logo {
  max-height: 52px;
  width: auto;
  margin-bottom: 0;
}

.doc-header-col-center {
  text-align: center;
}

.doc-hospital-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.doc-type-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.doc-header-col-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.doc-qrcode {
  padding: 4px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: inline-block;
  line-height: 0;
}

.doc-qrcode canvas {
  display: none !important;
}

.doc-qrcode img {
  display: block !important;
  max-width: 80px;
  height: auto;
}

.watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 3.2rem;
  font-weight: 900;
  color: rgba(0, 135, 90, 0.08);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  border: 4px dashed rgba(0, 135, 90, 0.09);
  padding: 12px 32px;
  border-radius: 12px;
  z-index: 1;
}

.document-rendered-content {
  position: relative;
  z-index: 2;
  font-size: 1.05rem;
  line-height: 1.8;
  color: #172b4d;
  user-select: none;
  -webkit-user-select: none;
}

.document-rendered-content p {
  margin-bottom: 14px;
}

.document-rendered-content strong,
.document-rendered-content b {
  font-weight: 700;
  color: #091e42;
}

/* Efeito visual quando ocorre tentativa de adulteração */
.document-paper.tamper-alert {
  filter: blur(4px);
  border-color: var(--danger) !important;
  transition: all 0.2s ease;
}

/* Security Verification Stamp */
.verification-stamp {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.85rem;
}

.stamp-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.stamp-status-valid {
  color: var(--primary);
  font-weight: 700;
}

.stamp-key-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.stamp-key-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--text-muted);
}

.stamp-key-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  background: #ffffff;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--secondary);
  word-break: break-all;
  user-select: all;
}

@media (max-width: 600px) {
  .doc-header-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 12px;
  }
  .doc-header-col-left,
  .doc-header-col-right {
    justify-content: center;
  }
}

.stamp-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stamp-code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-weight: 700;
  color: var(--secondary);
  background: #ebecf0;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-outline {
  background: transparent;
  color: var(--secondary);
  border: 1.5px solid #dfe1e6;
}

.btn-outline:hover {
  background: #ebecf0;
  border-color: #c1c7d0;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* Search / QR Scanner Box on Index */
.search-card {
  padding: 32px;
}

.tab-nav {
  display: flex;
  gap: 12px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* QR Camera Scanner Container */
#qr-reader-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px dashed var(--primary);
  background: #f8fafc;
  padding: 16px;
  text-align: center;
}

#qr-reader {
  width: 100% !important;
  border: none !important;
}

.doc-logo {
  max-height: 55px;
  width: auto;
  margin-bottom: 18px;
}

.brand-img-logo {
  height: 44px;
  width: auto;
  background: #ffffff;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.footer-dpo {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-dpo p {
  margin-bottom: 3px;
}

/* Footer */
.app-footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 28px 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 6px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--secondary);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 9999;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 640px) {
  .app-header {
    padding: 16px;
  }

  .status-hero {
    padding: 24px 16px;
  }

  .seal-icon-wrapper {
    width: 64px;
    height: 64px;
  }

  .seal-icon-wrapper svg {
    width: 36px;
    height: 36px;
  }

  .status-title {
    font-size: 1.25rem;
  }

  .document-frame-container {
    padding: 18px 16px;
  }

  .document-paper {
    padding: 24px 16px;
  }

  .details-summary {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .btn {
    width: 100%;
  }

  .header-badge {
    display: none;
  }
}
