:root {
  --primary: #58a6ff;
  --primary-glow: rgba(88, 166, 255, 0.15);
  --success: #3fb950;
  --success-glow: rgba(63, 185, 80, 0.15);
  --warning: #d29922;
  --warning-glow: rgba(210, 153, 34, 0.15);
  --danger: #f85149;
  --danger-glow: rgba(248, 81, 73, 0.15);

  --bg-dark: #0d1117;
  --card-bg: rgba(22, 27, 34, 0.7);
  --card-border: rgba(48, 54, 61, 0.8);
  --text-primary: #c9d1d9;
  --text-muted: #8b949e;
  --text-light: #f0f6fc;
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

h1,
h2,
h3,
h4 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-light);
  font-weight: 600;
}

/* Glassmorphism Background elements */
.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 10% 20%, rgba(90, 120, 255, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(120, 80, 255, 0.08) 0%, transparent 45%);
  z-index: -1;
  pointer-events: none;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--card-border);
  background-color: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-text h1 {
  font-size: 1.5rem;
  letter-spacing: 1px;
}

.logo-text .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.patient-selector-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.patient-selector-container label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.patient-dropdown {
  background: rgba(33, 38, 45, 0.7);
  border: 1px solid var(--card-border);
  color: var(--text-light);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.patient-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(33, 38, 45, 0.5);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--card-border);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* App Layout */
.app-container {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  height: calc(100vh - 170px);
}

/* Dashboard Panel (Left) */
.dashboard-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

/* Cards style */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.25rem;
  backdrop-filter: blur(8px);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease;
}

.card:hover {
  border-color: rgba(88, 166, 255, 0.3);
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  padding-bottom: 0.5rem;
}

/* Profile Card */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), #85c2ff);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #0d1117;
  font-size: 1.1rem;
}

.profile-meta h2 {
  font-size: 1.2rem;
}

.profile-meta .patient-id {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profile-details {
  list-style: none;
}

.profile-details li {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed rgba(48, 54, 61, 0.3);
}

.profile-details li:last-child {
  border-bottom: none;
}

.profile-details .label {
  color: var(--text-muted);
}

.profile-details .value {
  color: var(--text-light);
}

.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active {
  background-color: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

/* Med Card */
.med-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.med-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(33, 38, 45, 0.3);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(48, 54, 61, 0.4);
}

.med-item.compliant {
  border-left: 4px solid var(--success);
}

.med-item.missed {
  border-left: 4px solid var(--danger);
  background: rgba(248, 81, 73, 0.05);
}

.med-info {
  display: flex;
  flex-direction: column;
}

.med-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.med-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
}

.med-status {
  font-size: 0.8rem;
  font-weight: 600;
}

.med-status.taken {
  color: var(--success);
}

.med-status.not-taken {
  color: var(--danger);
}

.med-status.pending {
  color: var(--text-muted);
}

/* Analytics Card */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric-box {
  background: rgba(33, 38, 45, 0.4);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  border: 1px solid rgba(48, 54, 61, 0.3);
}

.metric-val {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-light);
  font-family: 'Outfit', sans-serif;
}

.metric-val .small {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.metric-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.privacy-notice {
  display: flex;
  gap: 0.75rem;
  background: rgba(88, 166, 255, 0.03);
  border: 1px solid rgba(88, 166, 255, 0.1);
  padding: 0.75rem;
  border-radius: 8px;
  align-items: flex-start;
}

.privacy-icon {
  font-size: 1.2rem;
  color: var(--primary);
}

.privacy-text h4 {
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.privacy-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Chat Panel (Right) */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(22, 27, 34, 0.9);
}

.chat-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#reset-session-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}

#reset-session-btn:hover {
  color: var(--text-light);
  border-color: var(--primary);
  background: var(--primary-glow);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Message Bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.message .msg-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.message.user .msg-bubble {
  background: var(--primary);
  color: #0d1117;
  font-weight: 500;
  border-bottom-right-radius: 2px;
}

.message.agent .msg-bubble {
  background: rgba(33, 38, 45, 0.8);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 2px;
}

.message.agent.alert .msg-bubble {
  background: rgba(248, 81, 73, 0.07);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--text-light);
  border-left: 4px solid var(--danger);
}

.message.agent.alert h4 {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.message .msg-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  margin-left: 0.2rem;
}

.message.user .msg-meta {
  align-self: flex-end;
  margin-right: 0.2rem;
}

