/* ============================================================
   Webmail – application styles
   ============================================================ */

/* ---- Hidden column for grouping ---- */
.webmail-hidden-column {
  visibility: hidden;
}

/* ---- Activity Log ---- */
.webmail-activity-log {
  border-top: 1px solid #dee2e6;
  padding-top: 1rem;
}

.webmail-activity-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
}

.webmail-activity-toggle-btn:hover {
  background-color: #e9ecef;
}

.webmail-activity-count {
  background-color: #6c757d;
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.webmail-activity-chevron {
  transition: transform 0.2s ease-in-out;
  transform: rotate(180deg);
}

.webmail-activity-toggle-btn[aria-expanded="true"] .webmail-activity-chevron,
.webmail-activity-toggle-btn.expanded .webmail-activity-chevron {
  transform: rotate(0deg);
}

.webmail-activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.webmail-activity-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
}

.webmail-activity-item {
  padding: 0.5rem 0.75rem;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
  border-left: 3px solid #6c757d;
}

.webmail-activity-type {
  font-weight: 600;
  font-size: 0.9rem;
  color: #212529;
}

.webmail-activity-notes {
  font-size: 0.85rem;
  color: #495057;
  margin-top: 0.25rem;
}

.webmail-activity-meta {
  font-size: 0.8rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

/* ---- Page shell ---- */
.webmail-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 120px);
  min-height: 500px;
}

/* ---- Sidebar ---- */
.webmail-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.webmail-sidebar-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  border-bottom: 1px solid #dee2e6;
}

.webmail-sidebar-account-email {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #9ca3af;
  margin-top: 0.1rem;
}

.webmail-sidebar-section {
  padding: 0.5rem 0;
  border-bottom: 1px solid #dee2e6;
}

.webmail-folder-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  color: #212529;
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 0;
  transition: background 0.1s;
}

.webmail-folder-link:hover {
  background: #e9ecef;
  color: #212529;
  text-decoration: none;
}

.webmail-folder-link.active {
  background: #d0e7ff;
  font-weight: 600;
  color: #0d6efd;
}

.webmail-unread-badge {
  margin-left: auto;
  background: #0d6efd;
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.75rem;
  font-weight: 600;
}

.webmail-deleted-badge {
  background: #6c757d;
}

