/* PAC.CO Studio 2026 — Email presentation layer.
   Existing Email IDs, handlers, content blocks, recipients, and persistence stay unchanged. */

body:has(#page-email.active) .ds-content {
  padding: 12px !important;
  overflow: hidden !important;
}

#page-email.active {
  width: 100% !important;
  max-width: none !important;
  height: calc(100vh - var(--topbar-h) - 24px) !important;
  min-height: 0 !important;
  margin: 0 !important;
  gap: 12px !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

#page-email .ds-widget-action-bar {
  flex: 0 0 auto;
  min-height: 72px;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: nowrap !important;
  gap: 0 !important;
  padding: 14px 16px !important;
  border: 1px solid #d2dae2 !important;
  border-radius: 9px !important;
  background: #fff !important;
  box-sizing: border-box;
}

#page-email .ds-widget-action-bar::before,
#page-email .ds-widget-action-bar::after {
  display: none !important;
  content: none !important;
}

#page-email .ds-widget-action-bar > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

#page-email .ds-widget-action-bar > div:first-child h2 {
  color: #1e2d3d;
  font-size: 0 !important;
  letter-spacing: -.025em;
}

#page-email .ds-widget-action-bar > div:first-child h2::after {
  content: 'Email' !important;
  font-size: 1.25rem;
}

#page-email .ds-widget-action-bar > div:first-child p {
  margin-top: 4px !important;
  color: #667384 !important;
  font-size: .78rem !important;
  font-weight: 600;
}

#page-email .email-workspace-panel {
  min-height: 0;
  flex: 1 1 auto;
  display: flex !important;
  flex-direction: column;
  padding: 0 !important;
  border: 1px solid #d2dae2 !important;
  border-radius: 9px !important;
  background: #fff !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

#page-email .email-workspace-panel > .slide-tab-bar {
  min-height: 48px;
  flex: 0 0 48px;
  display: flex;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid #d2dae2;
  background: #f8fafc;
  overflow-x: auto;
  scrollbar-width: none;
}

#page-email .email-workspace-panel > .slide-tab-bar::-webkit-scrollbar {
  display: none;
}

#page-email .email-workspace-panel > .slide-tab-bar .slide-tab {
  flex: 0 0 170px;
  min-width: 124px;
  min-height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #738196;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .01em;
  white-space: nowrap;
}

#page-email .email-workspace-panel > .slide-tab-bar .slide-tab:hover {
  color: #294a66;
  background: #eef3f7;
}

#page-email .email-workspace-panel > .slide-tab-bar .slide-tab.active {
  border-bottom-color: #466b88;
  color: #294a66;
  background: #e8eff5;
}

#page-email .email-tab-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px !important;
  background: #f8fafc;
}

#page-email .email-tab-panel.active {
  display: block !important;
  min-width: 0;
}

/* Compose tab: editor left, recipient inspector right. */
#page-email .email-compose-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

#page-email .email-compose-panel,
#page-email .email-send-panel {
  min-width: 0;
  border: 1px solid #d2dae2 !important;
  border-radius: 9px !important;
  background: #fff !important;
  box-sizing: border-box;
}

#page-email .email-compose-panel {
  display: flex;
  flex-direction: column;
  padding: 16px !important;
}

#page-email .email-send-panel {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  padding: 16px !important;
}

#page-email .email-compose-panel > h3,
#page-email .email-send-panel > h3,
#page-email #email-tab-notifications h3 {
  color: #2b4055;
}

#page-email .email-field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 12px;
}

#page-email .email-label,
#page-email .ds-field-label {
  color: #728093 !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: .07em;
  text-transform: uppercase;
}

#page-email .email-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
}

#page-email .email-label small {
  color: #8090a0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

#page-email .email-input,
#page-email .email-select,
#page-email .ds-widget-field {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cbd5df !important;
  border-radius: 7px !important;
  color: #24384c;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  box-sizing: border-box;
  box-shadow: none !important;
}

#page-email .email-input:focus,
#page-email .email-select:focus,
#page-email .ds-widget-field:focus {
  border-color: #8095a8 !important;
  outline: 2px solid rgba(96, 129, 157, .16);
}

#page-email .email-message-section {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

