/* ============================================================
   PharmaSaaS - Main Application Stylesheet
   Theme: Clinical Clean + Professional Green
   ============================================================ */

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

/* ─── CSS Variables ──────────────────────────────────────── */
:root {
  --primary:        #0d6832;
  --primary-light:  #19a54f;
  --primary-dark:   #094822;
  --primary-bg:     #f0faf4;
  --accent:         #00c97a;
  --accent-light:   #e6fff3;
  --danger:         #dc2626;
  --warning:        #d97706;
  --info:           #0284c7;
  --success:        #16a34a;
  --sidebar-width:  260px;
  --topbar-height:  64px;
  --sidebar-bg:     #0a1628;
  --sidebar-text:   #94a3b8;
  --sidebar-hover:  rgba(255,255,255,0.07);
  --sidebar-active: rgba(13,104,50,0.9);
  --card-radius:    12px;
  --font:           'Plus Jakarta Sans', sans-serif;
  --mono:           'JetBrains Mono', monospace;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:         0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:      0 10px 25px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.06);
  --transition:     all .2s cubic-bezier(.4,0,.2,1);
}

/* ─── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: #1e293b;
  background: #f1f5f9;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  padding: 0 20px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.brand-sub {
  color: var(--sidebar-text);
  font-size: 10px;
  display: block;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-search {
  padding: 10px 14px 0;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: #e2e8f0;
  outline: none;
  transition: all .2s;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,.35); }
.sidebar-search input:focus { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(148,163,184,.5);
}

.nav-item { margin: 1px 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  border-radius: 8px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13,104,50,.4);
}

.nav-link .nav-icon {
  width: 18px;
  text-align: center;
  opacity: .8;
  flex-shrink: 0;
}

.nav-link.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  transition: var(--transition);
  text-decoration: none;
  cursor: pointer;
}

.user-card:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { color: var(--sidebar-text); font-size: 11px; }

/* ─── Main Content ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

.topbar-breadcrumb {
  font-size: 12px;
  color: #64748b;
  margin-top: 1px;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}

.topbar-btn:hover { background: #f8fafc; border-color: #cbd5e1; color: #1e293b; }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ─── Page Content ───────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ─── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.page-header-title p {
  color: #64748b;
  font-size: 13px;
  margin: 4px 0 0;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid #f1f5f9; }

/* ─── Stat Cards ─────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}

.stat-card.green::before  { background: var(--primary-light); }
.stat-card.blue::before   { background: var(--info); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before    { background: var(--danger); }

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-meta {
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-meta.up   { color: var(--success); }
.stat-meta.down { color: var(--danger); }

.stat-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  opacity: .15;
}

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--card-radius); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead th {
  background: #f8fafc;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  padding: 10px 16px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: var(--transition);
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child { border-bottom: none; }

.table td {
  padding: 12px 16px;
  vertical-align: middle;
  color: #374151;
}

/* ─── Badges / Status ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: #f0fdf4; color: #166534; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.5;
  white-space: nowrap;
}

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-icon { padding: 8px; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline-primary { border: 1.5px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-secondary { border: 1.5px solid #e2e8f0; color: #64748b; background: transparent; }
.btn-outline-secondary:hover { background: #f8fafc; border-color: #cbd5e1; color: #1e293b; }
.btn-light { background: #f1f5f9; color: #374151; }
.btn-light:hover { background: #e2e8f0; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
  display: block;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: var(--font);
  color: #1e293b;
  background: #fff;
  transition: var(--transition);
  outline: none;
  appearance: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(25,165,79,.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 11.5px; color: var(--danger); margin-top: 4px; }

.form-hint { font-size: 11.5px; color: #94a3b8; margin-top: 4px; }

.input-group { display: flex; }
.input-group .form-control { border-radius: 8px 0 0 8px; }
.input-group .btn { border-radius: 0 8px 8px 0; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.page-link {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1.5px solid #e2e8f0;
  color: #374151;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.page-link:hover { background: #f8fafc; border-color: #cbd5e1; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ─── Subscription Banner ────────────────────────────────── */
.sub-warning-bar {
  background: linear-gradient(90deg, #f59e0b, #d97706);
  color: #fff;
  padding: 8px 24px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ─── Loading Overlay ────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.loading-overlay.active { display: flex; }

.spinner {
  width: 42px; height: 42px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ─── Sidebar Toggle (Mobile) ────────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #64748b;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
  }
  .sidebar-overlay.active { display: block; }
}

@media (max-width: 768px) {
  .page-content { padding: 16px; }
  .stat-value { font-size: 22px; }
}

/* ─── Utilities ──────────────────────────────────────────── */
.text-muted    { color: #94a3b8 !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger) !important; }
.text-warning  { color: var(--warning) !important; }
.text-primary  { color: var(--primary) !important; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.font-mono     { font-family: var(--mono); }
.cursor-pointer { cursor: pointer; }
.border-radius-lg { border-radius: var(--card-radius); }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