/* ---- Main content area ---- */
.webmail-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Toolbar ---- */
.webmail-toolbar {
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.webmail-bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.webmail-bulk-count {
  font-size: 0.85rem;
  color: #555;
  font-weight: 600;
}

/* ---- Message list ---- */
.webmail-message-list {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

/* Header row */
.webmail-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-size: 0.8rem;
  font-weight: 600;
  color: #495057;
  position: sticky;
  top: 0;
  z-index: 10;
}

.webmail-header-cell {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.webmail-header-attachment {
  width: 24px;
  flex-shrink: 0;
  justify-content: center;
}

.webmail-header-flag {
  width: 24px;
  flex-shrink: 0;
  justify-content: center;
}

.webmail-header-date {
  width: 80px;
  flex-shrink: 0;
}

.webmail-header-from {
  width: 180px;
  flex-shrink: 0;
}

.webmail-header-location {
  flex: 0 0 200px;
  min-width: 0;
}

.webmail-header-subject {
  flex: 1;
}

.webmail-sort-btn {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.webmail-sort-btn:hover {
  opacity: 1;
}

.webmail-message-row {
  display: flex !important;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  text-decoration: none;
  color: #212529;
}

.webmail-message-row > div {
  flex-shrink: 0;
}

.webmail-message-row:hover {
  background: #f5f8ff;
  text-decoration: none;
  color: #212529;
}

.webmail-message-row.unread {
  background: #fafcff;
  font-weight: 700 !important;
}

.webmail-message-row.unread > div {
  font-weight: 700 !important;
}

.webmail-message-row.unread > div > span,
.webmail-message-row.unread > div > div {
  font-weight: 700 !important;
}

.webmail-message-row.unread .webmail-msg-from,
.webmail-message-row.unread .webmail-msg-date,
.webmail-message-row.unread .webmail-msg-location,
.webmail-message-row.unread .webmail-msg-subject,
.webmail-message-row.unread .webmail-msg-subject-text,
.webmail-message-row.unread .webmail-msg-snippet {
  font-weight: 700 !important;
}

.webmail-message-row.selected {
  background: #dce8ff;
  outline: 2px solid #5591e8;
  outline-offset: -2px;
}

.webmail-message-row.selected:hover {
  background: #c8d9ff;
}

.webmail-msg-attachment {
  width: 24px;
  flex: 0 0 24px;
  display: flex;
  justify-content: center;
  color: #6c757d;
}

.webmail-msg-attachment--hidden {
  visibility: hidden;
}

.webmail-msg-flag {
  width: 24px;
  flex: 0 0 24px;
  display: flex;
  justify-content: center;
  color: #ffc107;
}

.webmail-msg-flag--hidden {
  visibility: hidden;
}

.webmail-msg-date {
  flex: 0 0 80px;
  font-size: 0.8rem;
  color: #6c757d;
}

.webmail-msg-from {
  flex: 0 0 180px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}


.webmail-msg-location {
  flex: 0 0 200px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.webmail-location-link {
  color: #0d6efd;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  display: block;
}

.webmail-location-link:hover {
  text-decoration: underline;
}

.webmail-msg-subject {
  flex: 1;
  overflow: hidden;
  font-size: 0.9rem;
  min-width: 0;
}

.webmail-subject-link {
  display: block;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.webmail-subject-link:hover {
  text-decoration: none;
  color: inherit;
}

.webmail-msg-subject-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.webmail-message-row.unread .webmail-msg-subject-text {
  font-weight: 700 !important;
}

.webmail-msg-snippet {
  color: #6c757d;
  font-weight: 400;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.15rem;
}

.webmail-sync-time {
  font-size: 0.7rem;
}

.webmail-empty-icon {
  font-size: 2.5rem;
  opacity: 0.35;
}

/* ---- Message detail ---- */
.webmail-message-detail {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.webmail-message-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #dee2e6;
}

.webmail-message-subject {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.webmail-meta-row {
  font-size: 0.875rem;
  color: #495057;
  margin-bottom: 0.2rem;
}

.webmail-meta-label {
  font-weight: 600;
  min-width: 60px;
  display: inline-block;
}

.webmail-message-body {
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.webmail-message-body-html {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---- Compose form ---- */
.webmail-compose-card {
  max-width: 1200px;
  margin: 1.5rem auto;
}

.webmail-compose-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.webmail-compose-field .webmail-compose-label {
  width: 5rem;
  flex-shrink: 0;
  font-weight: 600;
  text-align: left;
  margin-bottom: 0;
}

.webmail-compose-field .form-control {
  flex: 1;
}

.webmail-compose-trix {
  min-height: 180px;
  border-radius: 0 0 4px 4px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

/* Hide the file-attachment button in the compose editor */
.webmail-compose-card trix-toolbar .trix-button--icon-attach {
  display: none;
}

.webmail-prefill-attachment {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: #f0f4ff;
  border: 1px solid #c0cef5;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #2c4da0;
}

/* ---- Account settings form ---- */
.webmail-account-form {
  max-width: 680px;
}

.webmail-signature-trix {
  min-height: 120px;
  border-radius: 0 0 4px 4px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Hide the file-attachment button in the signature editor */
.webmail-account-form trix-toolbar .trix-button--icon-attach {
  display: none;
}

.webmail-fieldset-legend {
  font-weight: 600;
  font-size: 0.9rem;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0.25rem;
}

/* ---- Pagination ---- */
.webmail-pagination {
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #6c757d;
  border-top: 1px solid #dee2e6;
  background: #fff;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.webmail-per-page {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

/* ---- Empty state ---- */
.webmail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #6c757d;
  gap: 0.5rem;
}

.webmail-empty-icon {
  font-size: 2.5rem;
  opacity: 0.4;
}

/* ---- Accounts list ---- */
.webmail-accounts-list {
  max-width: 700px;
}

/* ---- Nav bar Mail button + unread badge ---- */
.pms-webmail-nav-btn {
  position: relative;
}

.pms-webmail-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc3545;
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 1;
  margin-left: 4px;
  vertical-align: middle;
}

.pms-webmail-unread-badge--hidden {
  display: none;
}

.webmail-signature-field {
  font-family: monospace;
  font-size: 0.875rem;
  resize: vertical;
}

.webmail-image-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: #fffbea;
  border: 1px solid #e9c84a;
  border-radius: 6px;
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.webmail-image-warning-text {
  flex: 1;
  color: #5a4a00;
}

.webmail-image-warning-text .bi {
  color: #b8860b;
  margin-right: 4px;
}

.webmail-quoted-preview {
  display: flex;
  gap: 0;
  margin-top: 8px;
  margin-bottom: 16px;
  border-top: 1px solid #e0e0e0;
  padding-top: 10px;
}

.webmail-quoted-preview-bar {
  width: 3px;
  flex-shrink: 0;
  background-color: #0078d4;
  border-radius: 2px;
  align-self: stretch;
}

.webmail-quoted-preview-body {
  padding-left: 12px;
  flex: 1;
  overflow: hidden;
}

.webmail-quoted-preview-text {
  margin: 0;
  font-size: 0.82rem;
  color: #666;
  white-space: pre-wrap;
  font-family: inherit;
  word-break: break-word;
}

.pms-password-toggle {
  color: #6c757d;
  border-color: #ced4da;
}

.pms-password-toggle:hover {
  color: #343a40;
  background-color: #f8f9fa;
  border-color: #ced4da;
}

/* Search form in sidebar */
.webmail-search-form {
  padding: 0 8px;
}

.webmail-search-wrap {
  display: flex;
  align-items: center;
  gap: 0;
}

.webmail-search-input {
  border-right: none;
  border-radius: 4px 0 0 4px;
  height: 30px;
  width: 100%;
}

select.webmail-search-input {
  border-right: 1px solid #ced4da;
  border-radius: 4px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236c757d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 16px 12px;
  padding-right: 1.75rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  height: 30px;
  min-height: 30px;
  font-size: 0.8rem;
}

.webmail-search-input:focus {
  z-index: 1;
}

.webmail-search-btn {
  padding: 0 8px;
  background: #fff;
  border: 1px solid #ced4da;
  border-left: none;
  border-radius: 0 4px 4px 0;
  color: #6c757d;
  cursor: pointer;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webmail-search-btn:hover {
  background: #f8f9fa;
  color: #343a40;
}

/* Search results */
.webmail-search-results {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

.webmail-search-group {
  margin-bottom: 4px;
}

.webmail-search-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  background: #f4f6f8;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  user-select: none;
}

.webmail-search-chevron {
  margin-left: 6px;
  transition: transform 0.2s ease;
}

.webmail-search-group-header.collapsed .webmail-search-chevron {
  transform: rotate(-90deg);
}

.webmail-search-group-count {
  margin-left: auto;
  background: #0078d4;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
}

.webmail-sync-time {
  font-size: 0.7rem;
}

/* ---- Attachments ---- */
.webmail-attachments {
  border-top: 1px solid #e8ecf0;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
}

.webmail-attachments-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.webmail-attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.webmail-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background: #f1f4f8;
  border: 1px solid #d0d8e4;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #1a4b8c;
  text-decoration: none;
  max-width: 280px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.webmail-attachment-chip:hover {
  background: #e2eaf6;
  color: #0d3a7a;
  text-decoration: none;
}

.webmail-attachment-size {
  color: #6c757d;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* Address autocomplete dropdown */
.webmail-autocomplete-wrapper {
  position: relative;
}

.webmail-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  background: #fff;
  border: 1px solid #ced4da;
  border-top: none;
  border-radius: 0 0 0.375rem 0.375rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 220px;
  overflow-y: auto;
}

.webmail-autocomplete-item {
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.webmail-autocomplete-item:hover,
.webmail-autocomplete-active {
  background-color: #e8f0fe;
  color: #1a5fa8;
}

/* Location search in compose form */
.webmail-location-search-wrapper {
  position: relative;
  flex: 1;
}

.webmail-location-search-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Email attach search - two column layout */
.email-attach-search-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.email-attach-search-table colgroup col:first-child {
  width: 300px;
}

.email-attach-search-table colgroup col:last-child {
  width: 150px;
}

.email-attach-search-table td {
  padding: 8px;
}

.email-attach-search-table td:first-child {
  border-right: 1px solid #dee2e6;
  cursor: pointer;
}

.webmail-location-search-input-row .form-control {
  flex: 1;
}

.webmail-location-clear {
  flex-shrink: 0;
  padding: 0.375rem 0.6rem;
  font-size: 0.9rem;
  line-height: 1;
  background: none;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  color: #6c757d;
  cursor: pointer;
}

.webmail-location-clear:hover {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

.webmail-location-search-name {
  display: block;
}

.webmail-location-search-sub {
  display: block;
  font-size: 0.8rem;
  color: #6c757d;
}

.webmail-location-search-item {
  white-space: normal;
  line-height: 1.3;
  padding: 0.5rem 0.75rem;
}

/* Group by dropdown in toolbar */
.webmail-group-by {
  margin-left: auto;
  width: 140px;
}

.webmail-group-by .form-select {
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
}

/* Group headers in message list */
.webmail-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f4f6f8;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  user-select: none;
}

.webmail-group-header--nested {
  padding-left: 2.5rem;
  background-color: #f1f3f5;
}

.webmail-group-link--nested {
  font-size: 0.9em;
  color: #495057;
}

.webmail-group-messages--nested {
  padding-left: 1.5rem;
}

.webmail-group-toggle-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #6c757d;
  transition: color 0.2s;
  display: flex;
  align-items: center;
}

.webmail-group-toggle-btn:hover {
  color: #0d6efd;
}

.webmail-group-chevron {
  transition: transform 0.2s;
  display: inline-block;
}

.webmail-group-link {
  color: #0d6efd;
  text-decoration: none;
}

.webmail-group-link:hover {
  text-decoration: underline;
}

.webmail-group-count {
  margin-left: auto;
  background: #6c757d;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
}

.webmail-group-messages {
  transition: max-height 0.3s ease-out;
}

.webmail-sidebar-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  margin-bottom: 0.25rem;
  padding: 0 8px;
}
