/* ============================================================
   TeleMed Design System
   Modern Healthcare UI — Bootstrap 5.3 + Custom CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Custom Properties ────────────────────────────────── */
:root {
  --primary:          #1A6EBD;
  --primary-dark:     #155A9F;
  --primary-light:    #EBF4FF;
  --secondary:        #00A896;
  --secondary-dark:   #008A7C;
  --secondary-light:  #E0F7F5;
  --success:          #2ECC71;
  --warning:          #F39C12;
  --danger:           #E74C3C;
  --info:             #3498DB;

  --text-primary:     #1A2340;
  --text-secondary:   #4A5568;
  --text-muted:       #6B7A99;
  --text-light:       #A0AEC0;

  --surface:          #FFFFFF;
  --background:       #F4F7FC;
  --border:           #E2E8F0;
  --border-light:     #EDF2F7;

  --sidebar-bg:       #0F1F3D;
  --sidebar-text:     #B8C5E0;
  --sidebar-hover:    rgba(255,255,255,0.08);
  --sidebar-active:   #1A6EBD;
  --sidebar-width:    260px;
  --sidebar-collapsed: 72px;

  --header-height:    64px;
  --border-radius:    10px;
  --border-radius-lg: 16px;
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow:           0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:        0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.05);
  --transition:       all 0.2s ease;
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Shell ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: width 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--header-height);
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  color: white;
}

.sidebar-brand .brand-text {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand .brand-text span {
  color: var(--secondary);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(184,197,224,0.5);
  padding: 12px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item { margin-bottom: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text) !important;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff !important;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff !important;
}

.nav-link .nav-icon {
  font-size: 1.1rem;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.nav-link .nav-text { flex: 1; }

.nav-link .nav-badge {
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ─── Main Content Area ────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.main-wrapper.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

/* ─── Top Header ───────────────────────────────────────────── */
.top-header {
  background: var(--surface);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.header-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
}

.header-toggle:hover {
  background: var(--background);
  color: var(--primary);
}

.header-breadcrumb {
  flex: 1;
}

.breadcrumb {
  margin: 0;
  background: transparent;
  padding: 0;
  font-size: 0.8125rem;
}

.breadcrumb-item a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}

.header-icon-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.notification-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.user-avatar-btn:hover {
  background: var(--background);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-placeholder {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.user-role-badge {
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-patient  { background: var(--secondary-light); color: var(--secondary-dark); }
.role-doctor   { background: var(--primary-light); color: var(--primary-dark); }
.role-admin    { background: #F3E8FF; color: #7C3AED; }

/* ─── Page Content ─────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px 28px;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }

/* ─── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.teal   { background: var(--secondary-light); color: var(--secondary); }
.stat-icon.green  { background: #DCFCE7; color: #16A34A; }
.stat-icon.purple { background: #F3E8FF; color: #7C3AED; }
.stat-icon.orange { background: #FEF3C7; color: #D97706; }

.stat-info { flex: 1; }

.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  padding: 8px 18px;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary-app {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.btn-secondary-app:hover {
  background: var(--secondary-dark);
  border-color: var(--secondary-dark);
  color: white;
}

.btn-walkin {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  border: none;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 32px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(26,110,189,0.3);
  transition: var(--transition);
}

.btn-walkin:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(26,110,189,0.4);
  color: white;
}

/* ─── Availability Toggle ──────────────────────────────────── */
.availability-card {
  background: linear-gradient(135deg, #0F1F3D 0%, #1A3A6B 100%);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  color: white;
  position: relative;
  overflow: hidden;
}

.availability-card::after {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
}

.availability-toggle {
  width: 56px; height: 28px;
  background: rgba(255,255,255,0.2);
  border-radius: 14px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.availability-toggle.active {
  background: var(--success);
}

.availability-toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.availability-toggle.active::after {
  left: calc(100% - 25px);
}

/* ─── Queue/Patient Items ──────────────────────────────────── */
.patient-queue-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: var(--surface);
  transition: var(--transition);
}

.patient-queue-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.queue-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-weight: 600;
  flex-shrink: 0;
}

.queue-info { flex: 1; }
.queue-name { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); }
.queue-complaint { font-size: 0.8rem; color: var(--text-muted); }
.queue-time { font-size: 0.75rem; color: var(--text-light); }

.waiting-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Tables ───────────────────────────────────────────────── */
.table-card .table {
  margin: 0;
}

.table thead th {
  background: var(--background);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

.table tbody tr:hover td {
  background: var(--primary-light);
}

/* ─── Status Badges ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-waiting  { background: #FEF3C7; color: #D97706; }
.status-active   { background: #DCFCE7; color: #16A34A; }
.status-completed{ background: var(--primary-light); color: var(--primary); }
.status-cancelled{ background: #FEE2E2; color: #DC2626; }

/* ─── Forms ────────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  padding: 9px 12px;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,110,189,0.12);
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ─── Auth Pages ───────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  background: var(--background);
}

.auth-left {
  width: 45%;
  background: linear-gradient(145deg, #0F1F3D 0%, #1A3A6B 60%, #1A6EBD 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: rgba(0,168,150,0.1);
  border-radius: 50%;
}

.auth-left::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -80px;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.auth-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.auth-logo-icon {
  width: 48px; height: 48px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: white;
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.auth-divider {
  text-align: center;
  position: relative;
  margin: 20px 0;
  color: var(--text-light);
  font-size: 0.8rem;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}

.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* ─── SOAP Notes ───────────────────────────────────────────── */
.soap-tabs .nav-link {
  color: var(--text-muted) !important;
  background: none !important;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 18px;
  font-weight: 500;
}

.soap-tabs .nav-link.active {
  color: var(--primary) !important;
  border-bottom-color: var(--primary);
  background: none !important;
}

.soap-section {
  background: var(--background);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.soap-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 6px;
}

/* ─── Medical Record Upload ────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--border-radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--background);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 12px;
}

/* ─── Notification Toast ───────────────────────────────────── */
.notification-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification-toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--border-radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

.notification-toast.success { border-left-color: var(--success); }
.notification-toast.warning { border-left-color: var(--warning); }
.notification-toast.urgent  { border-left-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─── Available Doctors Grid ────────────────────────────────── */
.doctor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.doctor-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.doctor-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.doctor-name { font-weight: 600; font-size: 0.9375rem; }
.doctor-specialty { font-size: 0.8rem; color: var(--text-muted); }

.available-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 500;
  margin-top: 6px;
}

.available-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 992px) {
  .sidebar {
    width: 0;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    width: var(--sidebar-width);
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .auth-left { display: none; }
  .auth-right { padding: 24px; }
}

@media (max-width: 576px) {
  .page-content { padding: 16px; }
  .stat-card { flex-direction: column; text-align: center; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}
