/*
 * Base structure
 */

/* Move down content because we have a fixed navbar that is 50px tall */
body {
  padding-top: 50px;
  padding-bottom: 30px;
  background-color: #f1f5f9;
  color: #1e293b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* Keep headings and controls consistent across the dashboard and auth pages. */
h1,
h2,
h3,
h4,
h5,
h6,
button,
input,
select,
textarea,
.btn {
  font-family: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: #172033;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.sub-header {
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

/*
 * Top navigation
 */
.navbar-fixed-top {
  border: 0;
  font-size: 12px;
}

.navbar-inverse {
  background-color: #1e293b;
  border-color: #0f172a;
}

.navbar-inverse .navbar-brand {
  color: #ffffff;
  font-weight: 600;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 7px 20px;
}

.app-logo {
  display: block;
  width: auto;
  height: 30px;
}

.app-brand-label {
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.navbar-inverse .navbar-brand:hover,
.navbar-inverse .navbar-brand:focus {
  color: #c7d2fe;
}

.navbar-inverse .navbar-nav > li > a {
  color: #cbd5e1;
}

.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus {
  color: #ffffff;
}

.navbar-inverse .navbar-text {
  color: #cbd5e1;
  margin: 12px 0;
}

.current-domain-badge {
  background-color: #6366f1;
  color: #ffffff;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
}

.current-domain-badge .fa-globe {
  margin-right: 6px;
}

.sidebar-domain {
  padding: 13px 20px;
  color: #ffffff;
  background-color: #16202f;
  border-bottom: 1px solid #0f172a;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-domain .fa-globe {
  color: #6366f1;
}

.sidebar-user {
  padding: 13px 20px;
  border-top: 1px solid #263449;
  color: #94a3b8;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user .fa-user {
  color: #f97316;
}

/*
 * Sidebar
 */

/* Hide for mobile, show later */
.sidebar {
  display: none;
}
@media (min-width: 768px) {
  .sidebar {
    position: fixed;
    top: 50px;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #1e293b;
    border: 0;
    border-radius: 0;
  }
}

/* Sidebar navigation */
.nav-sidebar {
  margin-right: -21px; /* 20px padding + 1px border */
  margin-bottom: 20px;
  margin-left: -20px;
  border-top: 1px solid #0f172a;
}

.nav-sidebar > li > ul {
  padding: 0;
  background-color: #16202f;
}

.nav-sidebar > li > ul > li > a {
  display: block;
  padding: 10px 15px 10px 30px;
  text-decoration: none;
  outline: none;
  color: #94a3b8;
  border-left: 3px solid transparent;
}

.nav-sidebar > li > ul > li > a:hover,
.nav-sidebar > li > ul > li > a:focus {
  color: #ffffff;
  background-color: #334155;
  border-left-color: #6366f1;
  text-decoration: none;
}

.nav-sidebar > li > a {
  padding-right: 20px;
  padding-left: 20px;
  outline: none;
  color: #cbd5e1;
  font-weight: 500;
}

.nav-sidebar > li > a:hover,
.nav-sidebar > li > a:focus {
  color: #ffffff;
  background-color: #334155;
  text-decoration: none;
}

/*
 * Main content
 */

.main {
  padding: 20px;
}
@media (min-width: 768px) {
  .main {
    padding-right: 40px;
    padding-left: 40px;
  }
}
.main .page-header {
  margin-top: 0;
}

/*
 * Content action buttons (spacing between buttons and tables)
 */
.content > .btn,
.content > .actions {
  margin-bottom: 15px;
}

.content > .actions .btn,
.content > .btn {
  margin-right: 5px;
}

.content h3 {
  margin-top: 0;
  margin-bottom: 18px;
  font-size: 21px;
  line-height: 1.3;
}

.content h4 {
  margin-top: 26px;
  margin-bottom: 14px;
  font-size: 16px;
  line-height: 1.35;
  color: #334155;
}

.content-help {
  max-width: 760px;
  margin: -6px 0 18px;
  color: #64748b;
  line-height: 1.6;
}

.server-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 460px;
  margin-bottom: 20px;
}

.domain-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.domain-filter label {
  flex: 0 0 auto;
  margin: 0;
  color: #334155;
  font-weight: 600;
}

.domain-filter input,
.domain-filter select {
  width: 260px;
  max-width: 100%;
  margin: 0;
}

.entity-search {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 460px;
  margin: 0 0 0 20px;
  vertical-align: top;
  white-space: nowrap;
}

.entity-search label {
  flex: 0 0 auto;
  margin: 0;
  color: #334155;
  font-weight: 600;
}

.entity-search .search-icon-label,
.domain-filter .search-icon-label {
  color: #2563eb;
  font-size: 16px;
  cursor: text;
}

.entity-search input {
  width: 300px;
  max-width: 100%;
  margin: 0;
}

.mailbox.index > div:first-of-type .entity-search {
  flex: 0 0 auto;
}

.alias.index .entity-search {
  margin-bottom: 20px;
}

.server-filter label {
  flex: 0 0 auto;
  margin: 0;
  color: #334155;
  font-weight: 600;
}

.server-filter select {
  max-width: 300px;
  margin: 0;
}

.shards.selector .table {
  table-layout: fixed;
}

.shards.selector .table th,
.shards.selector .table td {
  text-align: center;
  vertical-align: middle;
}

.shards.selector .table .domain-column {
  width: 38%;
}

.shards.selector .table .server-column {
  width: 37%;
}

.shards.selector .table .actions {
  width: 25%;
  text-align: center;
}

@media (max-width: 600px) {
  .server-filter {
    display: block;
    max-width: none;
  }

  .domain-filter {
    display: block;
  }

  .domain-filter label,
  .domain-filter input,
  .domain-filter select {
    display: block;
    width: 100%;
    max-width: none;
  }

  .domain-filter label {
    margin-bottom: 6px;
  }

  .entity-search {
    display: block;
    max-width: none;
    margin: 15px 0 20px;
    white-space: normal;
  }

  .entity-search label,
  .entity-search input {
    display: block;
    width: 100%;
    max-width: none;
  }

  .entity-search label {
    margin-bottom: 6px;
  }

  .server-filter label,
  .server-filter select {
    display: block;
    width: 100%;
    max-width: none;
  }

  .server-filter label {
    margin-bottom: 6px;
  }
}

.context-field {
  margin-bottom: 15px;
  padding: 11px 13px;
  background: #eef2f7;
  border: 1px solid #d7dee8;
  border-radius: 4px;
  color: #172033;
}

.context-field-label {
  display: block;
  margin-bottom: 3px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.totp-setup {
  margin: 15px 0;
  padding: 14px;
  background: #eef2f7;
  border: 1px solid #d7dee8;
  border-radius: 4px;
}

.totp-setup > code,
.totp-setup > small {
  display: block;
  margin-top: 8px;
  word-break: break-all;
}

.totp-qr {
  display: block;
  width: 240px;
  height: 240px;
  margin: 12px 0;
  background: #ffffff;
}

.totp-recovery {
  margin: 15px 0;
  padding: 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 4px;
}

.totp-recovery code {
  display: block;
  white-space: pre-line;
  line-height: 1.8;
}

.api-key-reveal {
  margin: 0 0 20px;
  padding: 15px;
  background: #ecfdf5;
  border: 1px solid #86efac;
  border-radius: 6px;
}

.api-key-reveal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.api-key-reveal-row code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 10px;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.api-key-reveal p {
  margin: 8px 0 0;
  color: #166534;
  font-size: 12px;
}

/*
 * Form fields (CakePHP default markup -> Bootstrap-like)
 */
.content .input {
  margin-bottom: 15px;
}

.content .input > label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #334155;
}

.content .input input[type="text"],
.content .input input[type="email"],
.content .input input[type="password"],
.content .input input[type="number"],
.content .input input[type="datetime-local"],
.content .input select,
.content .input textarea {
  display: block;
  width: 100%;
  max-width: 300px;
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.42857143;
  color: #334155;
  background-color: #ffffff;
  background-image: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}

.content .input input:focus,
.content .input select:focus,
.content .input textarea:focus {
  border-color: #6366f1;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px rgba(99, 102, 241, 0.4);
  outline: 0;
}

.content .input select[multiple] {
  max-width: 300px;
}

/*
 * Tom Select (searchable multi-select)
 */
.content .input .ts-wrapper {
  max-width: 300px;
}

.content .input .ts-wrapper .ts-control {
  border-color: #cbd5e1;
  border-radius: 4px;
}

.content .input .ts-wrapper.multi .ts-control > div {
  background: #6366f1;
  color: #ffffff;
  border: 0;
  border-radius: 12px;
  padding: 3px 10px;
}

.content .input .ts-wrapper.multi .ts-control > div.active {
  background: #4f46e5;
  color: #ffffff;
}

.content .input .ts-wrapper.multi .ts-control > div .remove {
  color: #ffffff;
  border-left-color: rgba(255, 255, 255, 0.4);
}

.password-wrap {
  display: flex;
  align-items: center;
  max-width: 380px;
}

.password-wrap input {
  flex: 1;
}

.password-actions {
  white-space: nowrap;
  margin-left: 6px;
}

.content .input-group {
  max-width: 300px;
}

.content .input-group .form-control {
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
}

.content .input-group .form-control:focus {
  border-color: #6366f1;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px rgba(99, 102, 241, 0.4);
}

.content .input-group-addon {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-left: none;
  color: #64748b;
  font-size: 14px;
}

.content .input.checkbox {
  position: static;
  display: flex;
  align-items: center;
  margin-top: 0;
  margin-bottom: 15px;
}

.content .input.checkbox > label {
  margin-bottom: 0;
  padding-left: 0;
  min-height: auto;
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.content .input.checkbox input[type="checkbox"] {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
}

/*
 * Primary accent (indigo)
 */

a {
  color: #6366f1;
}
a:hover,
a:focus {
  color: #4f46e5;
}

.btn-primary {
  background-color: #6366f1;
  border-color: #6366f1;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.open > .dropdown-toggle.btn-primary {
  background-color: #4f46e5;
  border-color: #4f46e5;
}

.btn-info {
  background-color: #0ea5e9;
  border-color: #0ea5e9;
}
.btn-info:hover,
.btn-info:focus,
.btn-info:active {
  background-color: #0284c7;
  border-color: #0284c7;
}

/*
 * Tables
 */
.table > thead > tr > th {
  background-color: #eef2f7;
  border-bottom: 2px solid #d7dee8;
  color: #172033;
  font-weight: 700;
}

.content table > thead > tr > th {
  text-align: center;
  vertical-align: middle;
}

.content table > thead > tr > th a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: normal;
  line-height: 1.3;
  color: #334155;
  font-weight: 700;
  text-decoration: none;
}

.content table > thead > tr > th a:hover,
.content table > thead > tr > th a:focus {
  color: #2563eb;
  text-decoration: none;
}

/* CakePHP adds .asc/.desc to the active paginator link. */
.content table > thead > tr > th a::after {
  content: "\f0dc";
  color: #94a3b8;
  font-family: FontAwesome;
  font-size: 11px;
  font-weight: normal;
  line-height: 1;
}

.content table > thead > tr > th a.asc::after {
  content: "\f0de";
  color: #2563eb;
}

.content table > thead > tr > th a.desc::after {
  content: "\f0dd";
  color: #2563eb;
}

.content table th.actions,
.content table td.actions {
  padding-left: 12px;
  white-space: nowrap;
}

.content table td.actions {
  text-align: right;
}

.content table td.actions form:not([hidden]) {
  display: inline-block;
  margin: 0;
}

.panel-title {
  color: #1e293b;
}

/*
 * Custom
 */

footer {
  padding-top: 50px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 42px;
  padding: 14px 0 8px;
  border-top: 1px solid #d7dee8;
  color: #64748b;
  font-size: 12px;
}

@media (max-width: 600px) {
  .app-footer {
    display: block;
  }

  .app-footer span {
    display: block;
    margin-bottom: 4px;
  }
}

.content .progress-bar {
  background-color: #6366f1;
}

.progress .progress-bar.progress-safe {
  background-color: #22c55e;
}

.progress .progress-bar.progress-warning {
  background-color: #f59e0b;
}

.progress .progress-bar.progress-danger {
  background-color: #dc2626;
}

.content .input.readonly > span {
  display: block;
  padding-top: 4px;
}

.settings.index .input.checkbox {
  margin-top: 25px;
}

/* Modern 24BOX brand palette. */
.navbar-inverse {
  background-color: #172033;
  border-bottom: 2px solid #f97316;
}

.sidebar,
.login-brand {
  background-color: #172033;
}

.sidebar-domain,
.nav-sidebar > li > ul {
  background-color: #111827;
}

.nav-sidebar > li > a:hover,
.nav-sidebar > li > a:focus,
.nav-sidebar > li > ul > li > a:hover,
.nav-sidebar > li > ul > li > a:focus {
  background-color: #263449;
  border-left-color: #f97316;
}

a {
  color: #2563eb;
}

a:hover,
a:focus {
  color: #1d4ed8;
}

.btn-primary,
.content .progress-bar {
  background-color: #2563eb;
  border-color: #2563eb;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.open > .dropdown-toggle.btn-primary {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
}

.login-card {
  border-top: 3px solid #f97316;
}

/*
 * Login / auth pages
 */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 110px);
  padding: 32px 16px;
}

