/* Drug Bank v4 - Enhanced Styles
 * Comprehensive styling for enhanced drug notes
 * Fixes: Empty boxes, improved readability, better UX
 */

/* ===== CSS VARIABLES ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #8b5cf6;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  --bg-primary: #0f0a1e;
  --bg-secondary: #1a1525;
  --bg-tertiary: #251e35;
  --bg-card: #1e1830;
  --bg-hover: #2a2340;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-accent: #a5b4fc;
  
  --border-color: #312b45;
  --border-light: #3d3654;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  
  --transition: all 0.3s ease;
}

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
}

.logo-text h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-text p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.stats {
  display: flex;
  gap: 2rem;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-light);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== SEARCH SECTION ===== */
.search-section {
  background: var(--bg-secondary);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
}

.search-container {
  max-width: 800px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-icon {
  font-size: 1.25rem;
  margin-right: 0.75rem;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.clear-btn.visible {
  opacity: 1;
  visibility: visible;
}

.clear-btn:hover {
  color: var(--danger);
}

/* ===== FILTERS ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.filter-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
}

.filter-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* ===== LOADING & ERROR STATES ===== */
.loading-state, .error-state, .no-results {
  text-align: center;
  padding: 4rem 2rem;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.error-state h3, .no-results h3 {
  color: var(--danger);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.error-state p, .no-results p {
  color: var(--text-muted);
}

/* ===== DRUG GRID ===== */
.drug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* ===== DRUG CARD ===== */
.drug-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.drug-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.drug-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.drug-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.drug-category {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.drug-indication {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.drug-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.drug-tag {
  background: var(--bg-tertiary);
  color: var(--text-accent);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.drug-tag.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.drug-tag.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.drug-tag.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 10, 30, 0.9);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.modal-title {
  flex: 1;
}

.modal-title h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.modal-title .category {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.modal-close {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ===== DETAIL SECTIONS ===== */
.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  overflow: hidden;
}

.detail-label {
  background: var(--bg-tertiary);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-accent);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-content {
  padding: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-content p {
  margin-bottom: 0.75rem;
}

.detail-content p:last-child {
  margin-bottom: 0;
}

/* ===== ENHANCED SECTIONS ===== */
.enhanced-section {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.enhanced-section .detail-label {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.enhanced-subsection {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.enhanced-subsection:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.enhanced-title {
  color: var(--primary-light);
  font-size: 1rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* ===== CLINICAL UPDATES ===== */
.clinical-updates-list {
  list-style: none;
  padding: 0;
}

.clinical-updates-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.clinical-updates-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
}

/* ===== FAILURE SCENARIOS ===== */
.failure-scenarios {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.failure-scenario-item {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.failure-scenario-item h5 {
  color: var(--danger);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.failure-scenario-item p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.failure-scenario-item p:last-child {
  margin-bottom: 0;
}

/* ===== COMBINATION THERAPY ===== */
.combination-therapy {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.combination-item {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.combination-item h5 {
  color: var(--success);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.combination-item p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* ===== CLINICAL PEARLS ===== */
.clinical-pearls {
  list-style: none;
  padding: 0;
}

.pearl-item {
  position: relative;
  padding: 0.75rem 1rem 0.75rem 2rem;
  margin-bottom: 0.5rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.pearl-item::before {
  content: '💡';
  position: absolute;
  left: 0.5rem;
}

/* ===== GUIDELINES SECTION ===== */
.guidelines-section {
  border-color: var(--info);
}

.guideline-source {
  font-weight: 600;
  color: var(--info);
}

.evidence-strength {
  background: rgba(59, 130, 246, 0.1);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.guideline-recommendations {
  list-style: none;
  padding: 0;
  margin-top: 0.75rem;
}

.guideline-recommendations li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.guideline-recommendations li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: bold;
}

/* ===== COMPARISON SECTION ===== */
.comparison-section {
  border-color: var(--secondary);
}

.comparison-item {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.comparison-item:last-child {
  margin-bottom: 0;
}

.comparison-item h4 {
  color: var(--secondary);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

/* ===== DOSING SECTIONS ===== */
.dosing-section, .dosing-array-section {
  border-color: var(--success);
}

.dosing-scenario {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.dosing-scenario.even {
  background: var(--bg-card);
}

.dosing-scenario h4 {
  color: var(--success);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.dose-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.dose-item {
  font-size: 0.9rem;
}

.dose-item.full-width {
  grid-column: 1 / -1;
}

.dose-label {
  color: var(--text-muted);
  font-weight: 500;
}

.dosing-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dose-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.dose-cell {
  flex: 1;
  min-width: 200px;
  font-size: 0.9rem;
}

.cell-label {
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== CONTRAINDICATIONS ===== */
.contraindications-section {
  border-color: var(--danger);
}

.contraindication-item {
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.contraindication-item:last-child {
  margin-bottom: 0;
}

.contraindication-item h4 {
  color: var(--danger);
  margin-bottom: 0.5rem;
}

/* ===== ADVERSE EFFECTS ===== */
.adverse-effects-section {
  border-color: var(--warning);
}

.adverse-effect-item {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.adverse-effect-item:last-child {
  margin-bottom: 0;
}

.adverse-effect-item h4 {
  color: var(--warning);
  margin-bottom: 0.5rem;
}

/* ===== INTERACTIONS ===== */
.interactions-section {
  border-color: var(--accent);
}

.interaction-category {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.interaction-category:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.interaction-title {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.interaction-title.synergism {
  color: var(--success);
}

.interaction-title.additive {
  color: var(--info);
}

.interaction-title.antagonism {
  color: var(--danger);
}

.interaction-title.drug-conditions {
  color: var(--warning);
}

.interaction-title.drug-food {
  color: var(--accent);
}

.interaction-title.genes-drug {
  color: var(--secondary);
}

.interaction-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

.interaction-list {
  list-style: none;
  padding: 0;
}

.interaction-item {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.interaction-item .drug-name {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  margin-bottom: 0.25rem;
}

.interaction-item .explanation {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.gene-interaction {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.gene-name {
  color: var(--secondary);
  font-weight: 600;
}

.mutation {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.effect {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== MONITORING ===== */
.monitoring-section {
  border-color: var(--primary);
}

/* ===== SPECIAL POPULATIONS ===== */
.special-section {
  border-color: var(--secondary);
}

.special-population {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.special-population h4 {
  color: var(--secondary);
  margin-bottom: 0.5rem;
}

.special-notes {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
}

/* ===== TRADE NAMES ===== */
.trade-names-section {
  border-color: var(--text-muted);
}

.trade-names-global, .trade-names-local {
  margin-bottom: 1rem;
}

.trade-names-global h4, .trade-names-local h4 {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* ===== UTILITY CLASSES ===== */
.label {
  font-weight: 500;
  color: var(--text-muted);
}

.label.success {
  color: var(--success);
}

.label.warning {
  color: var(--warning);
}

.label.danger {
  color: var(--danger);
}

.label.info {
  color: var(--info);
}

.label.clinical {
  color: var(--primary-light);
}

.label.evidence {
  color: var(--success);
  font-style: italic;
}

.no-data {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem;
  text-align: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.line-position {
  background: rgba(99, 102, 241, 0.1);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

/* ===== SECTION TYPE COLORS ===== */
.section-warning .detail-label {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.section-dosing .detail-label {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.section-indication .detail-label {
  background: rgba(59, 130, 246, 0.2);
  color: var(--info);
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer a {
  color: var(--primary-light);
  text-decoration: none;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }
  
  .stats {
    width: 100%;
    justify-content: space-around;
  }
  
  .search-section {
    padding: 1rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .drug-grid {
    grid-template-columns: 1fr;
  }
  
  .modal {
    max-height: 95vh;
    margin: 0.5rem;
  }
  
  .modal-header, .modal-body {
    padding: 1rem;
  }
  
  .dose-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .logo-text h1 {
    font-size: 1.25rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .filters {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
  }
  
  .filter-btn {
    white-space: nowrap;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .header, .search-section, .footer, .modal-close {
    display: none;
  }
  
  .modal-overlay {
    position: static;
    opacity: 1;
    visibility: visible;
    background: white;
    padding: 0;
  }
  
  .modal {
    max-height: none;
    border: none;
    box-shadow: none;
  }
  
  .detail-section {
    break-inside: avoid;
    border: 1px solid #ddd;
  }
  
  body {
    background: white;
    color: black;
  }
}
