/*
 * Estilos base inspirados en dashboards Sneat/Bootstrap.
 */
:root {
  --primary: #696cff;
  --body-bg: #f5f5f9;
  --sidebar-bg: #ffffff;
  --text-main: #34384c;
}

body {
  background: var(--body-bg);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
}

body.theme-dark {
  --body-bg: #171923;
  --sidebar-bg: #222635;
  --text-main: #f3f4f8;
  color-scheme: dark;
}

.theme-dark .panel,
.theme-dark .metric,
.theme-dark .topbar,
.theme-dark .mobile-appbar,
.theme-dark .login-card {
  background: #222635;
  color: var(--text-main);
}

.theme-dark .sidebar {
  background: #1d2130;
  border-right-color: #303548;
}

.theme-dark .app-shell {
  background: var(--body-bg);
}

.theme-dark .nav-link,
.theme-dark .account-link,
.theme-dark .mail-account,
.theme-dark .mail-date,
.theme-dark .topbar p,
.theme-dark .text-muted {
  color: #b8bed4 !important;
}

.theme-dark .nav-link:hover,
.theme-dark .account-link:hover,
.theme-dark .mail-row:hover,
.theme-dark .mail-open:hover {
  background: #2d3246;
}

.theme-dark .nav-link {
  background: transparent;
}

.theme-dark .account-link {
  background: transparent;
}

.theme-dark .sidebar-section {
  border-top-color: #303548;
}

.theme-dark .form-control,
.theme-dark .form-select,
.theme-dark .compose-editor,
.theme-dark .editor-toolbar,
.theme-dark .mail-frame {
  background-color: #171923;
  border-color: #3a4056;
  color: var(--text-main);
}

.theme-dark .form-control::placeholder,
.theme-dark textarea.form-control::placeholder {
  color: #8d94ad;
  opacity: 1;
}

.theme-dark .table {
  --bs-table-bg: #171923;
  --bs-table-color: #f3f4f8;
  --bs-table-border-color: #303548;
  --bs-table-striped-bg: #1d2130;
  --bs-table-striped-color: #f3f4f8;
  --bs-table-hover-bg: #2d3246;
  --bs-table-hover-color: #ffffff;
  color: #f3f4f8;
}

.theme-dark .table > :not(caption) > * > * {
  background-color: var(--bs-table-bg);
  border-color: var(--bs-table-border-color);
  color: var(--bs-table-color);
}

.theme-dark .table-responsive {
  background: #171923;
  border-radius: 6px;
}

.theme-dark .mail-row,
.theme-dark .mail-body,
.theme-dark .attachments-panel,
.theme-dark .bulk-toolbar {
  border-color: #303548;
}

.theme-dark .mail-unread {
  background: #202b45;
}

.theme-dark .mail-blocked {
  background: #332328;
}

.theme-dark .mail-html-content {
  background: #171923;
  color: #f3f4f8;
}

.theme-dark .mail-html-content * {
  background-color: transparent !important;
  color: inherit !important;
}

.theme-dark .mail-html-content a {
  color: #8ea2ff !important;
}

.theme-dark .calendar-preview-list {
  border-color: #303548;
}

.theme-dark .calendar-preview {
  background: #171923;
  border-color: #3a4056;
}

.theme-dark .calendar-preview-label,
.theme-dark .calendar-preview p {
  color: #b8bed4;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.mobile-appbar,
.mobile-menu-close,
.sidebar-backdrop {
  display: none;
}

.sidebar {
  flex: 0 0 260px;
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid #e7e7ef;
  padding: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(123, 128, 154, .35);
  border-radius: 999px;
}

.brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  margin-bottom: 1.5rem;
}

.brand-mark {
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: .45rem .5rem;
}

.nav-link {
  color: #5d6078;
  border-radius: 8px;
  padding: .7rem .85rem;
}

.nav-link:hover {
  background: #f0f1ff;
  color: var(--primary);
}

.sidebar-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e7e7ef;
  overflow: hidden;
}

.sidebar-title {
  color: #7b809a;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: .55rem;
  text-transform: uppercase;
}

.account-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #5d6078;
  font-size: .86rem;
  padding: .45rem .35rem;
  text-decoration: none;
  overflow: hidden;
}

.account-link span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-link:hover {
  color: var(--primary);
}

.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #20c997;
  flex: 0 0 auto;
}

.notification-status {
  color: #7b809a;
  font-size: .78rem;
  margin-top: .45rem;
  min-height: 1rem;
}

.content {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 260px);
  padding: 1.5rem;
  overflow-x: hidden;
}

.topbar {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(67, 89, 113, .08);
}