#page-email .email-editor {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 340px;
  border: 1px solid #cbd5df !important;
  border-radius: 7px !important;
  background: #fff;
  overflow: hidden;
}

/* Keep the editor and its action fields in normal document flow at short desktop heights. */
@media (min-width: 821px) {
  body:has(#page-email.active) .ds-content {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  #page-email.active {
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
  }

  #page-email .email-workspace-panel,
  #page-email .email-tab-body,
  #page-email .email-tab-panel.active,
  #page-email .email-compose-grid {
    flex: 0 0 auto !important;
  }

  #page-email .email-workspace-panel,
  #page-email .email-tab-body {
    overflow: visible !important;
  }

  #page-email .email-message-section {
    flex: 0 0 auto !important;
  }

  #page-email .email-message-section .email-editor {
    flex: 0 0 auto !important;
    min-height: clamp(220px, 42vh, 380px) !important;
  }

  #page-email .email-action-fields {
    margin-top: 12px !important;
  }
}

#page-email .email-editor-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 9px;
  border-bottom: 1px solid #dbe3ea;
  background: #f8fafc;
}

#page-email .email-editor-tools button {
  width: auto;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid #cbd5df !important;
  border-radius: 5px !important;
  color: #31485e;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
}

#page-email .email-editor-tools button:hover,
#page-email .email-editor-tools button:focus-visible {
  border-color: #111 !important;
  color: #111;
  background: #eef3f7;
  outline: none;
}

#page-email .email-editor-content {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding: 12px;
  color: #24384c;
  font-size: 13px;
  line-height: 1.55;
  overflow: auto;
}

#page-email .email-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #dbe3ea;
  color: #718096;
  font-size: 10px;
}

#page-email .email-merge-btn {
  border: 0;
  color: #405266;
  background: transparent;
  font: inherit;
  font-weight: 800;
}

#page-email .email-choice-list {
  border: 1px solid #d3dee7;
  border-radius: 8px;
  overflow: hidden;
}

#page-email .email-choice {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 62px;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-bottom: 1px solid #dbe3ea;
  color: #24384c;
  background: #fff;
  text-align: left;
  box-sizing: border-box;
}

#page-email .email-choice:last-child {
  border-bottom: 0;
}

#page-email .email-choice:hover,
#page-email .email-choice.is-selected {
  background: #e8eff5;
}

#page-email .email-choice-radio {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid #9aa9b8;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
}

#page-email .email-choice.is-selected .email-choice-radio {
  border-color: #111;
  background: #111;
}

#page-email .email-choice-copy {
  min-width: 0;
  flex: 1;
}

#page-email .email-choice-copy strong,
#page-email .email-choice-copy span {
  display: block;
}

#page-email .email-choice-copy strong {
  color: #2b4055;
  font-size: 12px;
}

#page-email .email-choice-copy span {
  margin-top: 3px;
  color: #8090a0;
  font-size: 10px;
}

#page-email .email-choice-chevron {
  color: #466b88;
  font-size: 20px;
  line-height: 1;
}

#page-email .email-summary {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d3dee7;
  border-radius: 8px;
  background: #f8fafc;
}

#page-email .email-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  color: #344c63;
  font-size: 11px;
}

#page-email .email-summary-row span {
  color: #8090a0;
}

#page-email .email-compose-notice {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #cbdceb;
  border-radius: 7px;
  color: #49657d;
  background: #f2f6fa;
  font-size: 10px;
  line-height: 1.45;
}

#page-email .email-compose-notice[data-tone="warning"] {
  border-color: #f2d1d1;
  color: #8b2c2c;
  background: #fff7f7;
}

#page-email .email-send-btn,
#page-email #emailCardService .ds-btn-primary,
#page-email #emailCardTest .ds-btn-primary {
  min-height: 40px;
  border: 1px solid #111 !important;
  border-radius: 7px !important;
  color: #fff !important;
  background: #111 !important;
  font-size: 11px;
  font-weight: 800;
}

#page-email .email-send-btn:disabled {
  border-color: #9aa0a6 !important;
  color: #fff !important;
  background: #9aa0a6 !important;
}

#page-email .email-send-note {
  margin: 9px 0 0;
  color: #8090a0;
  text-align: center;
  font-size: 10px;
  line-height: 1.45;
}

