/* ============================================
   MedBot — Prescription View Styles
   ============================================ */

/* ---- Prescription Container ---- */
.prescription-container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-3xl);
  width: 100%;
  animation: prescriptionEnter 0.6s ease forwards;
}

@keyframes prescriptionEnter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Prescription Header ---- */
.rx-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.rx-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 18px;
  background: var(--light-cyan);
  border: 1px solid var(--frosted-blue);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bright-teal-blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
}

.rx-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: var(--space-sm);
}

.rx-date {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

/* ---- Patient Summary Card ---- */
.rx-patient-card {
  background: #ffffff;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.rx-patient-card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--bright-teal-blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
}

.rx-patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.rx-patient-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rx-patient-item .label {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rx-patient-item .value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Share Consultation Card ---- */
.rx-share-card {
  background: linear-gradient(135deg, rgb(225 243 250) 0%, rgb(173 235 231 / 25%) 100%);
  border: 1px solid rgba(20, 184, 166, 0.35);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: 0 8px 32px #c0ebf1, 0 0 20px rgba(20, 184, 166, 0.08);
  position: relative;
  overflow: hidden;
}

.rx-share-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
}

.rx-share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
}

.rx-share-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--deep-twilight);
}

.rx-share-title svg {
  color: var(--bright-teal-blue);
}

.rx-cloud-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}

.rx-cloud-badge.cloud-synced {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #059669;
}

.rx-cloud-badge.local-synced {
  background: var(--light-cyan);
  border: 1px solid var(--frosted-blue);
  color: var(--bright-teal-blue);
}

.rx-share-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

.rx-uuid-tag {
  display: inline-block;
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--deep-twilight);
  background: var(--light-cyan);
  border: 1px solid var(--frosted-blue);
  padding: 1px 6px;
  border-radius: 4px;
}

.rx-share-input-group {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.rx-share-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.rx-link-icon {
  position: absolute;
  left: 12px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.rx-share-input-wrapper input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: #ffffff;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--deep-twilight);
  font-size: 0.82rem;
  font-family: monospace;
  transition: all var(--transition-fast);
}

.rx-share-input-wrapper input:focus {
  outline: none;
  border-color: var(--bright-teal-blue);
  box-shadow: 0 0 0 2px rgba(0, 119, 182, 0.15);
}

.rx-btn-copy {
  white-space: nowrap;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.82rem;
}

.rx-share-actions-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn-share-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-share-pill.whatsapp {
  background: rgba(37, 211, 102, 0.12);
  border-color: rgba(37, 211, 102, 0.35);
  color: #25d366;
}

.btn-share-pill.whatsapp:hover {
  background: rgba(37, 211, 102, 0.22);
  border-color: #25d366;
  transform: translateY(-1px);
}

.btn-share-pill.native {
  background: rgba(148, 163, 184, 0.1);
  border-color: var(--border-primary);
  color: var(--text-secondary);
}

.btn-share-pill.native:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-primary);
}

/* ---- Shared Consultation Banner ---- */
.rx-shared-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 12px 18px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
  font-size: 0.85rem;
  color: #a5f3fc;
  flex-wrap: wrap;
}

.rx-shared-banner-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.rx-shared-banner-left svg {
  color: #22d3ee;
  flex-shrink: 0;
}

/* ---- Loading / Error States ---- */
.rx-state-card {
  max-width: 540px;
  margin: var(--space-3xl) auto;
  padding: var(--space-2xl);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

.rx-state-card h2 {
  font-size: 1.3rem;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.rx-state-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.rx-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(20, 184, 166, 0.2);
  border-top-color: var(--primary-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-lg);
}

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

/* ---- Floating Toast Notification ---- */
.rx-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--bright-teal-blue);
  color: var(--deep-twilight);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 1000;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.rx-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.rx-toast svg {
  color: #10b981;
}

/* ---- Section Cards ---- */
.rx-section {
  background: #ffffff;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
  animation: sectionFadeIn 0.4s ease forwards;
  animation-delay: calc(var(--delay, 0) * 0.1s);
  opacity: 0;
}

@keyframes sectionFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rx-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--deep-twilight);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-primary);
}

.rx-section-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rx-section-icon.diagnosis {
  background: rgba(0, 119, 182, 0.1);
  color: var(--bright-teal-blue);
}

.rx-section-icon.medications {
  background: var(--light-cyan);
  color: var(--bright-teal-blue);
}