.login-card {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
  width: 100%;
  max-width: 440px;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  padding: 20px 28px;
  background: #1e293b;
  text-align: center;
}

.login-card-body {
  padding: 30px 36px 28px;
}

.login-card h3 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
}

.login-subtitle {
  margin: 0 0 24px;
  color: #64748b;
  font-size: 14px;
}

.login-card .input {
  display: block;
  margin-bottom: 18px;
}

.login-card .input > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-card .input input {
  display: block;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  height: 44px;
  border-radius: 6px;
  font-size: 15px;
}

.login-card .input.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-card .input.checkbox > label {
  display: inline-flex;
  align-items: center;
  width: auto;
  padding: 0;
  gap: 8px;
  margin: 0;
}

.login-card .input.checkbox input[type="checkbox"] {
  display: inline-block;
  position: static !important;
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  height: auto;
  margin: 0;
}

.login-card fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.login-card .btn-block {
  height: 44px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 6px;
  margin-top: 4px;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 0;
  font-size: 14px;
}

@media (max-width: 480px) {
  .login-page {
    align-items: flex-start;
    padding: 24px 12px;
  }

  .login-card-body {
    padding: 26px 22px 24px;
  }
}

/*
 * Flash messages
 */
div.message {
  padding: 12px 16px;
  margin-bottom: 15px;
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
}

div.message.success {
  background-color: #22c55e;
}

div.message.error {
  background-color: #dc2626;
}

div.message.info {
  background-color: #0ea5e9;
}

div.message.warning {
  background-color: #f59e0b;
}

div.message.hidden {
  display: none;
}

.chart {
  width: 100%;
  min-height: 450px;
}
