/* ==========================================================================
   Bespoke Enterprise Design System - Layout & Structure
   ========================================================================== */

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Elevated App Header (60px)
   ========================================================================== */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: relative;
  z-index: var(--z-header);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-icon-wrap {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.brand-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

/* Spotlight Command Search Bar */
.header-search {
  flex: 1;
  max-width: 540px;
  margin: 0 24px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  right: 12px;
  color: var(--text-subtle);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-input {
  width: 100%;
  height: 36px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 38px 0 68px;
  font-family: inherit;
  font-size: var(--text-xs);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  background-color: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.search-shortcut-pill {
  position: absolute;
  left: 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  letter-spacing: 0.05em;
  pointer-events: none;
  box-shadow: var(--shadow-subtle);
}

.search-clear-btn {
  position: absolute;
  left: 36px;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 2px;
  display: none;
  align-items: center;
  justify-content: center;
}
.search-clear-btn:hover {
  color: var(--text-primary);
}

/* Header User Menu & Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}
.header-user-pill:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.user-presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--emerald);
  box-shadow: 0 0 0 2px #fff;
  position: absolute;
  bottom: 0;
  left: 0;
}

/* Header Popovers & Dropdowns */
.header-popover-wrapper {
  position: relative;
}

.header-dropdown-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dropdown);
  z-index: 1050;
  animation: popoverFadeIn 160ms var(--ease-out);
  overflow: hidden;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Notifications Popover */
.notifications-popover {
  width: 360px;
  max-width: 90vw;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.popover-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popover-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.popover-counter-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background-color: var(--primary-light);
  color: var(--primary);
}

.popover-link-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}
.popover-link-btn:hover {
  background-color: var(--primary-light);
  text-decoration: underline;
}

.notifications-items-list {
  max-height: 380px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  position: relative;
}
.notification-item:last-child {
  border-bottom: none;
}
.notification-item:hover {
  background-color: var(--bg-surface-hover);
}
.notification-item.unread {
  background-color: var(--bg-surface-unread);
}

.notification-body {
  flex: 1;
  min-width: 0;
}

.notification-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.notification-sender {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-time {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.notification-subject {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
  flex-shrink: 0;
  margin-top: 5px;
}

.notifications-empty {
  padding: 36px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.notifications-empty .empty-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #ecfdf5;
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.notifications-empty .empty-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.notifications-empty .empty-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* User Profile Dropdown */
.user-dropdown-popover {
  width: 280px;
  padding: 8px 0;
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.user-dropdown-info {
  flex: 1;
  min-width: 0;
}

.user-dropdown-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.user-dropdown-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.user-dept-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background-color: var(--bg-app);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.user-role-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background-color: var(--primary-light);
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: 6px 0;
}

.dropdown-item-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: right;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}
.dropdown-item-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.dropdown-logout-btn {
  color: var(--rose) !important;
}
.dropdown-logout-btn:hover {
  background-color: #fff1f2 !important;
  color: #e11d48 !important;
}

/* Standalone Direct Full-Click Logout Button */
.btn-logout-full {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}
.btn-logout-full:hover {
  background-color: #fef2f2;
  border-color: rgba(244, 63, 94, 0.35);
  color: var(--rose);
  box-shadow: 0 1px 3px rgba(244, 63, 94, 0.1);
}
.btn-logout-full:active {
  transform: translateY(1px);
}

/* ==========================================================================
   Main 3-Pane Body
   ========================================================================== */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Pane 1: Sidebar */
.sidebar-pane {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.sidebar-compose-wrap {
  padding: 14px 14px 10px 14px;
  flex-shrink: 0;
}

.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 14px 10px;
}

.sidebar-bottom {
  padding: 12px 14px;
  border-top: 1px solid var(--border-default);
  background-color: var(--bg-sidebar);
  flex-shrink: 0;
}

/* Pane 2: Center Message List */
.message-list-pane {
  width: var(--list-width);
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.list-topbar {
  padding: 12px 16px 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.list-title-text {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Apple/Linear Segmented Control */
.segmented-control {
  display: flex;
  background-color: #eef2f6;
  border-radius: var(--radius-md);
  padding: 2px;
  margin: 0 14px 8px 14px;
  border: 1px solid rgba(226, 232, 240, 0.7);
}

.segmented-btn {
  flex: 1;
  padding: 5px 0;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-align: center;
}
.segmented-btn.active {
  background-color: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message-items-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  scroll-behavior: smooth;
}

.list-footer-pagination {
  padding: 8px 14px;
  border-top: 1px solid var(--border-default);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-2xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Pane 3: Executive Reading Pane */
.reading-pane {
  flex: 1;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.reading-pane-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}

.reading-pane-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface-elevated);
  margin: 14px 18px 18px 18px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.reading-pane-header {
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  flex-shrink: 0;
}

.reading-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  font-size: var(--text-base);
  line-height: 1.75;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.reading-pane-attachments {
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-app);
  flex-shrink: 0;
}

/* Clean Micro Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
