/* ==========================================================================
   AYUR CATALOG - STYLESHEET
   Herbal, Classical Ayurvedic Theme: Deep Emerald, Gold, Earth, Crisp Clean UI
   ========================================================================== */

:root {
  --primary-deep: #133926;
  --primary: #1c5236;
  --primary-light: #28744c;
  --primary-subtle: #e8f4ed;
  
  --gold: #b3822a;
  --gold-light: #dfab4b;
  --gold-subtle: #fbf5e8;
  
  --accent-warm: #c85a17;
  --accent-soft: #fdf3ed;
  
  --bg-main: #f6f8f6;
  --bg-card: #ffffff;
  --bg-surface: #f9fbf9;
  
  --text-main: #1d2721;
  --text-muted: #526359;
  --text-light: #83958b;
  
  --border: #dbe4dd;
  --border-focus: #1c5236;
  
  --warning-bg: #fff8e6;
  --warning-border: #f0c36d;
  --warning-text: #8c5b05;
  
  --danger: #be2e2e;
  --danger-light: #fbebeb;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(19, 57, 38, 0.06);
  --shadow-md: 0 4px 12px rgba(19, 57, 38, 0.08);
  --shadow-lg: 0 12px 30px rgba(19, 57, 38, 0.12);
  --shadow-modal: 0 24px 60px rgba(10, 30, 20, 0.25);
  
  --font-serif: 'Cinzel', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */
.app-header {
  background: linear-gradient(135deg, var(--primary-deep) 0%, #17422c 100%);
  color: #ffffff;
  padding: 1.1rem 1.5rem;
  border-bottom: 2px solid var(--gold);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

.logo-icon {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.12);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid rgba(223, 171, 75, 0.4);
}

.logo-title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
}

.logo-subtitle {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn .icon {
  font-size: 1rem;
  line-height: 1;
}

.btn-primary {
  background: var(--gold);
  color: #ffffff;
  border-color: var(--gold);
}

.btn-primary:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(179, 130, 42, 0.35);
}

.btn-secondary {
  background: var(--primary);
  color: #ffffff;
}

.btn-secondary:hover {
  background: var(--primary-light);
}

.btn-secondary-subtle {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid rgba(28, 82, 54, 0.2);
}

.btn-secondary-subtle:hover {
  background: #d6ebdf;
  color: var(--primary-deep);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
}

.btn-accent {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.82rem;
}

.btn-accent:hover {
  background: var(--primary-light);
}

.btn-warning-action {
  background: var(--gold);
  color: #ffffff;
  border: none;
}

.btn-warning-action:hover {
  background: var(--gold-light);
}

.btn-subtle {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-subtle:hover {
  background: #eaeaea;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.cursor-pointer {
  cursor: pointer;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.main-content {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

/* ==========================================================================
   STATISTICS BAR
   ========================================================================== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd8ce;
}

.stat-icon {
  font-size: 1.8rem;
  background: var(--primary-subtle);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.stat-info h4 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-deep);
  line-height: 1.1;
}

.stat-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================================================
   SEARCH & FILTERS
   ========================================================================== */
.search-filter-section {
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.95rem;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 2.2rem 0.65rem 2.4rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(28, 82, 54, 0.12);
}

.btn-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem;
  display: none;
}

.btn-clear.visible {
  display: block;
}

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

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-select {
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  min-width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-btn {
  background: var(--bg-surface);
  border: none;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.view-btn.active {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: bold;
}

/* ==========================================================================
   CATALOG HEADER
   ========================================================================== */
.catalog-section {
  margin-top: 0.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title-wrap h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--primary-deep);
  font-weight: 700;
}

.filter-tag {
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.section-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   MEDICINE SEARCH BAR
   ========================================================================== */
.medicine-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.medicine-search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(30, 92, 59, 0.1);
}

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

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.85rem;
  font-size: 1.05rem;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.8;
}

.search-medicine-control {
  width: 100%;
  padding: 0.6rem 2.4rem 0.6rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-dark);
  background: #ffffff;
  transition: all 0.2s ease;
}

.search-medicine-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 92, 59, 0.12);
}

.search-medicine-control::placeholder {
  color: #8fa094;
  font-size: 0.9rem;
}

.btn-clear-search {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-clear-search:hover {
  color: var(--danger);
  background: #fde8e8;
}

.search-count-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-deep);
  background: var(--primary-subtle);
  border: 1px solid #c2dcce;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ==========================================================================
   MEDICINE GRID & CARDS
   ========================================================================== */
.medicine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.medicine-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.medicine-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #cbd8ce;
}

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

.card-title-group {
  flex: 1;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--primary-deep);
  cursor: pointer;
  line-height: 1.25;
}

.card-title:hover {
  color: var(--gold);
}

