/* Design System - DentisBot Dashboard */
:root {
  /* Colors */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --color-primary: #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-secondary: #0ea5e9; /* Sky Blue */
  --color-success: #10b981; /* Emerald */
  --color-warning: #f59e0b; /* Amber */
  --color-danger: #ef4444; /* Rose */
  
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glass-blur: blur(12px);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* Light Mode Override (if user toggles it) */
body.light-mode {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.8);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --glass-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
  --glass-blur: blur(8px);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* Scrollbars */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  transition: background-color var(--transition-normal);
}

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

.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-wrap { white-space: normal; word-break: break-all; }
.hidden { display: none !important; }
.mt-4 { margin-top: 1.5rem; }
.ml-3 { margin-left: 0.75rem; }
.flex-1 { flex: 1; }

/* APP LAYOUT */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  z-index: 10;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  stroke: var(--color-secondary);
  animation: pulse 2s infinite;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  width: max-content;
}
.badge-primary {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--color-primary);
}
.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}
.badge-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}
.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.sidebar-nav {
  flex-grow: 1;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
  position: relative;
}

.nav-item i {
  width: 20px;
  height: 20px;
  stroke-width: 2px;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
  border-left: 3px solid var(--color-primary);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.system-status {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-indicator.online {
  background-color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}
.status-indicator.offline {
  background-color: var(--color-danger);
  box-shadow: 0 0 8px var(--color-danger);
}

/* MAIN CONTENT AREA */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.top-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(11, 15, 25, 0.4);
  backdrop-filter: var(--glass-blur);
  z-index: 5;
  flex-shrink: 0;
}

.header-title h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.header-title p {
  font-size: 0.875rem;
}

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

.clinic-info-quick {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.quick-icon {
  width: 16px;
  height: 16px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  outline: none;
}

.btn-primary {
  background-gradient: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  background-color: var(--color-primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
}
.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.08);
}
.btn-icon i {
  width: 18px;
  height: 18px;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

/* VIEWS */
.content-view {
  display: none;
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
  animation: fadeIn 0.4s ease;
}

.content-view.active {
  display: block;
}

/* CARDS */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.glass-card {
  background-color: var(--bg-card);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body {
  padding: 1.5rem;
  flex-grow: 1;
}

/* STATS CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--border-color);
}

.card-gradient-1 { background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(14, 165, 233, 0.05)); }
.card-gradient-2 { background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(14, 165, 233, 0.05)); }
.card-gradient-3 { background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(14, 165, 233, 0.05)); }
.card-gradient-4 { background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(239, 68, 68, 0.05)); }

.stat-icon {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-secondary);
}

.stat-icon i {
  width: 24px;
  height: 24px;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-change {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
}
.stat-change i {
  width: 12px;
  height: 12px;
}

/* TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.table th, .table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  background-color: rgba(255, 255, 255, 0.01);
  font-family: 'Outfit', sans-serif;
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* DASHBOARD GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.col-span-2 {
  grid-column: span 2;
}

/* AI Status Widget styling */
.ai-status-box {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.ai-key-status {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.key-icon {
  stroke: var(--color-success);
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.ai-key-status.missing .key-icon {
  stroke: var(--color-warning);
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.info-list-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 0.75rem;
}

.info-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.info-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.info-val {
  font-size: 0.875rem;
  font-weight: 500;
}

/* SEARCH INPUTS IN HEADERS */
.header-search {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  width: 250px;
  gap: 0.5rem;
}

.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 100%;
}

.header-search i {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* LIVE CHAT VIEW */
.livechat-container {
  display: flex;
  height: calc(100vh - 140px);
  gap: 1.5rem;
}

.chat-list-card {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
}

.chat-list-search {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(0, 0, 0, 0.1);
}

.chat-list-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 100%;
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.chat-threads-list {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-thread-item {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.chat-thread-item:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.chat-thread-item.active {
  background-color: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--color-primary);
}

.chat-thread-avatar {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.chat-thread-avatar i {
  width: 18px;
  height: 18px;
}

.chat-thread-details {
  flex-grow: 1;
  min-width: 0; /* Abilita troncatura */
}

.chat-thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.chat-thread-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.chat-thread-preview {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.thread-badge-step {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-radius: 4px;
}

.thread-badge-takeover {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.chat-window-card {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.chat-window-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
  gap: 1rem;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  stroke-width: 1px;
}

.chat-window-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-window-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.05);
}

.patient-chat-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.patient-chat-info .avatar {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--color-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.patient-chat-info h3 {
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.patient-chat-info span {
  font-size: 0.75rem;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.takeover-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.takeover-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Switch Toggle Styling */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
}
input:checked + .slider {
  background-color: var(--color-warning);
}
input:focus + .slider {
  box-shadow: 0 0 1px var(--color-warning);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}

.chat-messages-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background-color: rgba(0, 0, 0, 0.05);
}

.message-bubble-wrapper {
  display: flex;
  width: 100%;
}

.message-bubble-wrapper.patient {
  justify-content: flex-start;
}

.message-bubble-wrapper.bot, .message-bubble-wrapper.agent {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.4;
  position: relative;
}

.message-bubble-wrapper.patient .message-bubble {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border-color);
}

.message-bubble-wrapper.bot .message-bubble {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--text-primary);
  border-bottom-right-radius: 2px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.message-bubble-wrapper.agent .message-bubble {
  background-color: rgba(14, 165, 233, 0.15);
  color: var(--text-primary);
  border-bottom-right-radius: 2px;
  border: 1px solid rgba(14, 165, 233, 0.2);
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.message-sender-tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.03);
  margin-right: auto;
}

.chat-input-area {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: rgba(0, 0, 0, 0.1);
}

.chat-input-area form {
  display: flex;
  gap: 1rem;
}

.chat-input-area input {
  flex-grow: 1;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.chat-input-area input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--border-focus);
}

/* SANDBOX WHATSAPP VIEW */
.sandbox-container {
  display: flex;
  gap: 2rem;
  height: calc(100vh - 140px);
}

.sandbox-instructions {
  flex: 1;
  overflow-y: auto;
}

.sandbox-patients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.sandbox-patients-list li {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sandbox-patients-list code {
  color: var(--color-secondary);
  font-weight: 600;
  font-size: 0.875rem;
}

.test-scenarios {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.scenario-item {
  background-color: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.1);
  padding: 0.875rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.scenario-item:hover {
  background-color: rgba(99, 102, 241, 0.12);
  transform: translateY(-2px);
}

.scenario-item h5 {
  font-size: 0.875rem;
  margin-bottom: 0.15rem;
  color: var(--text-primary);
}

.scenario-item p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sandbox-phone-wrapper {
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.phone-select-number {
  width: 100%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.phone-select-number label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.phone-select-input-group {
  display: flex;
  gap: 0.5rem;
}

.phone-select-input-group input {
  flex-grow: 1;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  font-size: 0.875rem;
}

/* SMARTPHONE FRAME */
.smartphone-frame {
  width: 320px;
  height: 520px;
  border: 10px solid #1f2937;
  border-radius: 36px;
  background-color: #000;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  position: relative;
}

.phone-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #0b141a; /* WhatsApp default dark chat color */
  background-image: radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 0);
  background-size: 24px 24px;
}

.phone-status-bar {
  height: 24px;
  background-color: #1f2c34;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.8);
}

.phone-icons {
  display: flex;
  gap: 0.25rem;
}

.sm-icon {
  width: 10px;
  height: 10px;
}

/* WhatsApp Header in Smartphone */
.wa-header {
  height: 56px;
  background-color: #1f2c34;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
  color: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.15);
}

.wa-header-left {
  display: flex;
  align-items: center;
}

.wa-back-icon {
  width: 18px;
  height: 18px;
  color: #8696a0;
  cursor: pointer;
}

.wa-avatar {
  background-color: #51585c;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.15rem;
}

.wa-avatar i {
  width: 16px;
  height: 16px;
}

.wa-chat-details {
  margin-left: 0.5rem;
  display: flex;
  flex-direction: column;
}

.wa-contact-name {
  font-size: 0.825rem;
  font-weight: 600;
}

.wa-contact-status {
  font-size: 0.625rem;
  color: #8696a0;
}

.wa-header-icons {
  display: flex;
  gap: 0.75rem;
  color: #8696a0;
  padding-right: 0.25rem;
}

.wa-icon {
  width: 16px;
  height: 16px;
}

/* WhatsApp Chat Body */
.wa-chat-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: #0b141a;
}

/* WhatsApp Messages inside Smartphone */
.wa-msg-wrapper {
  display: flex;
  width: 100%;
}

.wa-msg-wrapper.sent {
  justify-content: flex-end;
}

.wa-msg-wrapper.received {
  justify-content: flex-start;
}

.wa-message {
  max-width: 80%;
  padding: 0.45rem 0.625rem;
  font-size: 0.75rem;
  line-height: 1.3;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.wa-msg-wrapper.sent .wa-message {
  background-color: #005c4b; /* WhatsApp Sent Green */
  color: #e9edef;
  border-radius: 6px 0 6px 6px;
}

.wa-msg-wrapper.received .wa-message {
  background-color: #202c33; /* WhatsApp Received Gray */
  color: #e9edef;
  border-radius: 0 6px 6px 6px;
}

.wa-msg-time {
  display: block;
  text-align: right;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.15rem;
}

/* WhatsApp Footer inside Smartphone */
.wa-input-footer {
  padding: 0.45rem;
  background-color: #1f2c34;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.wa-input-container {
  flex-grow: 1;
  background-color: #2a3942;
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  height: 34px;
}

.wa-input-container input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.75rem;
  padding: 0 0.35rem;
}

.wa-input-icon {
  width: 14px;
  height: 14px;
  color: #8696a0;
  cursor: pointer;
}

.wa-btn-send {
  background-color: #00a884; /* WhatsApp Green Send Button */
  border: none;
  outline: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.wa-btn-send:hover {
  background-color: #008f72;
}

.wa-btn-send i {
  width: 14px;
  height: 14px;
}

/* SETTINGS VIEW */
.settings-container {
  max-width: 1000px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input, .form-group textarea {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--border-focus);
}

.form-help {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.settings-row {
  display: flex;
  gap: 1.5rem;
}

.settings-actions {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

/* KEYFRAMES & ANIMATIONS */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

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

/* TRIAGE FILTERING & BADGES */
.triage-filters {
  display: flex;
  padding: 0.75rem;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(0, 0, 0, 0.05);
  flex-wrap: wrap;
}

.triage-filter-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.triage-filter-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.triage-filter-btn.active {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
  color: #fff;
}

.triage-filter-btn.active.filter-emergency {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.25);
}

.triage-filter-btn.active.filter-urgent {
  background-color: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.5);
}

.triage-filter-btn.active.filter-routine {
  background-color: rgba(234, 179, 8, 0.2);
  border-color: rgba(234, 179, 8, 0.5);
}

.triage-filter-btn.active.filter-admin {
  background-color: rgba(14, 165, 233, 0.2);
  border-color: rgba(14, 165, 233, 0.5);
}

/* Badges di Triage nei Thread */
.triage-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.triage-badge-EMERGENCY {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
  animation: pulse-border 2s infinite;
}

.triage-badge-URGENT {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fb923c;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.triage-badge-ROUTINE {
  background-color: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.triage-badge-ADMINISTRATIVE {
  background-color: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.2); }
  50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.5); }
  100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.2); }
}