.topbar h1,
.panel h2 {
  font-size: 1.25rem;
  margin: 0;
}

.topbar p {
  margin: .2rem 0 0;
  color: #7b809a;
  overflow-wrap: anywhere;
}

.panel,
.metric {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 2px 12px rgba(67, 89, 113, .08);
}

.metric span {
  display: block;
  color: #7b809a;
}

.metric strong {
  display: block;
  font-size: 2rem;
  margin-top: .5rem;
}

.metric small {
  display: block;
  margin-top: .25rem;
}

.metric-link {
  color: var(--text-main);
  display: block;
  height: 100%;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}

.metric-link:hover {
  color: var(--text-main);
  transform: translateY(-1px);
}

.metric-link strong {
  align-items: center;
  display: flex;
  gap: .55rem;
}

.account-filter {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding-bottom: .15rem;
}

.account-filter .btn {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-list {
  display: grid;
  gap: .2rem;
}

.mail-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .75rem;
  align-items: center;
  border-bottom: 1px solid #e7e7ef;
}

.mail-checkbox {
  margin-left: .5rem;
}

.mail-open {
  display: grid;
  grid-template-columns: 10px 42px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  color: var(--text-main);
  padding: .85rem .5rem;
  text-decoration: none;
  min-width: 0;
}

.mail-row:hover,
.mail-open:hover {
  background: #f7f7ff;
}

.mail-list > a.mail-row {
  grid-template-columns: 10px minmax(0, 1fr) auto;
  color: var(--text-main);
  padding: .85rem .5rem;
  text-decoration: none;
}

.mail-row-actions {
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  gap: 1rem;
  padding: .85rem .5rem;
}

.mail-row-no-checkbox {
  grid-template-columns: minmax(0, 1fr);
}

.mail-row-no-checkbox .mail-open {
  width: 100%;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border-bottom: 1px solid #e7e7ef;
  padding-bottom: .75rem;
  margin-bottom: .35rem;
}

.bulk-select-all {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: #5d6078;
  font-size: .9rem;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: flex-end;
}

.bulk-actions .bulk-icon-button {
  align-items: center;
  display: inline-flex;
  flex: 0 0 40px;
  height: 40px;
  justify-content: center;
  padding: 0;
  width: 40px;
}

.bulk-icon-button .bi {
  font-size: 1.1rem;
  line-height: 1;
}

.mail-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  justify-content: flex-end;
}

.mail-actions form {
  margin: 0;
}

.mail-icon-button {
  align-items: center;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  padding: 0;
  width: 40px;
}

.mail-icon-button .bi {
  font-size: 1.08rem;
  line-height: 1;
}

.mail-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: center;
  margin-top: 1rem;
}

.inbox-controls-toggle {
  display: none;
}

.pagination-gap {
  align-items: center;
  color: #7b809a;
  display: inline-flex;
  padding: 0 .25rem;
}

.mail-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.mail-unread {
  background: #f8faff;
}

.mail-unread .mail-status-dot {
  background: #0d6efd;
}

.mail-unread .mail-subject,
.mail-unread .mail-from {
  font-weight: 700;
}

.mail-blocked {
  box-shadow: inset 3px 0 0 #ff3e1d;
  background: #fff8f8;
}

.mail-blocked .mail-status-dot {
  background: #ff3e1d;
}

.mail-pinned {
  background: rgba(105, 108, 255, .08);
}

.theme-dark .mail-pinned {
  background: #242b46;
}

.mail-main {
  min-width: 0;
}

.mail-avatar {
  align-items: center;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 700;
  height: 42px;
  justify-content: center;
  line-height: 1;
  text-transform: uppercase;
  width: 42px;
}

