/* ============================================================
   PHARMA-ADVANCE PSYCHIATRY MODULE — MOBILE-FIRST CSS
   ============================================================ */

:root {
  --psych-primary: #1a3a5c;
  --psych-accent: #2e86ab;
  --psych-green: #0d7a5f;
  --psych-amber: #e07b39;
  --psych-red: #c0392b;
  --psych-purple: #6c3483;
  --psych-bg: #f0f4f8;
  --psych-card: #ffffff;
  --psych-border: #d1dde8;
  --psych-text: #1c2b3a;
  --psych-muted: #6b7e8f;
  --psych-radius: 14px;
  --psych-shadow: 0 2px 16px rgba(26,58,92,0.10);
  --psych-shadow-lg: 0 6px 32px rgba(26,58,92,0.16);
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ===== BASE ===== */
.papsych-wrap * {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.papsych-wrap {
  font-family: var(--font-main);
  color: var(--psych-text);
  background: var(--psych-bg);
  min-height: 100vh;
  padding: 0;
  margin: 0;
}

/* ===== HEADER ===== */
.papsych-header {
  background: linear-gradient(135deg, var(--psych-primary) 0%, #2a5298 100%);
  color: white;
  padding: 20px 16px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 3px 20px rgba(0,0,0,0.25);
}

.papsych-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.3px;
}

.papsych-header p {
  font-size: 0.75rem;
  opacity: 0.82;
  margin: 0;
}

/* ===== TAB NAV ===== */
.papsych-tabs {
  display: flex;
  overflow-x: auto;
  background: var(--psych-primary);
  padding: 0 8px 0;
  gap: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 3px solid var(--psych-accent);
}

.papsych-tabs::-webkit-scrollbar { display: none; }

.papsych-tab-btn {
  flex: 0 0 auto;
  padding: 11px 14px;
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: none;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
}

.papsych-tab-btn.active,
.papsych-tab-btn:focus {
  color: #fff;
  border-bottom-color: #4fc3f7;
  outline: none;
}

.papsych-tab-btn:active {
  background: rgba(255,255,255,0.08);
}

/* ===== TAB CONTENT ===== */
.papsych-tab-content { display: none; padding: 16px; }
.papsych-tab-content.active { display: block; }

/* ===== CARDS ===== */
.psych-card {
  background: var(--psych-card);
  border-radius: var(--psych-radius);
  box-shadow: var(--psych-shadow);
  padding: 18px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--psych-border);
}

.psych-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--psych-primary);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.psych-card-subtitle {
  font-size: 0.78rem;
  color: var(--psych-muted);
  margin: 0 0 16px;
}

/* ===== SCALE QUESTIONS ===== */
.scale-question {
  background: #f7fafc;
  border-radius: 10px;
  padding: 12px 12px 8px;
  margin-bottom: 10px;
  border-left: 4px solid var(--psych-accent);
}

.scale-question p {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--psych-text);
  margin: 0 0 10px;
  line-height: 1.4;
}

.scale-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.scale-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--psych-border);
  cursor: pointer;
  transition: all 0.18s;
  background: white;
}

.scale-option input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--psych-accent);
  cursor: pointer;
}

.scale-option label {
  font-size: 0.78rem;
  color: var(--psych-text);
  cursor: pointer;
  line-height: 1.2;
}

.scale-option:has(input:checked) {
  border-color: var(--psych-accent);
  background: #e8f4fd;
}