.card-dosage-badge {
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.card-reference {
  font-size: 0.8rem;
  color: var(--gold);
  font-style: italic;
  font-weight: 600;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.pill {
  font-size: 0.76rem;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
  background: #f1f4f2;
  color: #2b3a32;
  border: 1px solid #e1e7e3;
  line-height: 1.3;
}

.pill-ingredient {
  background: #eef7f2;
  border-color: #c9e6d4;
  color: var(--primary-deep);
}

.pill-indication {
  background: #fcf6eb;
  border-color: #f1dfba;
  color: #7d5006;
}

.pill-pharmacy {
  background: #f1f4f8;
  border-color: #d6e0ed;
  color: #1f3f6e;
  font-weight: 500;
}

.pill-more {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-light);
  font-size: 0.72rem;
}

.card-precaution-strip {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning-border);
  padding: 0.45rem 0.65rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.75rem;
  color: var(--warning-text);
  margin-bottom: 1rem;
  line-height: 1.35;
  display: flex;
  gap: 0.4rem;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #edf1ee;
  padding-top: 0.85rem;
  margin-top: 0.5rem;
}

.card-action-btns {
  display: flex;
  gap: 0.4rem;
}

.btn-card-action {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  font-weight: 500;
}

.btn-card-action:hover {
  background: var(--bg-surface);
  color: var(--primary-deep);
  border-color: var(--primary);
}

.btn-card-action.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* ==========================================================================
   TABLE VIEW
   ========================================================================== */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  background: #f2f6f3;
  color: var(--primary-deep);
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #edf1ee;
  vertical-align: middle;
}

.data-table tr:hover {
  background: #fbfdfc;
}

.table-med-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--primary-deep);
  cursor: pointer;
}

.table-med-name:hover {
  color: var(--gold);
  text-decoration: underline;
}

/* ==========================================================================
   PAGINATION (5 Cards / Items Per Page)
   ========================================================================== */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 0.9rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.pagination-info {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-page-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--primary-deep);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-page-nav:hover:not(:disabled) {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-page-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f8faf9;
  border-color: var(--border);
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.page-num-btn {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.page-num-btn:hover:not(.active) {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.page-num-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(30, 92, 59, 0.28);
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3.5rem 1.5rem;
  text-align: center;
  margin: 1.5rem 0;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.85;
}

.empty-state h3 {
  font-family: var(--font-serif);
  color: var(--primary-deep);
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 500px;
  margin: 0 auto 1.5rem auto;
}

.empty-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 16, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-container {
  background: var(--bg-card);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: modalScaleIn 0.22s ease-out;
  overflow: hidden;
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 1.1rem 1.5rem;
  background: linear-gradient(135deg, #1b4530 0%, #133926 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--gold);
}

.modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modal-badge {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--gold-light);
  text-transform: uppercase;
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: #ffffff;
}

.modal-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

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

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

.col-span-2 {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-deep);
}

.form-label.required::after {
  content: " *";
  color: var(--accent-warm);
}

.field-tip {
  font-size: 0.72rem;
  color: var(--text-light);
}

.form-control {
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  transition: all 0.2s ease;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(28, 82, 54, 0.12);
}

.form-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f7faf8;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   REDUNDANCY WARNING & AUTOFILL BANNERS
   ========================================================================== */
.alert-box {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.alert-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.alert-content {
  flex: 1;
}

.alert-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.alert-content p {
  font-size: 0.8rem;
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

.alert-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.autofill-banner {
  background: linear-gradient(135deg, #e7f5ed 0%, #f3faf5 100%);
  border: 1px solid #bce1cb;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.autofill-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.autofill-text {
  flex: 1;
}

.autofill-text span {
  display: block;
  font-size: 0.85rem;
  color: var(--primary-deep);
}

.autofill-text small {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.status-indicator {
  font-size: 0.74rem;
  font-weight: 600;
}

.status-indicator.valid {
  color: var(--primary);
}

.status-indicator.redundant {
  color: var(--accent-warm);
}

/* ==========================================================================
   TAG INPUTS & AUTOCOMPLETE
   ========================================================================== */
.input-with-autocomplete {
  position: relative;
}

.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  min-height: 48px;
  cursor: text;
  transition: all 0.2s ease;
  position: relative;
}

.tag-input-container:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(28, 82, 54, 0.12);
}

.tags-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.interactive-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-subtle);
  color: var(--primary-deep);
  border: 1px solid #cce5d6;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  animation: tagFadeIn 0.15s ease-out;
}

@keyframes tagFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.interactive-tag .tag-remove {
  cursor: pointer;
  font-weight: bold;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.interactive-tag .tag-remove:hover {
  opacity: 1;
  color: var(--danger);
}

.tag-inner-input {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 140px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-main);
  padding: 0.25rem 0.2rem;
}

.tag-inner-input:focus {
  outline: none;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1050;
  margin-top: 2px;
}

.autocomplete-item {
  padding: 0.6rem 0.85rem;
  font-size: 0.84rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f2f5f3;
  transition: background 0.12s ease;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--primary-subtle);
  color: var(--primary-deep);
}

