/* RS Adi Husada — Hospital CS Dashboard */
:root {
  /* Colors */
  --bg-primary: #f6f6f6;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --bg-sidebar-hover: #334155;
  --bg-sidebar-active: #3b82f6;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-light: #dbeafe;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: #ffffff;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
}

.sidebar-section {
  padding: var(--space-2) var(--space-6);
  margin-top: var(--space-4);
}

.sidebar-section-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all 0.15s ease;
  border-radius: 0;
  margin: 0 var(--space-3);
  border-radius: var(--radius-md);
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-sidebar-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: #ffffff;
}

.sidebar-user-info {
  flex: 1;
}

.sidebar-user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: #ffffff;
}

.sidebar-user-role {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

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

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.header-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.header-breadcrumb a:hover {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  background: none;
}

.header-icon:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.header-icon svg {
  width: 20px;
  height: 20px;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* Content */
.content {
  flex: 1;
  padding: var(--space-8);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.content-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.content-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.filter-select {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow 0.15s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.kpi-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-card-icon.blue { background: #dbeafe; color: #3b82f6; }
.kpi-card-icon.green { background: #dcfce7; color: #22c55e; }
.kpi-card-icon.amber { background: #fef3c7; color: #f59e0b; }
.kpi-card-icon.purple { background: #f3e8ff; color: #a855f7; }

.kpi-card-icon svg {
  width: 22px;
  height: 22px;
}

.kpi-card-badge {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
}

.kpi-card-badge.up { background: #dcfce7; color: #16a34a; }
.kpi-card-badge.down { background: #fee2e2; color: #dc2626; }

.kpi-card-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: var(--space-1);
}

.kpi-card-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

/* Chart Card */
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.chart-card-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.chart-area {
  width: 100%;
  height: 300px;
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-4);
}

/* Bar Chart */
.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.bar {
  width: 100%;
  max-width: 48px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--accent);
  transition: opacity 0.15s ease;
  position: relative;
}

.bar:hover {
  opacity: 0.85;
}

.bar-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.bar-value {
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}

/* Chat Page (CS) */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  gap: 0;
  height: calc(100vh - var(--header-height));
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Chat List */
.chat-list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-list-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-list-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

.chat-search {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.chat-search input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  outline: none;
  background: var(--bg-primary);
}

.chat-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.chat-items {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition: background 0.1s ease;
  border-bottom: 1px solid var(--border);
}

.chat-item:hover {
  background: var(--bg-primary);
}

.chat-item.active {
  background: var(--accent-light);
}

.chat-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}

.chat-item-content {
  flex: 1;
  min-width: 0;
}

.chat-item-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}

.chat-item-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
}

.chat-item-preview {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-item-badge {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Chat Main */
.chat-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.chat-main-header {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-main-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-main-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.chat-main-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.chat-main-status {
  font-size: var(--font-size-xs);
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-main-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--success);
}

.chat-messages {
  flex: 1;
  padding: var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.message {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message.received {
  align-self: flex-start;
}

.message.sent {
  align-self: flex-end;
}

.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

.message.received .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

.message.sent .message-bubble {
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: var(--radius-sm);
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 var(--space-1);
}

.message.sent .message-time {
  text-align: right;
}

.chat-input-area {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  outline: none;
  resize: none;
}

.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.chat-send-btn:hover {
  background: #2563eb;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

/* Chat Sidebar (Details) */
.chat-details {
  border-left: 1px solid var(--border);
  padding: var(--space-5);
  overflow-y: auto;
  background: var(--bg-card);
}

.chat-details-section {
  margin-bottom: var(--space-6);
}

.chat-details-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.chat-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  font-size: var(--font-size-sm);
}

.chat-detail-label {
  color: var(--text-secondary);
}

.chat-detail-value {
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.chat-tag {
  display: inline-flex;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.chat-tag.appointment { background: #dcfce7; color: #16a34a; }
.chat-tag.inquiry { background: #dbeafe; color: #2563eb; }
.chat-tag.urgent { background: #fee2e2; color: #dc2626; }

.chat-notes-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .main {
    margin-left: 0;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-list,
  .chat-details {
    display: none;
  }
}

/* Bar heights */
.bar-h-42 { height: 84px; }
.bar-h-65 { height: 130px; }
.bar-h-78 { height: 156px; }
.bar-h-91 { height: 182px; }
.bar-h-103 { height: 206px; }
.bar-h-55 { height: 110px; }
.bar-h-23 { height: 46px; }

/* Layout overrides */
.content-chat { padding: var(--space-4); }
.header-actions-row { display: flex; gap: var(--space-2); }

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}
