/* ==========================================================================
   TSRI Enterprise AI Document Assistant (RAG)
   Formal Government & Enterprise Clean UI Design System
   Refined for Production Grade A11y, Performance, and Zero Anti-Patterns
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand & Theme Colors (Formal & Trustworthy) */
  --color-primary-900: #0f1e36;
  --color-primary-800: #0f2942;
  --color-primary-700: #1a3c61;
  --color-primary-600: #1e3a8a;
  --color-primary-500: #2563eb;
  --color-primary-100: #e0e7ff;
  --color-primary-50:  #eff6ff;

  /* Accent & Highlight Colors (TSRI Warm Amber / Innovation Gold) */
  --color-accent-600:  #d97706;
  --color-accent-500:  #f59e0b;
  --color-accent-100:  #fef3c7;
  --color-accent-50:   #fffbeb;

  /* Neutrals & Surfaces (Clean, Soft & Eye-Friendly) */
  --bg-app:        #f8fafc;
  --bg-surface:    #ffffff;
  --bg-surface-alt:#f1f5f9;
  --bg-surface-subtle: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-strong: #94a3b8;

  /* Typography Colors (High-Contrast WCAG AAA Compliant) */
  --text-main:     #0f172a;
  --text-muted:    #334155;
  --text-light:    #475569;
  --text-inverse:  #ffffff;

  /* Functional Status Colors */
  --status-success-bg:   #ecfdf5;
  --status-success-text: #065f46;
  --status-success-border:#a7f3d0;
  --status-warning-bg:   #fffbeb;
  --status-warning-text: #92400e;
  --status-warning-border:#fde68a;
  --status-error-bg:     #fef2f2;
  --status-error-text:   #991b1b;
  --status-error-border: #fecaca;
  --status-info-bg:      #f0f9ff;
  --status-info-text:    #0369a1;
  --status-info-border:  #bae6fd;

  /* Typography Settings */
  --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body:    'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Elevation & Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-drawer: -6px 0 25px -4px rgba(15, 23, 42, 0.12);

  /* Dimensions & Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --drawer-width: 500px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Semantic Z-Index Scale (Impeccable Strict Hierarchy) */
  --z-base: 1;
  --z-nav: 100;
  --z-header: 120;
  --z-dropdown: 150;
  --z-drawer-overlay: 400;
  --z-drawer: 410;
  --z-modal-overlay: 500;
  --z-modal: 510;
  --z-toast: 600;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  background-color: var(--bg-app);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessibility Focus Ring */
:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-primary-900);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}

p {
  margin-bottom: 0.75rem;
  text-wrap: pretty;
}

p:last-child {
  margin-bottom: 0;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* App Shell Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Navigation (Streamlined & Compact) */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: var(--z-nav);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  height: 56px;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, #ffffff, #fcfdfd);
}

.sidebar-logo {
  height: 38px;
  max-width: 215px;
  width: auto;
  object-fit: contain;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
}

.sidebar-nav {
  flex: 1;
  padding: 0.65rem 0.55rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* Slim Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

.nav-section-title {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.45rem 0.5rem 0.15rem 0.5rem;
  margin-top: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-family: var(--font-heading);
  font-size: 0.86rem;
  transition: background-color 0.15s, color 0.15s;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 36px;
}

.nav-item:hover {
  background-color: var(--bg-surface-alt);
  color: var(--color-primary-800);
}

.nav-item.active {
  background-color: var(--color-primary-50);
  color: var(--color-primary-600);
  border-color: var(--color-primary-100);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-full);
  background-color: var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background-color: var(--color-primary-100);
  color: var(--color-primary-700);
}

.sidebar-footer {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
}

.system-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Sidebar Backdrop for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  z-index: calc(var(--z-nav) - 1);
}

.sidebar-overlay.active {
  display: block;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* Top App Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  z-index: var(--z-header);
  box-shadow: var(--shadow-xs);
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.sidebar-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-main);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.header-title-box {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary-800);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--color-primary-50);
  color: var(--color-primary-700);
  border: 1px solid var(--color-primary-100);
  flex-shrink: 0;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

/* User Switcher Dropdown (สลับบทบาทผู้ใช้งานเมื่อคลิกที่ชื่อ) */
.user-switcher-wrapper {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  text-align: left;
}

.user-profile-btn:hover {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-medium);
}

.user-profile-btn.active,
.user-profile-btn:focus-visible {
  background-color: var(--color-primary-50);
  border-color: var(--color-primary-300);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-800));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

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

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-role-badge {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 500;
}

.user-chevron-icon {
  color: var(--text-light);
  transition: transform 0.2s ease;
  margin-left: 0.25rem;
  flex-shrink: 0;
}

.user-profile-btn.active .user-chevron-icon {
  transform: rotate(180deg);
  color: var(--color-primary-600);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: var(--z-modal);
  animation: modalScaleIn 0.15s ease-out;
}

.user-dropdown-menu.active {
  display: flex;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  width: 100%;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.user-dropdown-item:hover {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-subtle);
}