.autocomplete-item small {
  font-size: 0.72rem;
  color: var(--text-light);
}

/* Quick Chips */
.quick-chips-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.quick-chips-label {
  font-size: 0.72rem;
  color: var(--text-light);
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip-btn {
  background: #edf2ee;
  border: 1px solid #d9e4dc;
  border-radius: var(--radius-full);
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-light);
  color: var(--primary-deep);
}

.chip-compound {
  background: #fdf5e6;
  border-color: #eed5a1;
  color: #8c5b05;
  font-weight: 600;
}

.chip-compound:hover {
  background: #faeccd;
  border-color: var(--gold);
  color: #6d4400;
}

.chip-accent {
  background: #e9f3ed;
  border-color: #badcc8;
  color: var(--primary);
  font-weight: 600;
}

.chip-accent:hover {
  background: #d4ebd9;
  border-color: var(--primary);
  color: var(--primary-deep);
}

/* Master Autofill Toolbar */
.autofill-toolbar-card {
  background: linear-gradient(135deg, #f6faf7 0%, #fefcf7 100%);
  border: 1.5px solid #d4e5da;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin-bottom: 1.35rem;
  box-shadow: 0 2px 8px rgba(19, 57, 38, 0.04);
}

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

.toolbar-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.toolbar-heading {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-deep);
  line-height: 1.2;
}

.toolbar-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.autofill-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.autofill-toolbar-select-row {
  margin-top: 0.4rem;
}

.select-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.select-icon {
  position: absolute;
  left: 0.85rem;
  font-size: 1.05rem;
  color: var(--gold);
  pointer-events: none;
}

.template-select {
  padding-left: 2.35rem !important;
  font-weight: 600;
  color: var(--primary-deep);
  border-color: #cbd8ce;
  background-color: #ffffff !important;
}

.template-select:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(179, 130, 42, 0.15) !important;
}

.compound-chips-group {
  display: inline-flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   DETAIL VIEW MONOGRAPH MODAL
   ========================================================================== */
.detail-modal-container {
  max-width: 860px;
}

.modal-header-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex: 1;
}

.detail-hero-box {
  background: #f8faf8;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.detail-meta-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.05em;
}

.detail-meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.highlight-reference {
  color: var(--gold);
  font-family: var(--font-serif);
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-deep);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-bottom: 1px solid #eef2ef;
  padding-bottom: 0.35rem;
}

.detail-section-title.precaution-title {
  color: #a45308;
}

.pills-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pills-cloud .pill {
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
}

.precaution-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: #633c00;
  line-height: 1.5;
}

.pharmacy-grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.pharmacy-item-badge {
  background: #f1f4f8;
  border: 1px solid #d8e2ef;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: #173868;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.detail-footer-meta {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-light);
}

.dosage-form-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 0.2rem;
}

/* ==========================================================================
   GLOBAL TOAST NOTIFICATION
   ========================================================================== */
.notification-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary-deep);
  color: #ffffff;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--gold);
  z-index: 2000;
  font-size: 0.88rem;
  font-weight: 500;
  animation: toastSlideUp 0.25s ease-out;
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
  body * {
    visibility: hidden;
  }
  .printable, .printable * {
    visibility: visible;
  }
  .printable {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 2cm;
  }
  .modal-overlay {
    position: static;
    background: none;
  }
  .modal-container {
    box-shadow: none;
    border: none;
    max-height: none;
  }
  .modal-header, .modal-footer, .header-actions, .app-header {
    display: none !important;
  }
}

/* ==========================================================================
   PHP SECURITY BADGE & NOTICE BANNER
   ========================================================================== */
.security-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.security-status-badge.php-secured {
  background: rgba(223, 171, 75, 0.2);
  color: var(--gold-light);
  border: 1px solid rgba(223, 171, 75, 0.5);
}

.security-status-badge.offline-mode {
  background: rgba(255, 255, 255, 0.15);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.backend-notice-banner {
  background: linear-gradient(135deg, #fefbf3 0%, #fff9eb 100%);
  border: 1px solid #f2db9b;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #795508;
}

.backend-notice-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.backend-notice-text {
  flex: 1;
}

.backend-notice-text strong {
  color: var(--primary-deep);
  margin-right: 0.35rem;
}

/* ==========================================================================
   RESPONSIVE QUERIES
   ========================================================================== */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .medicine-search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .pagination-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.85rem;
  }
  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  .medicine-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .col-span-2 {
    grid-column: span 1;
  }
}