.mail-from,
.mail-subject,
.mail-account {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-from {
  font-size: .92rem;
}

.mail-subject {
  margin-top: .15rem;
}

.mail-account,
.mail-date {
  color: #7b809a;
  font-size: .82rem;
}

.attachment-indicator {
  color: #7b809a;
  margin-right: .35rem;
}

.pin-indicator {
  color: #ffab00;
  margin-right: .35rem;
}

.mail-body {
  border-top: 1px solid #e7e7ef;
  margin-top: 1rem;
  padding-top: 1rem;
}

.mail-html-content {
  background: #fff;
  border-radius: 8px;
  color: #212529;
  min-height: 420px;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem;
  width: 100%;
}

.mail-html-content *,
.mail-html-content *::before,
.mail-html-content *::after {
  box-sizing: border-box;
  max-width: 100%;
}

.mail-html-content img,
.mail-html-content video {
  height: auto;
  max-width: 100%;
}

.mail-html-content table {
  max-width: 100% !important;
  table-layout: fixed;
  width: 100% !important;
}

.mail-html-content td,
.mail-html-content th,
.mail-html-content p,
.mail-html-content div,
.mail-html-content span {
  overflow-wrap: anywhere;
  word-break: normal;
}

.attachments-panel {
  border-top: 1px solid #e7e7ef;
  margin-top: 1rem;
  padding-top: 1rem;
}

.attachments-panel h3 {
  font-size: 1rem;
  margin-bottom: .75rem;
}

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

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  max-width: 100%;
  border: 1px solid #d9dee8;
  border-radius: 8px;
  color: var(--text-main);
  padding: .55rem .7rem;
  text-decoration: none;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip small {
  color: #7b809a;
  white-space: nowrap;
}

.calendar-preview-list {
  border-top: 1px solid #e7e7ef;
  display: grid;
  gap: .75rem;
  margin-top: 1rem;
  padding-top: 1rem;
}

.calendar-preview {
  align-items: stretch;
  background: #f7f8fb;
  border: 1px solid #e2e6f0;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  overflow: hidden;
}

.calendar-preview-icon {
  align-items: center;
  background: #696cff;
  color: #fff;
  display: flex;
  font-size: 1.75rem;
  justify-content: center;
}

.calendar-preview-content {
  padding: 1rem;
}

.calendar-preview-label {
  color: #7b809a;
  display: block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
  margin-bottom: .25rem;
  text-transform: uppercase;
}

.calendar-preview h3 {
  font-size: 1.08rem;
  margin-bottom: .65rem;
}

.calendar-preview p {
  align-items: center;
  color: #5d6078;
  display: flex;
  gap: .45rem;
  margin-bottom: .45rem;
}

.calendar-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .85rem;
}

.accounts-card-list,
.blacklist-card-list {
  display: none;
}

.account-card,
.blacklist-card {
  border: 1px solid #e7e7ef;
  border-radius: 8px;
  padding: 1rem;
}

.account-card + .account-card,
.blacklist-card + .blacklist-card {
  margin-top: .85rem;
}