.user-dropdown-item.active {
  background-color: var(--color-primary-50);
  border-color: var(--color-primary-100);
}

.user-dropdown-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-dropdown-item-name {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--color-primary-900);
}

.user-dropdown-item-meta {
  font-size: 0.72rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Gear Icon & Admin Dropdown Menu */
.admin-settings-wrapper {
  position: relative;
}

.gear-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background-color: var(--bg-surface);
  color: var(--color-primary-800);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.gear-btn:hover {
  background-color: var(--color-primary-50);
  border-color: var(--color-primary-500);
  color: var(--color-primary-600);
}

.gear-btn.active {
  background-color: var(--color-primary-600);
  color: white;
  border-color: var(--color-primary-700);
}

.gear-btn svg {
  transition: transform 0.3s ease;
}

.gear-btn:hover svg {
  transform: rotate(45deg);
}

.admin-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 330px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: var(--z-modal);
  animation: modalScaleIn 0.15s ease-out;
}

.admin-dropdown-menu.active {
  display: flex;
}

.dropdown-header {
  padding: 0.6rem 0.75rem 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  width: 100%;
  color: var(--text-main);
  transition: background-color 0.15s, border-color 0.15s;
}

.dropdown-item:hover {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-subtle);
}

.dropdown-item.active {
  background-color: var(--color-primary-50);
  border-color: var(--color-primary-100);
}

.dropdown-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary-700);
  flex-shrink: 0;
}

.dropdown-item:hover .dropdown-icon {
  background-color: var(--color-primary-100);
  color: var(--color-primary-800);
}

.dropdown-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dropdown-item-text .item-title {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--color-primary-900);
}

.dropdown-item-text .item-desc {
  font-size: 0.74rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat History Sidebar Components (Compact & Sleek) */
.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.45rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--color-primary-800);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
  margin-bottom: 0.35rem;
  min-height: 36px;
}

.new-chat-btn:hover {
  background-color: var(--color-primary-50);
  border-color: var(--color-primary-500);
  color: var(--color-primary-600);
}

.chat-history-group {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.chat-history-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0.3rem 0.5rem 0.1rem 0.5rem;
}

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  border: 1px solid transparent;
  min-height: 32px;
  position: relative;
  width: 100%;
  text-align: left;
}

.chat-history-item:hover {
  background-color: var(--bg-surface-alt);
  color: var(--color-primary-900);
}

.chat-history-item.active {
  background-color: var(--color-primary-50);
  color: var(--color-primary-700);
  border-color: var(--color-primary-100);
  font-weight: 600;
}

.history-item-icon {
  color: var(--text-light);
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.chat-history-item.active .history-item-icon {
  color: var(--color-primary-600);
}

.history-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

/* Back to Chat floating banner in Back Office */
.back-office-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
}

.back-office-banner-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary-800);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Content Container (Fixed 100vh Shell - Prevents chat input from falling down) */
.content-body {
  flex: 1;
  overflow: hidden;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* Chat view: Fills 100% of viewport without outer page scroll */
#tab-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 1rem 1.5rem;
  overflow: hidden;
}

/* Back Office Views: Scrollable independently */
.tab-view:not(#tab-chat) {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem 2.5rem 2rem;
  min-height: 0;
}

/* Common Card & Section Elements */
.section-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.card-title-group h3 {
  font-size: 1.15rem;
  margin-bottom: 0.2rem;
}

.card-title-group p {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* Buttons (With 44x44px accessible touch targets) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  text-decoration: none;
  min-height: 44px;
}

.btn-primary {
  background-color: var(--color-primary-600);
  color: white;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background-color: var(--color-primary-700);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-accent {
  background-color: var(--color-accent-600);
  color: white;
}

.btn-accent:hover {
  background-color: #b45309;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  min-height: 38px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s;
}

.btn-icon:hover {
  background-color: var(--bg-surface-alt);
  color: var(--color-primary-800);
}

/* Utility Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-heading);
  white-space: nowrap;
}

.badge-success {
  background-color: var(--status-success-bg);
  color: var(--status-success-text);
  border: 1px solid var(--status-success-border);
}

.badge-warning {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.badge-info {
  background-color: var(--status-info-bg);
  color: var(--status-info-text);
  border: 1px solid var(--status-info-border);
}

.badge-outline {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-medium);
}

/* Toast Notification (Strict: Zero Side-stripe Border, Semantic Z-index) */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 48px);
}

.toast {
  background-color: var(--color-primary-900);
  color: white;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  animation: slideInUp 0.25s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.15); /* Clean full border, NO side-stripe */
}

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

/* Responsive Styles for Tablet & Mobile */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
  }

  .content-body {
    padding: 1rem;
  }

  .app-header {
    padding: 0 1rem;
  }

  .user-info {
    display: none; /* Compact header on mobile */
  }

  .role-switcher-card {
    padding: 0.2rem 0.4rem;
  }
  
  .role-switcher-label {
    display: none;
  }
}

/* Accessibility: Reduced Motion Alternative */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .status-dot.pulse {
    animation: none !important;
  }
}
