/* Dr. Aravindh Clinic OS v3 - Master CSS Design System */
:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Theme Colors - Deep Obsidian & Electric Accents */
  --bg-app: #080c14;
  --bg-surface: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-glass: rgba(15, 23, 42, 0.85);

  --border-subtle: #1e293b;
  --border-main: #334155;
  --border-glow: #475569;

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.2);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.2);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.2);
  --accent-rose: #ef4444;
  --accent-rose-glow: rgba(239, 68, 68, 0.2);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);

  --topbar-height: 64px;
  --bottomnav-height: 64px;
  --sidebar-width: 240px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-main);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* App Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header Topbar */
.app-topbar {
  height: var(--topbar-height);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.clinic-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-icon {
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-text {
  display: flex;
  flex-direction: column;
}
.clinic-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--text-main);
  line-height: 1.1;
}
.clinic-badge {
  font-size: 0.65rem;
  color: var(--accent-cyan);
  font-weight: 700;
}

.topbar-center {
  flex: 1;
  max-width: 460px;
  margin: 0 1rem;
}

.search-trigger-btn {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.search-trigger-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--text-main);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}
.search-trigger-btn kbd {
  margin-left: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-family: monospace;
  color: var(--text-dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doctor-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.doctor-profile .avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  color: #080c14;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.doctor-info {
  display: flex;
  flex-direction: column;
}
.doc-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.1;
}
.doc-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* App Body Structure */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar Navigation */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 0.75rem;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}

.nav-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.15), rgba(16, 185, 129, 0.1));
  color: var(--accent-cyan);
  border-left: 3px solid var(--accent-cyan);
  padding-left: calc(0.85rem - 3px);
}

.nav-btn svg {
  transition: transform 0.2s ease;
}
.nav-btn:hover svg {
  transform: scale(1.1);
}

.nav-btn .badge {
  margin-left: auto;
}

.clinic-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}
.status-title {
  display: block;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-main);
}
.status-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Screen Viewport */
.screen-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--bg-app);
}

/* Mobile Bottom Navigation */
.bottom-nav {
  display: none;
  height: var(--bottomnav-height);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  justify-content: space-around;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  transition: color 0.2s ease;
}
.bnav-btn.active {
  color: var(--accent-cyan);
}

/* Mobile Menu Trigger Button */
.mobile-menu-trigger {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 0.25rem;
  flex-shrink: 0;
}
.mobile-menu-trigger:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

/* Left Mobile Navigation Drawer */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-main);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  z-index: 105;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1rem 0.75rem;
}
.mobile-nav-drawer.open {
  transform: translateX(0);
}
.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.mobile-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  flex: 1;
}
.mobile-drawer-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

/* Patients Grid Layout Defaults */
.patients-layout-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.mobile-patients-switcher {
  display: none;
}

/* Responsiveness Rules */
@media (max-width: 768px) {
  html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100vw;
  }

  .app-layout, .app-body {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .screen-viewport {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 0.75rem;
    padding-bottom: calc(var(--bottomnav-height) + 1.25rem);
  }

  .mobile-menu-trigger {
    display: flex;
  }

  .app-sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .doc-name, .doc-role {
    display: none;
  }

  .topbar-center {
    max-width: 150px;
    margin: 0 0.2rem;
  }

  .search-trigger-btn span, .search-trigger-btn kbd {
    display: none;
  }

  .search-trigger-btn::after {
    content: "Search...";
    font-size: 0.8rem;
  }

  /* Mobile Patients Switcher */
  .mobile-patients-switcher {
    display: flex !important;
    gap: 0.5rem;
    width: 100%;
  }
  .mobile-patients-switcher .btn {
    flex: 1;
  }
  .mobile-hide {
    display: none !important;
  }

  /* Patients Directory Layout on Mobile */
  .patients-layout-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  /* Grid responsive single-column mobile view */
  .grid-2, .grid-3, .grid-4 {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.85rem !important;
  }

  /* Convert Data Tables to Mobile Card Views (Zero Horizontal Scroll!) */
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .data-table thead {
    display: none !important;
  }

  .data-table tr {
    margin-bottom: 0.75rem !important;
    background: var(--bg-app) !important;
    border: 1px solid var(--border-main) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.75rem !important;
  }

  .data-table td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.45rem 0 !important;
    border: none !important;
    border-bottom: 1px dashed var(--border-subtle) !important;
    font-size: 0.85rem !important;
    text-align: right !important;
    white-space: normal !important;
  }

  .data-table td:last-child {
    border-bottom: none !important;
  }

  .data-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: left;
    margin-right: 0.5rem;
    flex-shrink: 0;
  }
}

/* General UI Utility Classes */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.4);
}
.btn-emerald {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-emerald:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}
.btn-purple {
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  color: #ffffff;
}
.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-main);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
}
.btn-danger {
  background: var(--accent-rose-glow);
  border: 1px solid var(--accent-rose);
  color: var(--accent-rose);
}
.btn-danger:hover {
  background: var(--accent-rose);
  color: #ffffff;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-cyan {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.badge-emerald {
  background: var(--accent-emerald-glow);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-purple {
  background: var(--accent-purple-glow);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
}
.badge-amber {
  background: var(--accent-amber-glow);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-rose {
  background: var(--accent-rose-glow);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Cards & Layout Grids */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease;
}
.card:hover {
  border-color: var(--border-main);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Screen Headers */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.screen-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}
.screen-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Interactive Clickable Links & Badges */
.clickable {
  cursor: pointer;
  transition: all 0.15s ease;
}
.clickable:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}
.clickable-text {
  color: var(--accent-cyan);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(6, 182, 212, 0.4);
}
.clickable-text:hover {
  color: var(--accent-emerald);
}

/* Drawers & Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 90;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 540px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-main);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.side-drawer.open {
  transform: translateX(0);
}
.drawer-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}
.drawer-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

/* Global Search Modal */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5rem;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(8px);
}
.search-modal-card {
  width: 90%;
  max-width: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.7);
  overflow: hidden;
}
.search-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.search-modal-header input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-sans);
}
.search-results-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
}
.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}
.search-item:hover, .search-item.selected {
  background: var(--bg-card);
  border-left: 3px solid var(--accent-cyan);
  padding-left: calc(1rem - 3px);
}
.search-item-title {
  font-weight: 700;
  color: var(--text-main);
}
.search-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--accent-emerald);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 20px rgba(0,0,0,0.5);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slide-toast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}
@keyframes slide-toast {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-input, .form-select, .form-textarea {
  background: var(--bg-app);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 0.6rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Table styling */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.data-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
}
.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* VAS Pain Scale Slider */
.pain-scale-container {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}
.pain-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  outline: none;
  cursor: pointer;
}

/* Print Styles */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-topbar, .app-sidebar, .bottom-nav, .search-modal, .toast-container, .modal-backdrop, .drawer-header, button:not(#printReceiptBtn) {
    display: none !important;
  }
  .side-drawer {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
  }
  .drawer-body {
    padding: 0 !important;
  }
}