.message.system-msg {
  align-self: center;
  max-width: 100%;
}

.message.system-msg p {
  background: rgba(110, 118, 129, 0.1);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(110, 118, 129, 0.15);
}

/* Thinking Indicator / Pipeline stages */
.thinking-stages {
  display: flex;
  justify-content: space-around;
  padding: 0.75rem 1.5rem;
  background: rgba(22, 27, 34, 0.8);
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
  gap: 0.5rem;
}

.stage-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.3s;
}

.stage-item.active {
  opacity: 1;
  color: var(--primary);
}

.stage-item.completed {
  opacity: 0.8;
  color: var(--success);
}

.stage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.stage-item.active .stage-dot {
  background-color: var(--primary);
  box-shadow: 0 0 6px var(--primary);
  animation: pulse 1.2s infinite ease-in-out;
}

.stage-item.completed .stage-dot {
  background-color: var(--success);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.4);
    opacity: 1;
  }
}

/* Chat Input Area */
.chat-input-area {
  padding: 1.25rem 1.5rem;
  background: rgba(22, 27, 34, 0.95);
  border-top: 1px solid var(--card-border);
}

.chat-form-container {
  display: flex;
  gap: 0.75rem;
}

#chat-input {
  flex: 1;
  background: rgba(13, 17, 23, 0.7);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 0.85rem 1.25rem;
  border-radius: 24px;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

#chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.send-button {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #0d1117;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.2s,
    background-color 0.2s;
}

.send-button:hover {
  background-color: #85c2ff;
  transform: scale(1.05);
}

.send-button:active {
  transform: scale(0.95);
}

.send-button:disabled {
  background-color: var(--card-border);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* Demo Controller (Bottom) */
.demo-controller {
  padding: 1.25rem 2rem;
  background-color: rgba(13, 17, 23, 0.95);
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  z-index: 10;
}

.demo-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
}

.demo-title i {
  color: var(--primary);
}

.demo-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.demo-btn {
  background: rgba(33, 38, 45, 0.6);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 0.6rem 1.1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.demo-btn:hover {
  background: rgba(33, 38, 45, 1);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.demo-btn.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger-glow);
}

.demo-btn.btn-warning:hover {
  border-color: var(--warning);
  background: var(--warning-glow);
}

.text-success {
  color: var(--success);
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: visible;
  }

  .dashboard-panel {
    overflow-y: visible;
  }

  .chat-panel {
    height: 600px;
  }

  .demo-controller {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

/* Security Verification Dialog Modal */
.security-modal {
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: 16px;
  background: rgba(22, 27, 34, 0.96);
  color: var(--text-color);
  max-width: 420px;
  width: 90%;
  padding: 0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.security-modal::backdrop {
  background: rgba(10, 12, 16, 0.75);
  backdrop-filter: blur(10px);
}

.security-modal .modal-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.security-modal .modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(48, 54, 61, 0.4);
  padding-bottom: 0.75rem;
}

.security-modal .security-icon {
  font-size: 1.5rem;
  color: var(--warning);
}

.security-modal h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-color);
}

.security-modal .modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.security-modal .pin-input-container {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0;
}

.security-modal #security-pin {
  background: rgba(13, 17, 23, 0.8);
  border: 2px solid rgba(48, 54, 61, 0.6);
  border-radius: 8px;
  color: #fff;
  font-size: 2rem;
  padding: 0.5rem 1rem;
  letter-spacing: 0.5rem;
  width: 150px;
  text-align: center;
  outline: none;
  transition: all 0.2s ease;
}

.security-modal #security-pin:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(56, 139, 253, 0.3);
}

.security-modal .pin-hint {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(33, 38, 45, 0.4);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(48, 54, 61, 0.2);
  line-height: 1.3;
}

.security-modal .pin-hint i {
  color: var(--primary-light);
  margin-top: 2px;
}

.security-modal .pin-hint strong {
  color: var(--text-color);
}

.security-modal .error-msg {
  color: #ff7b72;
  font-size: 0.85rem;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  text-align: center;
}

.security-modal .modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.security-modal .btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.security-modal .btn-secondary {
  background: transparent;
  border-color: rgba(240, 246, 252, 0.1);
  color: var(--text-color);
}

.security-modal .btn-secondary:hover {
  background: rgba(240, 246, 252, 0.05);
  border-color: rgba(240, 246, 252, 0.2);
}

.security-modal .btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.security-modal .btn-primary:hover {
  background: var(--primary-light);
}