/* ===== SCORE RESULT ===== */
.score-result {
  display: none;
  background: linear-gradient(135deg, var(--psych-primary), #2a5298);
  color: white;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  margin-top: 16px;
}

.score-result.visible { display: block; }

.score-number {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 6px 0 4px;
}

.score-desc {
  font-size: 0.82rem;
  opacity: 0.9;
  margin: 0;
}

.score-action {
  margin-top: 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  text-align: left;
}

.score-action strong { display: block; margin-bottom: 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.8; }

/* severity badges */
.sev-minimal { background: #d5f5e3; color: #1e8449; }
.sev-mild { background: #fef9c3; color: #7d6608; }
.sev-moderate { background: #fde8d0; color: #9c4a00; }
.sev-severe { background: #fadbd8; color: #922b21; }

/* ===== BUTTONS ===== */
.psych-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  margin-top: 12px;
}

.psych-btn-primary {
  background: linear-gradient(135deg, var(--psych-accent), var(--psych-primary));
  color: white;
  box-shadow: 0 4px 12px rgba(46,134,171,0.3);
}

.psych-btn-primary:active { transform: scale(0.98); }

.psych-btn-reset {
  background: #f0f4f8;
  color: var(--psych-muted);
  border: 1.5px solid var(--psych-border);
  margin-top: 8px;
}

/* ===== PROGRESS BAR ===== */
.score-bar-wrap {
  background: rgba(255,255,255,0.25);
  border-radius: 50px;
  height: 8px;
  margin: 10px 0 0;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 50px;
  background: linear-gradient(90deg, #4fc3f7, #81d4fa);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

/* ===== DRUG CARDS ===== */
.drug-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.drug-card {
  background: var(--psych-card);
  border-radius: var(--psych-radius);
  box-shadow: var(--psych-shadow);
  overflow: hidden;
  border: 1px solid var(--psych-border);
}

.drug-card-header {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.drug-card-header:active { background: #f5f5f5; }

.drug-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--psych-primary);
}

.drug-class-badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  margin-top: 3px;
  display: inline-block;
}

.badge-ssri { background: #d6eaf8; color: #1a5276; }
.badge-snri { background: #d5f5e3; color: #1e8449; }
.badge-tca { background: #f9ebea; color: #922b21; }
.badge-atypical { background: #e8d5f5; color: #6c3483; }
.badge-typical { background: #fde8d0; color: #9c4a00; }
.badge-mood { background: #fef9c3; color: #7d6608; }
.badge-benzo { background: #e8f8f5; color: #0e6655; }

.drug-chevron {
  font-size: 1.2rem;
  color: var(--psych-muted);
  transition: transform 0.2s;
}

.drug-card.open .drug-chevron { transform: rotate(180deg); }

.drug-card-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--psych-border);
}

.drug-card.open .drug-card-body { display: block; }

.drug-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.drug-info-item {
  background: #f7fafc;
  border-radius: 8px;
  padding: 10px;
}

.drug-info-item .label {
  font-size: 0.68rem;
  color: var(--psych-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}

.drug-info-item .value {
  font-size: 0.82rem;
  color: var(--psych-text);
  font-weight: 600;
  line-height: 1.3;
}

.drug-info-full {
  background: #f7fafc;
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
}

.drug-info-full .label {
  font-size: 0.68rem;
  color: var(--psych-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.drug-info-full .value {
  font-size: 0.82rem;
  color: var(--psych-text);
  line-height: 1.5;
}

.drug-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fef9c3;
  border-left: 3px solid #f39c12;
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: #7d6608;
  line-height: 1.4;
}

.drug-danger {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fadbd8;
  border-left: 3px solid var(--psych-red);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: #922b21;
  line-height: 1.4;
}

/* ===== BENZO CALCULATOR ===== */
.benzo-form {
  display: grid;
  gap: 14px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--psych-primary);
  margin-bottom: 6px;
}

.form-group select,
.form-group input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--psych-border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--psych-text);
  background: white;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
  border-color: var(--psych-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(46,134,171,0.12);
}

.benzo-result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.benzo-eq-item {
  background: #f7fafc;
  border-radius: 10px;
  padding: 12px;
  border: 1.5px solid var(--psych-border);
  text-align: center;
}

.benzo-eq-item.highlight {
  background: linear-gradient(135deg, var(--psych-accent), var(--psych-primary));
  color: white;
  border-color: transparent;
}

.benzo-eq-name {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
  opacity: 0.8;
}

.benzo-eq-dose {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
}

.benzo-eq-unit {
  font-size: 0.72rem;
  opacity: 0.7;
}

/* ===== LITHIUM MONITOR ===== */
.lithium-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.lithium-level-card {
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}

.lithium-level-card .range {
  font-size: 0.85rem;
  font-weight: 800;
}

.lithium-level-card .meaning {
  font-size: 0.68rem;
  margin-top: 4px;
  font-weight: 600;
}

.ll-therapeutic { background: #d5f5e3; color: #1e8449; }
.ll-caution { background: #fef9c3; color: #7d6608; }
.ll-toxic { background: #fadbd8; color: #922b21; }

.toxicity-signs {
  background: #fadbd8;
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  border-left: 4px solid var(--psych-red);
}

.toxicity-signs h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #922b21;
}

.toxicity-signs ul {
  margin: 0;
  padding-left: 18px;
}

.toxicity-signs li {
  font-size: 0.8rem;
  color: #7b241c;
  margin-bottom: 3px;
  line-height: 1.4;
}

/* ===== GUIDELINES ===== */
.guideline-card {
  background: var(--psych-card);
  border-radius: var(--psych-radius);
  box-shadow: var(--psych-shadow);
  margin-bottom: 14px;
  border: 1px solid var(--psych-border);
  overflow: hidden;
}

.guideline-header {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.guideline-org-badge {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-ips { background: #e8f4fd; color: #1a5276; }
.badge-apa { background: #e8f5e9; color: #1b5e20; }
.badge-nice { background: #f3e5f5; color: #4a148c; }
.badge-who { background: #fff3e0; color: #e65100; }

.guideline-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--psych-primary);
  flex: 1;
}

.guideline-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--psych-border);
}

.guideline-card.open .guideline-body { display: block; }

.guideline-step {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  align-items: flex-start;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--psych-primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-content strong {
  display: block;
  font-size: 0.85rem;
  color: var(--psych-primary);
  margin-bottom: 2px;
}

.step-content p {
  font-size: 0.78rem;
  color: var(--psych-muted);
  margin: 0;
  line-height: 1.5;
}

/* ===== CIWA SCALE ===== */
.ciwa-item {
  background: #f7fafc;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border-left: 4px solid var(--psych-amber);
}

.ciwa-item p {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--psych-text);
}

.ciwa-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ciwa-slider {
  flex: 1;
  height: 6px;
  accent-color: var(--psych-amber);
  cursor: pointer;
}

.ciwa-val {
  width: 30px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--psych-primary);
}

.ciwa-label {
  font-size: 0.72rem;
  color: var(--psych-muted);
  margin-top: 4px;
}

/* ===== AIMS SCALE ===== */
.aims-section {
  background: #f7fafc;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border-left: 4px solid var(--psych-purple);
}

.aims-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--psych-purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ===== SUICIDE RISK BANNER ===== */
.suicide-risk-banner {
  background: linear-gradient(135deg, #c0392b, #922b21);
  color: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.suicide-risk-banner .icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.suicide-risk-banner h4 {
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.suicide-risk-banner p {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.92;
  line-height: 1.5;
}

.suicide-risk-banner a {
  color: #ffd700;
  font-weight: 700;
}

/* ===== MONITORING TABLE ===== */
.monitor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 10px;
}

.monitor-table th {
  background: var(--psych-primary);
  color: white;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
}

.monitor-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--psych-border);
  vertical-align: top;
  line-height: 1.4;
}

.monitor-table tr:nth-child(even) td {
  background: #f7fafc;
}

/* ===== QUICK REFERENCE CHIPS ===== */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  border: 1.5px solid;
}

.chip-blue { background: #e8f4fd; color: #1a5276; border-color: #aed6f1; }
.chip-green { background: #d5f5e3; color: #1e8449; border-color: #a9dfbf; }
.chip-red { background: #fadbd8; color: #922b21; border-color: #f1948a; }
.chip-amber { background: #fef9c3; color: #7d6608; border-color: #f9e79f; }
.chip-purple { background: #e8d5f5; color: #6c3483; border-color: #c39bd3; }

/* ===== PREGNANCY SAFETY ===== */
.preg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.preg-cat {
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.preg-A { background: #d5f5e3; color: #1e8449; }
.preg-B { background: #d6eaf8; color: #1a5276; }
.preg-C { background: #fef9c3; color: #7d6608; }
.preg-D { background: #fde8d0; color: #9c4a00; }
.preg-X { background: #fadbd8; color: #922b21; }

/* ===== QUICK ACTION TOOLS ===== */
.qat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.qat-btn {
  background: white;
  border: 2px solid var(--psych-border);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: block;
}

.qat-btn:active {
  border-color: var(--psych-accent);
  background: #e8f4fd;
  transform: scale(0.97);
}

.qat-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.qat-label { font-size: 0.78rem; font-weight: 700; color: var(--psych-primary); }

/* ===== CLINICAL PEARL ===== */
.clinical-pearl {
  background: linear-gradient(135deg, #e8f4fd, #d6eaf8);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
  border-left: 4px solid var(--psych-accent);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.clinical-pearl .pearl-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.clinical-pearl p { margin: 0; font-size: 0.8rem; color: #1a3a5c; line-height: 1.5; font-style: italic; }

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
  .drug-grid { grid-template-columns: repeat(2, 1fr); }
  .scale-options { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .papsych-header h1 { font-size: 1.6rem; }
  .papsych-tab-btn { font-size: 0.8rem; padding: 13px 18px; }
  .drug-grid { grid-template-columns: repeat(2, 1fr); }
  .psych-card { padding: 22px; }
}

/* ===== ANIMATION ===== */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.papsych-tab-content.active {
  animation: fadeSlideIn 0.25s ease;
}

@keyframes scorePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.score-result.visible .score-number {
  animation: scorePulse 0.6s ease;
}