/* Notifications tab: compact settings cards in a 2-column desktop grid. */
#page-email #email-tab-notifications.active {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

#page-email #email-tab-notifications > .ds-panel {
  min-width: 0;
  margin: 0 !important;
  padding: 14px !important;
  border: 1px solid #d2dae2 !important;
  border-radius: 9px !important;
  background: #fff !important;
  box-sizing: border-box;
}

#page-email #emailCardService,
#page-email #emailCardTest {
  grid-column: 1 / -1;
}

#page-email #emailCardService > div:first-child {
  margin-bottom: 12px !important;
}

#page-email #emailCardService > div:first-child > div:last-child {
  margin-left: auto;
}

#page-email #emailCardService #emailStatusInfo {
  margin-bottom: 10px !important;
}

#page-email #emailCardService #emailStatusInfo > div {
  gap: 5px 12px !important;
  color: #405266;
  font-size: 12px !important;
  line-height: 1.55 !important;
}

#page-email #emailCardService .email-service-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
  margin-top: 12px !important;
}

#page-email #emailCardCustomer > div[style*="border-bottom"],
#page-email #emailCardAdmin > div[style*="border-bottom"] {
  padding: 10px 0 !important;
  border-bottom-color: #dbe3ea !important;
}

#page-email #emailCardCustomer .ds-seg-toggle,
#page-email #emailCardAdmin .ds-seg-toggle,
#page-email #emailCardService .ds-seg-toggle {
  flex: 0 0 74px;
}

#page-email .ds-seg-toggle {
  width: 74px;
  height: 28px;
  border: 1px solid #c4d0db;
  border-radius: 7px;
  background: #eef2f5;
  overflow: hidden;
}

#page-email .ds-seg-toggle-btn {
  min-width: 0;
  border: 0;
  color: #697889;
  background: transparent;
  font-size: 9px;
  font-weight: 800;
}

#page-email .ds-seg-toggle-btn.active {
  color: #fff;
  background: #111;
}

#page-email .ds-seg-toggle-btn.active:hover {
  color: #fff;
  background: #000;
}

#page-email #emailCardTest > div {
  align-items: flex-end;
}

#page-email #emailCardTest p {
  color: #8090a0 !important;
}

@media (max-width: 1100px) and (min-width: 821px) {
  #page-email .email-compose-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

@media (max-width: 820px) {
  body:has(#page-email.active) .ds-content {
    padding: 8px 10px calc(76px + env(safe-area-inset-bottom)) !important;
    overflow-y: auto !important;
  }

  #page-email.active {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    gap: 10px !important;
  }

  #page-email .ds-widget-action-bar {
    min-height: 58px;
    padding: 11px 12px !important;
  }

  #page-email .ds-widget-action-bar > div:first-child h2 {
    font-size: 0 !important;
  }

  #page-email .ds-widget-action-bar > div:first-child h2::after {
    font-size: 1rem;
  }

  #page-email .ds-widget-action-bar > div:first-child p {
    margin-top: 3px !important;
    font-size: .7rem !important;
    line-height: 1.35;
  }

  #page-email .email-workspace-panel {
    overflow: visible !important;
  }

  #page-email .email-workspace-panel > .slide-tab-bar {
    min-height: 44px;
    flex-basis: 44px;
    padding: 0 5px;
    border-radius: 8px 8px 0 0;
  }

  #page-email .email-workspace-panel > .slide-tab-bar .slide-tab {
    min-height: 44px;
    min-width: 112px;
    padding: 0 9px;
  }

  #page-email .email-tab-body {
    overflow: visible;
    padding: 10px !important;
  }

  #page-email .email-tab-panel.active {
    display: block !important;
  }

  #page-email .email-compose-grid {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }

  #page-email .email-compose-panel,
  #page-email .email-send-panel {
    padding: 12px !important;
  }

  #page-email .email-send-panel {
    position: static !important;
  }

  #page-email .email-field-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #page-email .email-editor {
    min-height: 230px;
  }

  #page-email #email-tab-notifications.active {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }

  #page-email #emailCardService,
  #page-email #emailCardTest {
    grid-column: auto;
  }

  #page-email #emailCardService .email-service-grid {
    grid-template-columns: 1fr !important;
  }

  #page-email #emailCardTest > div {
    align-items: stretch;
  }

  #page-email #emailCardTest #emailSendTestNotifBtn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  #page-email .email-workspace-panel > .slide-tab-bar .slide-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 4px;
    font-size: 10px;
  }

  #page-email .email-editor-tools {
    flex-wrap: wrap;
  }
}