.account-card-header span,
.account-card-details dt,
.blacklist-card span {
  color: #7b809a;
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.account-card-header strong,
.blacklist-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.blacklist-card p {
  margin: .15rem 0 .75rem;
  overflow-wrap: anywhere;
}

.blacklist-summary-actions {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: .65rem;
  justify-content: flex-end;
}

.blacklist-collapsed-list {
  border-top: 1px solid #e7e7ef;
  margin-top: 1rem;
  padding-top: 1rem;
}

.theme-dark .blacklist-collapsed-list {
  border-color: #303548;
}

.account-card-details {
  display: grid;
  gap: .65rem;
  margin: .9rem 0;
}

.account-card-details div {
  min-width: 0;
}

.account-card-details dd {
  margin: .15rem 0 0;
  overflow-wrap: anywhere;
}

.account-card-actions {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-card-actions .btn,
.account-card-actions form {
  width: 100%;
}

.mail-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.mail-frame {
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  border: 1px solid #d9dee8;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: .5rem;
  background: #f7f7fb;
}

.compose-editor {
  min-height: 260px;
  border: 1px solid #d9dee8;
  border-radius: 0 0 8px 8px;
  padding: .85rem;
  background: #fff;
  outline: none;
}

.compose-editor:empty::before {
  content: attr(data-placeholder);
  color: #9aa0b5;
}

.signature-compose-editor {
  min-height: 140px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 8px 28px rgba(67, 89, 113, .14);
}

.login-card h1 {
  font-size: 1.75rem;
}

@media (max-width: 840px) {
  body.menu-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    overflow-x: hidden;
  }

  .mobile-appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #fff;
    border-bottom: 1px solid #e7e7ef;
    padding: .6rem .85rem;
    box-shadow: 0 2px 12px rgba(67, 89, 113, .08);
  }

  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    color: var(--text-main);
    font-weight: 700;
    text-decoration: none;
  }

  .mobile-menu-toggle,
  .mobile-menu-close {
    width: 40px;
    height: 40px;
    border: 1px solid #e7e7ef;
    border-radius: 8px;
    background: #fff;
    color: var(--text-main);
    display: inline-grid;
    place-items: center;
    font-size: 1.2rem;
    line-height: 1;
  }

  .theme-dark .mobile-menu-toggle,
  .theme-dark .mobile-menu-close {
    background: #252a3b;
    border-color: #303548;
    color: #f3f4f8;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgba(23, 25, 38, .48);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }

  .menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    flex: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    width: 100%;
    height: 100dvh;
    overflow-y: auto;
    border-right: 0;
    padding: 1rem;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }

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

  .mobile-menu-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
  }

  .brand {
    gap: .65rem;
    margin: .1rem 3.2rem 1.25rem 0;
    font-size: 1.05rem;
  }

  .brand-mark {
    border-radius: 8px;
    padding: .4rem .48rem;
    font-size: .9rem;
  }

  .sidebar .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem !important;
  }

  .sidebar-section {
    margin-top: 1rem;
    padding-top: 1rem;
  }

  .sidebar-title {
    display: block;
  }

  .account-link {
    display: flex;
    max-width: none;
    padding: .7rem .8rem;
    border-radius: 8px;
    background: #f5f5f9;
    margin: 0 0 .45rem;
  }

  .theme-dark .account-link,
  .theme-dark .nav-link {
    background: #252a3b;
  }

  .nav-link {
    min-height: 72px;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: .55rem;
    padding: .85rem;
    font-size: .95rem;
    line-height: 1.15;
    text-align: left;
    white-space: nowrap;
    background: #f7f7fb;
  }

  .nav-link i {
    font-size: 1.15rem;
  }

  .content {
    max-width: 100%;
    padding: .9rem;
  }

  .account-filter {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .account-filter .btn {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-left: .65rem;
    padding-right: .65rem;
    text-align: center;
    white-space: nowrap;
  }

  .inbox-controls-panel {
    padding-bottom: .85rem;
  }

  .inbox-controls-toggle {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
  }

  .inbox-controls-body {
    display: none;
  }

  .inbox-controls-body.is-open {
    display: block;
  }

  .inbox-controls-panel h2 {
    font-size: 1.15rem;
  }

  .inbox-controls-panel p {
    font-size: .88rem;
  }

  .topbar {
    padding: 1rem;
    margin-bottom: .85rem;
  }

  .topbar h1 {
    font-size: 1.35rem;
  }

  .topbar p {
    font-size: .95rem;
  }

  .panel,
  .metric {
    padding: 1rem;
  }

  .metric strong {
    font-size: 1.75rem;
  }

  .mail-row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: .5rem;
  }

  .mail-checkbox {
    margin-left: .15rem;
  }

  .mail-open {
    grid-template-columns: 8px 40px minmax(0, 1fr);
    gap: .65rem;
    padding: .9rem .25rem;
  }

  .mail-row-actions {
    grid-template-columns: 10px minmax(0, 1fr);
    gap: .25rem;
    padding: .9rem .25rem;
  }

  .mail-date {
    grid-column: 3;
    font-size: .78rem;
  }

  .mail-avatar {
    height: 40px;
    width: 40px;
  }

  .mail-row form {
    grid-column: 2;
  }

  .bulk-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .bulk-actions {
    display: flex;
    gap: .55rem;
    justify-content: center;
  }

  .bulk-actions .bulk-icon-button {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }

  .mail-actions {
    justify-content: flex-start;
  }

  .mail-icon-button {
    height: 44px;
    width: 44px;
  }

  .mail-html-content {
    overflow-x: auto;
    padding: .75rem;
    -webkit-overflow-scrolling: touch;
  }

  .mail-html-content table {
    margin-left: auto;
    margin-right: auto;
    max-width: 100% !important;
    min-width: 0;
    table-layout: auto;
    width: 100% !important;
  }

  .mail-html-content table table {
    min-width: 0;
    width: 100% !important;
  }

  .calendar-preview {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .calendar-preview-icon {
    font-size: 1.35rem;
  }

  .calendar-preview-actions .btn {
    flex: 1 1 100%;
    text-align: center;
  }

  .panel .d-flex {
    align-items: flex-start !important;
    gap: .75rem;
  }

  .panel .btn {
    white-space: nowrap;
  }

  .accounts-table,
  .blacklist-table {
    display: none;
  }

  .accounts-card-list,
  .blacklist-card-list {
    display: block;
  }

  .theme-dark .account-card,
  .theme-dark .blacklist-card {
    border-color: #303548;
    background: #171923;
  }
}

@media (max-width: 430px) {
  .mobile-appbar {
    padding: .55rem .75rem;
  }

  .mobile-brand,
  .brand {
    font-size: .95rem;
  }

  .mobile-menu-toggle,
  .mobile-menu-close {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .content {
    padding: .75rem;
  }

  .nav-link {
    min-height: 68px;
    font-size: .88rem;
    padding: .75rem;
  }

  .topbar h1 {
    font-size: 1.25rem;
  }

  .panel h2 {
    font-size: 1.1rem;
  }
}