.rx-section-icon.food {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.rx-section-icon.lifestyle {
  background: rgba(0, 180, 216, 0.12);
  color: var(--turquoise-surf);
}

.rx-section-icon.followup {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ---- Diagnosis Content ---- */
.rx-diagnosis-text {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.rx-diagnosis-text p {
  margin-bottom: var(--space-md);
}

.rx-diagnosis-text p:last-child {
  margin-bottom: 0;
}

/* ---- Medications Table ---- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  margin-top: var(--space-sm);
}

.rx-meds-table {
  width: 100%;
  min-width: 540px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
}

.rx-meds-table thead th {
  background: var(--light-cyan);
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--deep-twilight);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  border-bottom: 1px solid var(--border-primary);
}

.rx-meds-table tbody td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--deep-twilight);
  border-bottom: 1px solid var(--border-primary);
  vertical-align: top;
}

.rx-meds-table tbody tr:last-child td {
  border-bottom: none;
}

.rx-meds-table tbody tr:nth-child(even) {
  background: #f8fdff;
}

.rx-meds-table tbody tr:hover {
  background: rgba(202, 240, 248, 0.35);
}

.med-name {
  font-weight: 700;
  color: var(--bright-teal-blue);
}

.med-generic {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.med-instruction {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ---- Recommendation Cards ---- */
.rx-recommendations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.rx-rec-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.rx-rec-card:hover {
  border-color: var(--turquoise-surf);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.rx-rec-card .rec-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.rx-rec-card .rec-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
  color: var(--deep-twilight);
}

.rx-rec-card .rec-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---- Lifestyle List ---- */
.rx-lifestyle-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.rx-lifestyle-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
}

.rx-lifestyle-item .lifestyle-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-cyan);
  color: var(--bright-teal-blue);
  border-radius: var(--radius-sm);
}

.rx-lifestyle-item .lifestyle-content h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--deep-twilight);
  margin-bottom: 4px;
}

.rx-lifestyle-item .lifestyle-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---- Disclaimer ---- */
.rx-disclaimer {
  background: rgba(239, 68, 68, 0.04);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-top: var(--space-lg);
  text-align: center;
}

.rx-disclaimer-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.rx-disclaimer h4 {
  font-size: 0.9rem;
  color: #dc2626;
  margin-bottom: var(--space-sm);
}

.rx-disclaimer p {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

/* ---- Actions ---- */
.rx-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  flex-wrap: wrap;
}

.rx-actions .btn {
  min-width: 160px;
  justify-content: center;
  padding: 14px 28px;
}

/* ---- Download PDF Button & Loading Animation ---- */
.btn-download-pdf {
  position: relative;
  min-width: 175px;
  transition: all var(--transition-base);
  overflow: hidden;
}

.btn-download-pdf.loading {
  pointer-events: none;
  background: var(--light-cyan) !important;
  color: var(--bright-teal-blue) !important;
  border-color: var(--frosted-blue) !important;
  box-shadow: 0 0 16px rgba(0, 180, 216, 0.25);
  cursor: wait;
}

.btn-download-pdf.success {
  background: #ecfdf5 !important;
  color: #059669 !important;
  border-color: #a7f3d0 !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}

.btn-download-pdf .btn-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(0, 119, 182, 0.25);
  border-top-color: var(--bright-teal-blue);
  border-radius: 50%;
  display: inline-block;
  animation: btnSpin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes btnSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Subtle progress pulse bar */
.btn-download-pdf.loading::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #0077b6, #00b4d8, #caf0f8, #0077b6);
  background-size: 200% 100%;
  animation: loadingBarPulse 1.2s linear infinite;
}

@keyframes loadingBarPulse {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .prescription-container {
    padding: var(--space-md) var(--space-sm) var(--space-xl);
  }

  .rx-title {
    font-size: 1.5rem;
  }

  .rx-patient-card,
  .rx-section {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }

  .rx-patient-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .rx-share-card {
    padding: var(--space-md);
  }

  .rx-share-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .rx-meds-table {
    font-size: 0.78rem;
  }

  .rx-meds-table thead th,
  .rx-meds-table tbody td {
    padding: 8px 10px;
  }

  .rx-recommendations {
    grid-template-columns: 1fr;
  }

  .rx-actions {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .rx-actions .btn {
    width: 100%;
    min-width: unset;
    justify-content: center;
    padding: 12px 18px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .rx-patient-grid {
    grid-template-columns: 1fr;
  }

  .rx-share-pills {
    flex-direction: column;
    width: 100%;
  }

  .btn-share-pill {
    justify-content: center;
    width: 100%;
  }
}

@media print {
  .prescription-container {
    padding: 20px;
    max-width: 100%;
  }

  .rx-section {
    background: white;
    border: 1px solid #ddd;
    box-shadow: none;
    backdrop-filter: none;
    opacity: 1 !important;
    animation: none !important;
    page-break-inside: avoid;
  }

  .rx-patient-card {
    background: white;
    border: 1px solid #ddd;
  }

  .rx-actions {
    display: none !important;
  }

  .rx-rec-card,
  .rx-lifestyle-item {
    background: #f9f9f9;
    border: 1px solid #ddd;
  }

  .rx-meds-table {
    border: 1px solid #ccc;
  }

  .rx-meds-table thead th {
    background: #f0f0f0;
    color: #333;
  }

  .rx-meds-table tbody td {
    color: #333;
  }

  * {
    color: #333 !important;
  }

  .med-name,
  .rx-section-title,
  .rx-title {
    color: #0077b6 !important;
  }
}