/* ═══════════════════════════════════════════════════════════
   OptiVision — Design System
   A premium dark-themed clinical management UI
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables (Design Tokens) ────────────────────────── */
:root {
  /* Brand accents */
  --primary: #f2892d;
  --primary-light: #ffa453;
  --primary-dark: #d76f12;
  --primary-glow: rgba(242, 137, 45, 0.18);
  --accent: #2d34b0;
  --accent-light: #dde1ff;
  
  /* Status colors */
  --warning: #f4b24e;
  --danger: #d05a5a;
  --danger-dark: #b54545;
  --success: #2f9d68;
  --info: #377dff;

  /* Surfaces */
  --bg-primary: #eef3ff;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fbff;
  --bg-input: #ffffff;
  --bg-modal: #ffffff;
  --bg-sidebar: #0e1f56;

  /* Typography */
  --text-primary: #1d2740;
  --text-secondary: #4a5b79;
  --text-muted: #7e8ba8;
  --text-inverse: #ffffff;

  /* Borders & Shadows */
  --border: #d8e0f1;
  --border-light: #edf2ff;
  --border-focus: #2d34b0;

  --shadow-sm: 0 8px 20px rgba(14, 31, 86, 0.07);
  --shadow-md: 0 18px 36px rgba(14, 31, 86, 0.12);
  --shadow-lg: 0 30px 60px rgba(9, 22, 49, 0.16);
  --shadow-glow: 0 4px 20px var(--primary-glow);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --topbar-height: 64px;

  /* Fonts */
  --font-serif: 'Cormorant Garamond', 'Playfair Display', serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font: var(--font-sans);
  
  --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
h1, h2, h3, h4, h5 { font-family: var(--font-serif); font-weight: 500; line-height: 1.3; color: var(--accent); letter-spacing: 0.5px; }
h1 i, h2 i, h3 i, h4 i, h5 i, h1 em, h2 em, h3 em, h4 em, h5 em { color: var(--primary); font-style: italic; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Login Screen ─────────────────────────────────────────── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(242, 137, 45, 0.14), transparent 32%),
    radial-gradient(circle at bottom right, rgba(45, 52, 176, 0.24), transparent 36%),
    linear-gradient(145deg, #091631 0%, #152d73 52%, #0a1f4d 100%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid rgba(45, 52, 176, 0.12);
  border-radius: 28px;
  padding: 48px 40px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease;
  position: relative;
  overflow: hidden;
}
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--accent), var(--primary), var(--accent)); }
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo-image { width: 220px; max-width: 100%; }
.login-logo p { color: var(--text-secondary); font-size: 13px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; margin-top: 16px; }
.login-demo { text-align: center; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.login-demo p { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.login-demo small { color: var(--text-secondary); font-size: 11px; }

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

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); background: linear-gradient(180deg, #0b1a47 0%, #132d73 100%); border-right: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: width var(--transition);
  color: rgba(255,255,255,0.88);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label, .sidebar.collapsed .sidebar-title, .sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-footer { flex-direction: column; align-items: center; gap: 8px; }
.sidebar.collapsed .user-info { justify-content: center; }

.sidebar-header { display: flex; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo-image { width: 38px; height: 38px; object-fit: contain; flex-shrink: 0; }
.sidebar-title { font-family: var(--font-serif); font-size: 24px; font-weight: 600; color: #ffffff; letter-spacing: 0.5px; }
.sidebar-toggle { display: none; background: none; border: none; color: rgba(255,255,255,0.72); cursor: pointer; margin-left: auto; padding: 4px; border-radius: var(--radius-sm); transition: color var(--transition); }
.sidebar-toggle:hover { color: #ffffff; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 24px; margin: 4px 12px;
  color: rgba(255,255,255,0.74); border-radius: 14px; transition: all var(--transition); font-weight: 600; font-size: 13px; letter-spacing: 0.3px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #ffffff; }
.nav-item.active { background: linear-gradient(135deg, var(--primary), #f47b1c); color: #ffffff; box-shadow: 0 12px 24px rgba(242, 137, 45, 0.22); }
.nav-item .material-icons-round { font-size: 20px; opacity: 0.8; }
.nav-item.active .material-icons-round { opacity: 1; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-info .material-icons-round { font-size: 32px; color: rgba(255,255,255,0.84); }
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.62); text-transform: capitalize; }

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

.top-bar {
  height: var(--topbar-height); display: flex; align-items: center; gap: 16px;
  padding: 0 28px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.top-bar h2 { font-size: 18px; font-weight: 700; flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-menu { display: none; }

.content-area { flex: 1; padding: 24px 28px; overflow-y: auto; }

/* ── Cards & Panels ───────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 24px; transition: all var(--transition); position: relative;
  box-shadow: var(--shadow-sm);
}
.card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--primary-glow), transparent); opacity: 0; transition: opacity var(--transition); }
.card:hover { border-color: var(--border-light); box-shadow: var(--shadow-md); }
.card:hover::before { opacity: 1; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-header h3 { font-size: 18px; font-weight: 500; }

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 24px; display: flex; align-items: center; gap: 20px; transition: all var(--transition); position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.stat-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; background: var(--bg-secondary); border: 1px solid var(--border); }
.stat-icon.purple { color: #8A6ba8; }
.stat-icon.green { color: #699e74; }
.stat-icon.orange { color: #c98a4c; }
.stat-icon.red { color: #c55353; }
.stat-icon.blue { color: #5a8ab4; }
.stat-icon.teal { color: #68a186; }
.stat-icon .material-icons-round { color: var(--primary); }
.stat-info h4 { font-size: 26px; font-weight: 500; font-family: var(--font-serif); color: var(--text-primary); line-height: 1.1; margin-bottom: 4px; }
.stat-info p { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 13px; font-weight: 500; letter-spacing: 0.5px; cursor: pointer; transition: all var(--transition); white-space: nowrap; text-transform: uppercase;
}
.btn .material-icons-round { font-size: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--text-inverse); font-weight: 700; box-shadow: 0 10px 22px rgba(242, 137, 45, 0.25); }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-light), var(--primary)); box-shadow: 0 14px 28px rgba(242, 137, 45, 0.34); transform: translateY(-2px); }
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid rgba(45, 52, 176, 0.28); }
.btn-secondary:hover { background: rgba(45, 52, 176, 0.08); border-color: var(--accent); color: var(--accent); }
.btn-success { background: transparent; color: var(--success); border: 1px solid var(--success); }
.btn-success:hover { background: rgba(108, 166, 118, 0.1); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(217, 108, 108, 0.1); }
.btn-warning { background: transparent; color: var(--warning); border: 1px solid var(--warning); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-sm .material-icons-round { font-size: 16px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-icon { background: none; border: 1px solid var(--border); color: var(--text-secondary); width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); }
.btn-icon:hover { background: var(--bg-card); color: var(--accent); border-color: rgba(45, 52, 176, 0.2); }
.btn-group { display: flex; gap: 8px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary); font-family: var(--font); font-size: 13px;
  transition: all var(--transition); outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-group input::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239B9FB5' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.password-toggle:hover { color: var(--primary); background: var(--primary-glow); }
.password-toggle .material-icons-round { font-size: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 8px; padding: 8px 12px; background: rgba(255,107,107,0.1); border-radius: var(--radius-sm); }
.form-section { margin-bottom: 24px; }
.form-section h4 { font-size: 14px; font-weight: 600; color: var(--primary-light); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-container { overflow-x: auto; background: var(--bg-card); border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--bg-secondary); color: var(--primary); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; padding: 14px 20px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
tbody td { padding: 14px 20px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(0,0,0,0.02); }
tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; }

/* ── Status Badges ────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid transparent; }
.badge-booked { border-color: rgba(108,140,166,0.3); color: var(--info); }
.badge-arrived { background: rgba(201, 168, 76, 0.15); border-color: var(--primary-dark); color: var(--primary-light); box-shadow: 0 0 8px rgba(201,168,76,0.2); }
.badge-confirmed { border-color: rgba(108,166,118,0.3); color: var(--success); }
.badge-in-progress { border-color: rgba(212,163,115,0.3); color: var(--warning); }
.badge-completed { border-color: rgba(108,166,118,0.3); background: rgba(108,166,118,0.1); color: var(--success); }
.badge-cancelled { border-color: rgba(217,108,108,0.3); color: var(--danger); }
.badge-no-show { border-color: rgba(120,125,148,0.3); color: var(--text-muted); }
.badge-pending { border-color: rgba(212,163,115,0.3); color: var(--warning); }
.badge-in-lab { border-color: rgba(108,140,166,0.3); color: var(--info); }
.badge-ready { border-color: rgba(201,168,76,0.3); color: var(--primary); }
.badge-delivered { border-color: rgba(108,166,118,0.3); background: rgba(108,166,118,0.1); color: var(--success); }
.badge-draft { border-color: rgba(120,125,148,0.3); color: var(--text-muted); }
.badge-issued { border-color: rgba(108,140,166,0.3); color: var(--info); }
.badge-partial { border-color: rgba(212,163,115,0.3); color: var(--warning); }
.badge-paid { border-color: rgba(108,166,118,0.3); background: rgba(108,166,118,0.1); color: var(--success); }
.badge-admin { border-color: rgba(217,108,108,0.3); color: var(--danger); }
.badge-optometrist { border-color: rgba(201,168,76,0.3); color: var(--primary); }
.badge-receptionist { border-color: rgba(108,140,166,0.3); color: var(--info); }
.badge-technician { border-color: rgba(212,163,115,0.3); color: var(--warning); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(44, 41, 37, 0.6); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.3s ease; }
.modal { background: var(--bg-modal); border: 1px solid var(--border); border-radius: var(--radius-md); width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideInUp 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); }
.modal.modal-lg { max-width: 900px; }
.modal.modal-sm { max-width: 440px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 32px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 22px; font-weight: 500; font-family: var(--font-serif); color: var(--primary); margin: 0; }
.modal-body { padding: 32px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 20px 32px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; background: var(--bg-secondary); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); transition: color var(--transition); }
.modal-close:hover { color: var(--danger); }

.invoice-brand-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(45, 52, 176, 0.06), rgba(242, 137, 45, 0.08));
}
.invoice-brand-logo {
  width: 132px;
  max-width: 38%;
  object-fit: contain;
  flex-shrink: 0;
}
.invoice-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.invoice-brand-title {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--accent);
  line-height: 1.1;
}
.invoice-brand-subtitle {
  font-size: 12px;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-weight: 700;
}

/* ── Search & Toolbar ──────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { width: 100%; padding: 10px 14px 10px 40px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px; outline: none; transition: all var(--transition); }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-box .material-icons-round { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 20px; }
.filter-select { padding: 10px 36px 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px; outline: none; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239B9FB5' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; transition: all var(--transition); }
.filter-select:focus { border-color: var(--primary); }
.filter-select-wide { min-width: 240px; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px; }
.pagination button { padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: 12px; font-weight: 500; transition: all var(--transition); }
.pagination button:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-info { font-size: 12px; color: var(--text-muted); margin: 0 12px; }

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: var(--radius-md);
  max-width: 380px; min-width: 280px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideInRight 0.3s ease; transition: all var(--transition);
}
.toast-success { background: #0d3320; border: 1px solid #1a5c38; color: var(--success); }
.toast-error { background: #3d1515; border: 1px solid #5c1a1a; color: var(--danger); }
.toast-info { background: #0d2133; border: 1px solid #1a385c; color: var(--info); }
.toast-warning { background: #332d0d; border: 1px solid #5c4f1a; color: var(--warning); }
.toast .material-icons-round { font-size: 20px; }
.toast-close { margin-left: auto; cursor: pointer; opacity: 0.7; background:none; border:none; color:inherit; }
.toast-close:hover { opacity: 1; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .material-icons-round { font-size: 64px; color: var(--text-muted); margin-bottom: 16px; }

/* Fallback appearance when Material Icons webfont is unavailable */
.material-icons-round.icon-fallback-active {
  font-family: "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

/* ── Detail View ──────────────────────────────────────────── */
.detail-header { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
.detail-header .back-btn { cursor: pointer; }
.detail-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.detail-tab { padding: 12px 24px; color: var(--text-secondary); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none; }
.detail-tab:hover { color: var(--text-primary); border-bottom-color: var(--border-light); }
.detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Prescription Display ─────────────────────────────────── */
.rx-table { display: grid; grid-template-columns: 80px repeat(5, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius-md); overflow: hidden; margin: 16px 0; }
.rx-cell { background: var(--bg-card); padding: 10px 12px; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.rx-header { background: var(--bg-secondary); font-weight: 600; color: var(--text-secondary); font-size: 11px; text-transform: uppercase; }
.rx-label { background: var(--bg-secondary); font-weight: 600; justify-content: flex-start; }

/* ── Calendar View ────────────────────────────────────────── */
.rx-sheet {
  background: linear-gradient(180deg, #f4f8ff 0%, #fcfdff 100%);
  border: 1px solid #b7c6ec;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 16px 34px rgba(79, 109, 182, 0.12);
}
.rx-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 2px solid #d7e1f6;
}
.rx-sheet-brand { display: flex; flex-direction: column; gap: 8px; }
.rx-sheet-brand-logo { width: 190px; max-width: 100%; }
.rx-sheet-subtitle {
  font-size: 14px;
  font-weight: 700;
  color: #f2892d;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.rx-sheet-contact {
  text-align: right;
  font-size: 12px;
  color: #52678f;
  line-height: 1.5;
}
.rx-sheet-contact-name {
  color: #294a97;
  font-weight: 700;
  font-size: 14px;
}
.rx-sheet-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.rx-sheet-field {
  border-bottom: 1px solid #9eb0da;
  padding-bottom: 8px;
  min-height: 62px;
}
.rx-sheet-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #5b6f9d;
  margin-bottom: 6px;
}
.rx-sheet-field input,
.rx-sheet-field select,
.rx-sheet textarea,
.rx-sheet-drug-row input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.78);
  border: 1px solid #c1cfee;
  border-radius: 10px;
  border-color: #c1cfee;
  color: #1f2f57;
  font-family: var(--font);
  font-size: 13px;
  transition: all var(--transition);
  outline: none;
}
.rx-sheet textarea { min-height: 128px; resize: vertical; }
.rx-sheet-field input:focus,
.rx-sheet-field select:focus,
.rx-sheet textarea:focus,
.rx-sheet-drug-row input:focus {
  border-color: #4f6db6;
  box-shadow: 0 0 0 3px rgba(79, 109, 182, 0.15);
}
.rx-sheet-static {
  min-height: 36px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #20345d;
  font-weight: 600;
}
.rx-sheet-static-cap { text-transform: capitalize; }
.rx-sheet-block {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid #d4def3;
  border-radius: 14px;
  background: rgba(255,255,255,0.64);
}
.rx-sheet-block-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #35508d;
  margin-bottom: 12px;
}
.rx-sheet-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
}
.rx-sheet-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-size: 12px;
  color: #24427a;
}
.rx-sheet-option input {
  width: 16px;
  height: 16px;
  accent-color: #3d5fae;
}
.rx-sheet-option-box {
  width: 16px;
  height: 16px;
  border: 1px solid #5571b1;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #27448a;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
}
.rx-sheet-option.checked span:last-child { font-weight: 700; }
.rx-sheet-table-wrap { overflow-x: auto; }
.rx-sheet-grid {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #8ea0cc;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.rx-sheet-grid thead th {
  position: static;
  background: #edf2ff;
  color: #284585;
  border: 1px solid #8ea0cc;
  font-size: 11px;
  padding: 10px 8px;
  text-align: center;
}
.rx-sheet-grid tbody th,
.rx-sheet-grid tbody td {
  border: 1px solid #b9c7e6;
  padding: 10px 8px;
  font-size: 12px;
  text-align: center;
  color: #233965;
}
.rx-sheet-grid tbody th {
  background: #f6f9ff;
  font-weight: 700;
  text-align: left;
  min-width: 92px;
}
.rx-sheet-grid input {
  width: 100%;
  min-width: 70px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 8px;
}
.rx-sheet-help {
  text-align: left !important;
  color: #4f628c !important;
  background: #f8fbff;
  font-size: 11px !important;
}
.rx-sheet-secondary {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
.rx-sheet-notes-readonly {
  min-height: 128px;
  padding: 12px 14px;
  border: 1px solid #d4def3;
  border-radius: 12px;
  background: rgba(255,255,255,0.86);
  color: #20345d;
  white-space: pre-wrap;
}
.rx-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.rx-quick-chip {
  border-radius: 999px;
  font-size: 11px;
  padding: 6px 10px;
  text-transform: none;
  letter-spacing: 0;
}
.rx-sheet-drug-list { display: flex; flex-direction: column; gap: 10px; }
.rx-sheet-drug-row {
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 0;
}
.rx-sheet-drug-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #d4def3;
  border-radius: 12px;
  background: rgba(255,255,255,0.86);
  color: #20345d;
}
.rx-sheet-drug-pill strong { color: #284585; }
.rx-sheet-drug-pill span { color: #5a6f9a; font-size: 12px; }
.rx-sheet-muted {
  color: #6b7fa8;
  font-size: 12px;
}

.sms-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sms-hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  padding: 24px;
  border: 1px solid rgba(61, 95, 174, 0.16);
}
.sms-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 8px;
}
.sms-hero-copy h3 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 28px;
}
.sms-hero-copy p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 720px;
}
.sms-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.sms-mini-stat {
  border: 1px solid rgba(61, 95, 174, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sms-mini-stat strong {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}
.sms-mini-stat span {
  color: var(--text-secondary);
  font-size: 12px;
}
.sms-layout {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 20px;
}
.sms-card-body {
  padding: 20px;
}
.sms-helper {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}
.sms-template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sms-template-btn {
  white-space: nowrap;
}
.sms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}
.sms-preview-card {
  display: flex;
  flex-direction: column;
}
.sms-preview-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}
.sms-preview-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.sms-preview-stat {
  padding: 14px 16px;
  border-radius: 14px;
  background: #f6f8ff;
  border: 1px solid rgba(61, 95, 174, 0.12);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sms-preview-stat strong {
  color: var(--primary);
  font-size: 24px;
  line-height: 1;
}
.sms-preview-stat span {
  color: var(--text-secondary);
  font-size: 12px;
}
.sms-preview-message {
  min-height: 180px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f6f8ff);
  border: 1px solid rgba(61, 95, 174, 0.14);
  color: var(--text-primary);
  white-space: pre-wrap;
  line-height: 1.7;
}
.sms-preview-message.is-placeholder {
  color: var(--text-secondary);
}
.sms-preview-note {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}
.sms-result {
  border-top: 1px solid rgba(61, 95, 174, 0.12);
  padding: 18px 20px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: pre-wrap;
}
.sms-result strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.sms-result-list,
.sms-result-meta {
  margin-top: 8px;
  line-height: 1.6;
  word-break: break-word;
}
.sms-result-pending {
  color: var(--warning);
}
.sms-result-success strong {
  color: var(--success);
}
.sms-result-error strong {
  color: var(--danger);
}

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius-md); overflow: hidden; }
.calendar-day-header { background: var(--bg-secondary); padding: 10px; text-align: center; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; }
.calendar-day { background: var(--bg-card); min-height: 100px; padding: 8px; cursor: pointer; transition: background var(--transition); }
.calendar-day:hover { background: var(--bg-card-hover); }
.calendar-day.today { border: 2px solid var(--primary); }
.calendar-day.other-month { opacity: 0.4; }
.calendar-date { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.calendar-event { font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.calendar-event.eye-exam { background: rgba(108,99,255,0.2); color: var(--primary-light); }
.calendar-event.follow-up { background: rgba(0,217,166,0.2); color: var(--accent); }
.calendar-event.contact-lens-fitting { background: rgba(255,179,71,0.2); color: var(--warning); }
.calendar-event.emergency { background: rgba(255,107,107,0.2); color: var(--danger); }
.calendar-event.consultation { background: rgba(77,166,255,0.2); color: var(--info); }

/* ── Chart Container ──────────────────────────────────────── */
.chart-container { position: relative; height: 240px; margin-top: 12px; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 100%; padding: 0 4px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { background: linear-gradient(to top, var(--primary), var(--primary-light)); border-radius: 4px 4px 0 0; width: 100%; min-height: 4px; transition: height 0.5s ease; position: relative; }
.bar:hover { background: linear-gradient(to top, var(--primary-light), var(--accent-light)); }
.bar-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.bar-value { font-size: 10px; color: var(--text-secondary); font-weight: 600; }
.donut-chart { display: flex; align-items: center; justify-content: center; gap: 32px; padding: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-in { animation: fadeInUp 0.4s ease; }
.loading { animation: pulse 1.5s ease-in-out infinite; }

/* ── Low Stock Alert ──────────────────────────────────────── */
.low-stock { color: var(--danger) !important; font-weight: 700; }
.stock-ok { color: var(--success); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .mobile-menu { display: flex !important; }
  .top-bar { padding: 0 16px; }
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal { max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); }
  .rx-table { grid-template-columns: 60px repeat(5, 1fr); font-size: 11px; }
  .rx-sheet-meta,
  .rx-sheet-secondary,
  .rx-sheet-options { grid-template-columns: 1fr; }
  .rx-sheet-header { flex-direction: column; align-items: flex-start; }
  .rx-sheet-contact { text-align: left; }
  .rx-sheet-drug-row { grid-template-columns: 1fr; }
  .sms-hero,
  .sms-layout { grid-template-columns: 1fr; }
  .sms-hero-stats,
  .sms-preview-meta { grid-template-columns: 1fr; }
  .sms-actions { justify-content: stretch; flex-direction: column; }
  .sms-actions .btn { width: 100%; }
  .calendar-day { min-height: 60px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: unset; }
  .sidebar-toggle { display: block; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
}
