@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --sidebar-bg: #1e293b;
  --sidebar-dark: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-hover: #334155;
  --sidebar-active: #0f172a;
  
  --bg-main: #f3f4f6;
  --card-bg: #ffffff;
  
  --text-main: #111827;
  --text-muted: #6b7280;
  
  --border-color: #e5e7eb;
  
  --primary-blue: #0284c7;
  --primary-hover: #0369a1;
  
  --success-green: #15803d;
  --danger-red: #b91c1c;
  
  --font-family: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
}

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

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-nav {
  flex-grow: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  gap: 1rem;
}

.nav-item i { width: 20px; text-align: center; }

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: white;
}

.float-right { margin-left: auto; font-size: 0.8rem; }

.active-group {
  background-color: var(--sidebar-active);
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}
.nav-group-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  gap: 1rem;
  color: white;
  border-left: 3px solid var(--primary-blue);
}
.nav-subitem {
  display: block;
  padding: 0.5rem 1.5rem 0.5rem 3.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
}
.nav-subitem.active { color: white; }
.nav-subitem:hover { color: white; }

.nav-section-title {
  padding: 1.5rem 1.5rem 0.5rem 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.dashboard-ad {
  margin: 1rem 1rem;
  background-color: var(--primary-blue);
  border-radius: 8px;
  padding: 1rem;
  color: white;
}
.dashboard-ad i { font-size: 1.25rem; margin-bottom: 0.5rem; }
.dashboard-ad p { font-size: 0.8rem; line-height: 1.4; margin: 0.5rem 0; opacity: 0.9; }
.dashboard-ad button { background: #facc15; border: none; padding: 0.25rem 0.75rem; border-radius: 4px; font-weight: 600; font-size: 0.75rem; cursor: pointer; color: #111827; }

.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.05); }
.quick-order-btn { width: 100%; background: #334155; color: white; border: none; padding: 0.75rem; border-radius: 6px; display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; }
.quick-order-btn:hover { background: #475569; }

/* Main Content Area */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 60px;
  background-color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.topbar-left { cursor: pointer; font-size: 1.25rem; }
.topbar-center h1 { font-size: 1.25rem; font-weight: 600; color: var(--text-main); margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; font-weight: 500; cursor: pointer; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; }

/* Page Content */
.page-content {
  padding: 1.5rem;
  overflow-y: auto;
  height: calc(100vh - 60px);
}

/* Grid Layout for Forms */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Form Groups and Inputs with Icons */
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon-wrapper i, .input-icon-wrapper .icon-text {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: #f9fafb;
  border: 1px solid var(--border-color);
  border-right: none;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  font-size: 0.9rem;
}
.input-icon-wrapper input, .input-icon-wrapper select {
  width: 100%;
  padding: 0.5rem 0.5rem 0.5rem 44px; /* Space for icon */
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.input-icon-wrapper input:focus, .input-icon-wrapper select:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 1px var(--primary-blue);
}

/* Verify Button appended to input */
.input-with-button {
  display: flex;
}
.input-with-button input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-with-button button {
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  border-left: none;
  padding: 0 1rem;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Clinical Table Grid */
.clinical-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.clinical-table th, .clinical-table td {
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  text-align: center;
}
.clinical-table th {
  background: #f9fafb;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.clinical-table td { background: white; padding: 0; }
.clinical-table td.row-label {
  background: #f3f4f6;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem;
}
.clinical-table input {
  width: 100%;
  border: none;
  text-align: center;
  font-size: 0.9rem;
  outline: none;
  padding: 0.75rem 0.5rem;
}
.clinical-table input:focus {
  background: #f0f9ff;
}

/* Right Sticky Panel (Summary) */
.summary-card {
  position: sticky;
  top: 0;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.summary-divider {
  height: 1px;
  background: var(--border-color);
  margin: 1rem 0;
}
.summary-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.summary-total.green { color: var(--success-green); }
.summary-total.red { color: var(--danger-red); }

.payment-history { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.8rem; }
.payment-history th { text-align: left; background: #f9fafb; padding: 0.5rem; border: 1px solid var(--border-color); }
.payment-history td { padding: 0.5rem; border: 1px solid var(--border-color); }

/* ==========================================
   BUTTONS — Standard System
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  border: none;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s;
  line-height: 1.4;
}
.btn-primary { background: var(--primary-blue); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-secondary:hover { background: #f9fafb; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }

/* Inline (for table rows) */
.btn-sm {
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 4px;
}

/* ==========================================
   DATA TABLE — For Grids / Lists (not clinical)
   ========================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table thead th {
  background: var(--sidebar-bg);
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.75rem 1rem;
  text-align: center;
  border: none;
}
.data-table tbody td {
  padding: 0.7rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.data-table tbody tr:nth-child(even) { background: #f9fafb; }
.data-table tbody tr:hover { background: #f0f9ff; }

/* Action cell: flex to space buttons */
.data-table .actions-cell {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  align-items: center;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ==========================================
   FORM CONTROL — Standalone input/select
   ========================================== */
.form-control {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  height: 38px;
}
.form-control:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 1px var(--primary-blue);
}
select.form-control { appearance: auto; }

/* ==========================================
   SECTION — Bordered panel inside a card
   ========================================== */
.section-panel {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.section-panel h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

