/*
 * Application additions to mexports-theme.css.
 *
 * The theme file stays untouched so it can be replaced wholesale when the
 * design is revised; anything the application needs on top lives here.
 */

/* Sign-in and error pages: Modern deep slate-crimson gradient background */
.mge-bare-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: radial-gradient(circle at top right, #1e1b4b 0%, #0f172a 45%, #020617 100%);
  position: relative;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.mge-bare-main::before {
  content: '';
  position: absolute;
  top: -10%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(220, 38, 38, 0.15) 0%, rgba(220, 38, 38, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.mge-bare-main::after {
  content: '';
  position: absolute;
  bottom: -10%;
  left: -10%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, rgba(37, 99, 235, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* A message the shell puts above the card */
.mge-bare-main > .alert {
  width: 100%;
  max-width: 440px;
  margin-bottom: 20px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 10;
}

/* Modern Login Card */
.mge-login-wrapper {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
}

.mge-login-card-modern {
  background: #ffffff;
  border-radius: 20px;
  padding: 38px 34px 28px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(226, 232, 240, 0.8);
  width: 100%;
  box-sizing: border-box;
  max-width: 440px;
}

/* Mobile Screens (Phones) */
@media (max-width: 576px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative;
  }
  .mge-bare-main {
    padding: 20px 14px !important;
    justify-content: flex-start !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
  }
  .mge-bare-main > .alert {
    max-width: 100% !important;
    margin-bottom: 14px !important;
  }
  .mge-login-wrapper,
  .mge-login-card-modern {
    padding: 24px 18px 22px !important;
    border-radius: 18px !important;
    max-width: 100% !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  .mge-login-card-modern input.form-control,
  .mge-login-card-modern .form-control {
    font-size: 16px !important; /* Prevents iOS Safari auto-zooming */
  }
}

@keyframes mgePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.mge-login-header {
  text-align: center;
  margin-bottom: 26px;
}

.mge-login-brand-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  border: 1px solid #E2E8F0;
}

.mge-login-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.mge-login-title {
  font-family: var(--mge-font-heading);
  font-weight: 800;
  font-size: 22px;
  color: #0F172A;
  letter-spacing: -0.03em;
}

.mge-login-subtitle {
  font-size: 12.5px;
  color: #64748B;
  margin-bottom: 0;
}

.mge-input-group-modern {
  border-radius: 10px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  transition: all 0.2s ease;
}

.mge-input-group-modern:focus-within {
  border-color: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
  background: #FFFFFF;
}

.mge-input-group-modern .form-control {
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 12px;
}

.mge-input-group-modern .form-control:focus {
  box-shadow: none;
}

.mge-btn-login {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-family: var(--mge-font-heading);
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mge-btn-login:hover {
  background: linear-gradient(135deg, #B91C1C 0%, #991B1B 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
  color: #ffffff;
}

/* Feature Tool Tiles (App Launcher Style) */
.mge-tool-tile {
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  min-height: 180px;
  position: relative;
}

.mge-tool-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -4px rgba(15, 23, 42, 0.1), 0 4px 12px -2px rgba(15, 23, 42, 0.04) !important;
  border-color: #CBD5E1 !important;
}

.mge-tool-tile:hover .mge-tool-icon {
  transform: scale(1.06);
}

.mge-tool-icon {
  transition: transform 0.22s ease;
}

.mge-tool-tile:hover .mge-tool-title {
  color: #DC2626 !important;
}

.mge-tool-tile:hover .mge-tool-arrow {
  transform: translateX(3px);
}

.mge-tool-arrow {
  transition: transform 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-purple {
  color: #7C3AED !important;
}

.mge-btn-pill {
  border-radius: 999px !important;
}

.shadow-xs {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}


/* -------------------------------------------------------------------------
 * Modern Permission Matrix Suite
 * ---------------------------------------------------------------------- */
.perm-row {
  display: flex;
  gap: 16px;
  padding: 12px 14px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  align-items: center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.perm-row:hover {
  background-color: #F1F5F9;
  border-color: #CBD5E1;
}

.perm-entity {
  flex: 0 0 160px;
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
}

.perm-ops {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.perm-op-tile {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 6px 12px;
  margin: 0;
  transition: all 0.15s ease;
  min-width: 140px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.perm-op-tile:hover {
  background-color: #FEF2F2;
  border-color: #FECACA;
  transform: translateY(-1px);
}

.perm-op-tile input[type="checkbox"]:checked ~ span {
  color: #DC2626;
  font-weight: 600;
}

/* Floating Glassmorphic Save Bar */
.perm-savebar {
  position: sticky;
  bottom: 20px;
  z-index: 1050;
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid #CBD5E1;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}


/* post_action() renders mutations as one-button forms; the button has to sit
   in a table row exactly where the old anchor sat. */
form.d-inline { display: inline; margin: 0; }

button.table-action-btn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}


/* -------------------------------------------------------------------------
 * The pipeline board.
 *
 * Columns scroll sideways and each column scrolls down on its own, so a long
 * stage never pushes the board's own header off the screen. Cards are sized
 * for glancing at, not reading: title, who it is, what it is worth.
 * ---------------------------------------------------------------------- */
.crm-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  align-items: flex-start;
}

.crm-column {
  flex: 0 0 264px;
  background: var(--mge-surface-2, #F8FAFC);
  border: 1px solid var(--mge-border, #E2E8F0);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

.crm-column.is-won  { border-top: 3px solid #16A34A; }
.crm-column.is-lost { border-top: 3px solid #94A3B8; }

.crm-column-head {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--mge-border, #E2E8F0);
}

.crm-column-title {
  font-size: 12.5px;
  font-weight: 700;
}

.crm-column-meta {
  font-size: 10.5px;
  color: var(--mge-muted, #64748B);
  margin-top: 1px;
}

.crm-column-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 90px;
}

.crm-column-body.is-over {
  background: rgba(220, 38, 38, 0.05);
  outline: 2px dashed var(--mge-primary, #DC2626);
  outline-offset: -6px;
  border-radius: 8px;
}

.crm-column-empty {
  font-size: 11px;
  color: var(--mge-muted, #94A3B8);
  text-align: center;
  padding: 14px 0;
}

.crm-card {
  background: #fff;
  border: 1px solid var(--mge-border, #E2E8F0);
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.crm-card:hover {
  border-color: var(--mge-primary-light, #F87171);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.09);
}

.crm-card.is-dragging { opacity: .45; }

.crm-card-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

.crm-card-sub {
  font-size: 11px;
  color: var(--mge-muted, #64748B);
  margin-top: 2px;
}

.crm-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.crm-card-value {
  font-size: 11px;
  font-weight: 700;
}

.crm-card-chip {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--mge-surface-2, #F1F5F9);
  color: var(--mge-muted, #64748B);
}

.crm-card-chip.is-late {
  background: #FEE2E2;
  color: #B91C1C;
  font-weight: 600;
}

.crm-card-owner {
  margin-left: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--mge-primary, #DC2626);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* -------------------------------------------------------------------------
 * The chatter: what has been said about a record, newest first.
 * ---------------------------------------------------------------------- */
.crm-chatter-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--mge-border, #E2E8F0);
}

.crm-chatter-item:first-child { border-top: 0; }

.crm-chatter-icon {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--mge-surface-2, #F1F5F9);
  color: var(--mge-muted, #64748B);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.crm-chatter-item.is-system .crm-chatter-icon {
  background: transparent;
  color: var(--mge-muted, #94A3B8);
}

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

.crm-chatter-meta {
  font-size: 10.5px;
  color: var(--mge-muted, #64748B);
}

.crm-chatter-text {
  font-size: 12.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.crm-chatter-item.is-system .crm-chatter-text {
  font-size: 11.5px;
  color: var(--mge-muted, #64748B);
  font-style: italic;
}

/* An activity that is late has to be visible without being read. */
.crm-activity.is-late {
  border-left: 3px solid #DC2626;
  padding-left: 8px;
}

.crm-activity.is-done { opacity: .55; }

/* Ensure badge-status never wraps text */
.badge-status {
  white-space: nowrap !important;
}

/* Subnav pills for tabs within pages like Activity Log */
.mge-subnav-pills .nav-link {
  color: var(--mge-slate, #475569);
  background: #ffffff;
  border: 1px solid var(--mge-border, #E2E8F0);
  border-radius: var(--mge-radius, 8px);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  transition: all 0.2s ease;
}

.mge-subnav-pills .nav-link:hover {
  background: #F8FAFC;
  color: var(--mge-primary, #AC3D3C);
  border-color: #CBD5E1;
}

.mge-subnav-pills .nav-link.active {
  background: var(--mge-primary, #AC3D3C);
  color: #ffffff;
  border-color: var(--mge-primary, #AC3D3C);
  box-shadow: 0 2px 8px rgba(172, 61, 60, 0.25);
}

.mge-subnav-pills .nav-link.active .badge {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

.shadow-xs { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.shadow-2xs { box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03); }

/* Settings Page Info Tooltip & Row Spacing */
.mge-info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--mge-muted, #94A3B8);
  font-size: 13.5px;
  cursor: pointer;
  margin-left: 6px;
  transition: color 0.15s ease, transform 0.15s ease;
  vertical-align: middle;
}

.mge-info-tip:hover {
  color: var(--mge-primary, #AC3D3C);
  transform: scale(1.15);
}

.mge-setting-row {
  padding: 13px 0;
  border-bottom: 1px solid var(--mge-border, #F1F5F9);
}

.mge-setting-row:first-child {
  padding-top: 4px;
}

.mge-setting-row:last-child {
  border-bottom: 0;
  padding-bottom: 4px;
}