/* Final desktop overrides: let the page end with its content instead of
   stretching an empty workspace below the composer. */
@media (min-width: 821px) {
  body:has(#page-email.active) #page-email.active {
    height: calc(100vh - var(--topbar-h) - 24px) !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow: visible !important;
  }

  body:has(#page-email.active) #page-email.active .email-workspace-panel {
    height: auto !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow: visible !important;
  }

  body:has(#page-email.active) #page-email.active .email-tab-body {
    height: auto !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body:has(#page-email.active) #page-email.active #email-tab-compose.active {
    display: flex !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    flex-direction: column;
  }

  body:has(#page-email.active) #page-email.active .email-compose-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    align-items: stretch !important;
    grid-template-columns: minmax(0, 1.7fr) minmax(360px, .8fr) !important;
  }

  body:has(#page-email.active) #page-email.active .email-compose-panel,
  body:has(#page-email.active) #page-email.active .email-send-panel {
    align-self: stretch !important;
    min-height: 0 !important;
  }

  body:has(#page-email.active) #page-email.active .email-compose-panel {
    display: flex !important;
    flex-direction: column !important;
  }

  body:has(#page-email.active) #page-email.active .email-message-section {
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }

  body:has(#page-email.active) #page-email.active .email-message-section .email-editor {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 340px !important;
    max-height: none !important;
  }

  body:has(#page-email.active) #page-email.active .email-action-fields {
    flex: 0 0 auto !important;
    margin-top: 12px !important;
  }
}

/* Shared outline icon treatment for the Email header. */
body:has(#page-email.active) #page-email.active .ds-widget-action-bar::before {
  display: grid !important;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  margin-right: 12px;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  background-color: #f8fafc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m4 7 8 6 8-6'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 18px 18px;
  content: '' !important;
  line-height: 1;
}

/* Notification rows use consistent line icons instead of platform emoji. */
#page-email .email-notification-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 18px 18px;
}

#page-email .email-notification-icon[data-notification-icon="emailNotifOrderConfirm"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='m8 12 2.5 2.5L16 9'/%3E%3C/svg%3E");
}

#page-email .email-notification-icon[data-notification-icon="emailNotifShippingUpdate"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 7 9-4 9 4-9 4-9-4Z'/%3E%3Cpath d='m3 12 9 4 9-4M3 17l9 4 9-4'/%3E%3C/svg%3E");
}

#page-email .email-notification-icon[data-notification-icon="emailNotifPaymentConfirmed"],
#page-email .email-notification-icon[data-notification-icon="emailAdminPaymentReceived"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3 10h18M7 15h3'/%3E%3C/svg%3E");
}

#page-email .email-notification-icon[data-notification-icon="emailNotifRefunded"],
#page-email .email-notification-icon[data-notification-icon="emailAdminRefundIssued"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7h10v4'/%3E%3Cpath d='m17 11 3-3-3-3'/%3E%3Cpath d='M17 17H7v-4'/%3E%3Cpath d='m7 13-3 3 3 3'/%3E%3C/svg%3E");
}

#page-email .email-notification-icon[data-notification-icon="emailAdminNewOrder"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h2l2 11h10l2-8H6'/%3E%3Ccircle cx='9' cy='20' r='1'/%3E%3Ccircle cx='17' cy='20' r='1'/%3E%3C/svg%3E");
}

#page-email .email-notification-icon[data-notification-icon="emailAdminFailedPayment"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 9 17H3L12 3Z'/%3E%3Cpath d='M12 9v5M12 17h.01'/%3E%3C/svg%3E");
}

#page-email .email-notification-icon[data-notification-icon="emailAdminEmailDeliveryFailed"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23294a66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m4 7 8 6 8-6M16 16l4-4M20 16l-4-4'/%3E%3C/svg%3E");
}
