/*
 * HY Partner Center — black & gold identity.
 * This bundle loads after @/styles/tokens.css, so the :root block below re-skins
 * every shared token for this entry only (the internal admin keeps its light theme).
 * All directional rules use CSS logical properties because the app also runs RTL (Arabic).
 */

:root[data-external-admin-theme="black-gold"] {
  --bg-page: #0d0d11;
  --bg-sidebar: #101015;
  --bg-header: rgba(14, 14, 19, 0.88);
  --bg-card: #16161c;
  --bg-card-strong: #1e1e26;
  --bg-hover: rgba(214, 181, 110, 0.08);
  --bg-input: rgba(255, 255, 255, 0.035);
  --bg-input-strong: rgba(255, 255, 255, 0.07);
  --bg-flyout: rgba(24, 24, 31, 0.98);

  --border: rgba(214, 181, 110, 0.2);
  --border-soft: rgba(214, 181, 110, 0.12);
  --row-border: rgba(214, 181, 110, 0.1);
  --detail-border: rgba(214, 181, 110, 0.12);

  --primary: #d6b56e;
  --primary-strong: #e4ca8c;
  --primary-hover: rgba(214, 181, 110, 0.1);
  --primary-surface: rgba(214, 181, 110, 0.12);
  --primary-surface-strong: rgba(214, 181, 110, 0.16);
  --primary-border: rgba(214, 181, 110, 0.45);
  --primary-border-strong: rgba(214, 181, 110, 0.62);
  --primary-border-active: rgba(214, 181, 110, 0.75);
  --brand-secondary: #a8823f;
  --brand-gradient: linear-gradient(135deg, #efdcab 0%, #d6b56e 45%, #a8823f 100%);
  --brand-shadow: 0 12px 28px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(214, 181, 110, 0.28);
  --active-gradient: linear-gradient(90deg, rgba(214, 181, 110, 0.95), rgba(168, 130, 63, 0.4));
  --active-inset: inset 0 0 0 1px rgba(214, 181, 110, 0.24);

  --success: #66bd8b;
  --success-surface: rgba(102, 189, 139, 0.12);
  --success-border: rgba(102, 189, 139, 0.36);
  --success-border-strong: rgba(102, 189, 139, 0.72);
  --success-glow: rgba(102, 189, 139, 0.26);
  --warning: #d9a441;
  --warning-surface: rgba(217, 164, 65, 0.12);
  --warning-border: rgba(217, 164, 65, 0.36);
  --warning-glow: rgba(217, 164, 65, 0.26);
  --danger: #e07b6d;
  --danger-surface: rgba(224, 123, 109, 0.12);
  --danger-border: rgba(224, 123, 109, 0.34);
  --danger-border-strong: rgba(224, 123, 109, 0.72);
  --danger-glow: rgba(224, 123, 109, 0.26);
  --info: #9fb4cc;
  --info-surface: rgba(159, 180, 204, 0.12);
  --info-surface-strong: rgba(159, 180, 204, 0.18);
  --info-border: rgba(159, 180, 204, 0.34);
  --stopped: #8c8577;
  --neutral-surface: rgba(255, 255, 255, 0.05);
  --neutral-surface-strong: rgba(255, 255, 255, 0.09);
  --neutral-border: rgba(255, 255, 255, 0.14);
  --admin-tag-bg: var(--neutral-surface);
  --admin-tag-border: var(--neutral-border);
  --admin-tag-color: var(--text-secondary);

  --chart-grid: rgba(214, 181, 110, 0.12);
  --chart-tooltip-bg: #1e1e26;
  --chart-tooltip-border: rgba(214, 181, 110, 0.3);
  --chart-tooltip-text: #f0e9d8;

  --text-primary: #f0e9d8;
  --text-secondary: #b8ad92;
  --text-tertiary: #8c836d;
  --active-contrast: #1a1206;

  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-panel: 0 20px 50px rgba(0, 0, 0, 0.55);
  --shadow-dialog: 0 30px 90px rgba(0, 0, 0, 0.7);
  --shadow-drawer: 0 -18px 60px rgba(0, 0, 0, 0.6);
  --overlay-scrim: rgba(4, 4, 7, 0.66);
  --focus-ring: rgba(214, 181, 110, 0.26);
  --login-gradient: radial-gradient(120% 70% at 50% 0%, rgba(214, 181, 110, 0.12), transparent 60%);
  --skeleton-surface: rgba(255, 255, 255, 0.045);
  --skeleton-shine: rgba(214, 181, 110, 0.12);
  --skeleton-gradient: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);

  --font-display: "Didot", "Bodoni MT", "Playfair Display", Georgia, "Times New Roman", serif;
  --tabbar-height: 62px;
}

/* Bigger touch targets on handsets; 16px inputs also stop iOS Safari focus-zoom. */
@media (max-width: 899px) {
  :root[data-external-admin-theme="black-gold"] {
    --control-height: 44px;
    --control-font-size: 16px;
    --control-line-height: 22px;
    --control-padding-x: 14px;
    --admin-font-size: 15px;
    --admin-line-height: 22px;
    --radius-control: 10px;
  }
}

html,
body,
#external-admin-root {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 460px at 50% -8%, rgba(214, 181, 110, 0.08), transparent 62%),
    radial-gradient(900px 500px at 100% 110%, rgba(214, 181, 110, 0.045), transparent 55%),
    var(--bg-page);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-system);
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(214, 181, 110, 0.32);
  color: #fdf9ef;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 181, 110, 0.28) transparent;
}

/* ---------------------------------------------------------------------------
 * Login / password screens
 * ------------------------------------------------------------------------- */

.external-login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    var(--login-gradient),
    radial-gradient(700px 380px at 50% 108%, rgba(214, 181, 110, 0.07), transparent 60%),
    var(--bg-page);
}

.external-login-card {
  width: min(100%, 420px);
  border: 1px solid var(--border);
  border-radius: 20px !important;
  background:
    linear-gradient(180deg, rgba(214, 181, 110, 0.05), transparent 34%),
    var(--bg-card) !important;
  box-shadow: var(--shadow-panel);
}

.external-login-card .MuiCardContent-root {
  display: grid;
  gap: 26px;
  padding: 30px 28px 34px;
}

.external-login-title {
  font-family: var(--font-display) !important;
  font-size: 24px !important;
  letter-spacing: 0.05em;
  color: var(--primary-strong) !important;
  padding-top: 6px;
}

.external-language-switcher {
  min-width: 140px !important;
}

.external-change-password-brand {
  color: var(--primary-strong);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.external-full-state {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
}

/* ---------------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------------- */

.external-shell,
.external-main {
  min-height: 100dvh;
}

.external-main {
  background: transparent;
}

.external-header {
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-header) !important;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  color: var(--text-primary) !important;
  padding-top: env(safe-area-inset-top);
}

.external-header .MuiToolbar-root {
  min-height: 60px;
  gap: 10px;
}

.external-toolbar-spacer {
  min-height: calc(60px + env(safe-area-inset-top)) !important;
}

.external-header-title {
  font-family: var(--font-display) !important;
  font-size: 17px !important;
  letter-spacing: 0.03em;
}

.external-mobile-brand {
  max-width: min(48vw, 180px);
  color: var(--primary-strong);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.external-mobile-brand img,
.external-sidebar-brand img,
.external-change-password-brand img {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 1px rgba(214, 181, 110, 0.08), 0 8px 24px rgba(0, 0, 0, 0.38);
}

.external-user-avatar {
  width: 34px !important;
  height: 34px !important;
  font-size: 13px !important;
  background: var(--brand-gradient) !important;
  color: var(--active-contrast) !important;
  font-weight: 700;
}

/* Desktop sidebar */

.external-sidebar {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(214, 181, 110, 0.05), transparent 18%),
    var(--bg-sidebar);
}

.external-logo {
  width: 248px;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
}

.external-sidebar-brand {
  color: var(--primary-strong);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.05em;
}

.external-nav {
  padding: 12px !important;
  overflow-y: auto;
  flex: 1;
}

.external-nav .MuiListItemButton-root {
  min-height: 44px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: var(--text-secondary);
  transition: color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard);
}

.external-nav .MuiListItemButton-root:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.external-nav .MuiListItemButton-root.Mui-selected,
.external-nav .MuiListItemButton-root.Mui-selected:hover {
  background: linear-gradient(90deg, rgba(214, 181, 110, 0.16), rgba(214, 181, 110, 0.05));
  color: var(--primary-strong);
  font-weight: 700;
  box-shadow: inset 3px 0 0 0 var(--primary);
}

[dir="rtl"] .external-nav .MuiListItemButton-root.Mui-selected,
[dir="rtl"] .external-nav .MuiListItemButton-root.Mui-selected:hover {
  box-shadow: inset -3px 0 0 0 var(--primary);
}

.external-nav .MuiListItemIcon-root {
  min-width: 38px;
  color: inherit;
}

.external-sidebar-footer {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
  display: grid;
  gap: 10px;
}

/* ---------------------------------------------------------------------------
 * Mobile bottom tab bar + "more" sheet
 * ------------------------------------------------------------------------- */

.external-tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1100;
  display: none;
  align-items: stretch;
  min-height: var(--tabbar-height);
  padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--bg-header);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  border-top: 1px solid var(--border-soft);
}

.external-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 50px;
  padding: 4px 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard);
}

.external-tab .MuiSvgIcon-root {
  font-size: 22px;
}

.external-tab-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.external-tab.is-active {
  color: var(--primary-strong);
}

.external-tab.is-active .MuiSvgIcon-root {
  filter: drop-shadow(0 0 10px rgba(214, 181, 110, 0.45));
}

.external-tab:active {
  background: var(--bg-hover);
}

/* Bottom sheet (mobile navigation drawer + dialogs share the look) */

.external-sheet.MuiDrawer-paper {
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--primary-border);
  background:
    linear-gradient(180deg, rgba(214, 181, 110, 0.06), transparent 30%),
    var(--bg-card);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-drawer);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 86dvh;
}

.external-sheet-handle {
  width: 44px;
  height: 4px;
  margin: 2px auto 14px;
  border-radius: 999px;
  background: rgba(214, 181, 110, 0.35);
}

.external-sheet-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(214, 181, 110, 0.1), rgba(214, 181, 110, 0.02));
}

.external-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.external-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 76px;
  padding: 10px 4px;
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  text-decoration: none;
  transition: color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard);
}

.external-sheet-item .MuiSvgIcon-root {
  font-size: 24px;
  color: var(--primary);
}

.external-sheet-item:active,
.external-sheet-item.is-active {
  background: var(--primary-surface);
  color: var(--primary-strong);
}

.external-sheet-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Page scaffolding
 * ------------------------------------------------------------------------- */

.external-page {
  display: grid;
  gap: 20px;
  padding: 24px;
  animation: external-page-enter var(--motion-slow) var(--ease-emphasized) both;
}

.external-page > .MuiStack-root:first-child h1 {
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.external-session-card,
.external-table-container,
.external-filter-bar,
.external-form-panel,
.external-empty {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  background: var(--bg-card);
}

.external-filter-bar,
.external-form-panel {
  padding: 16px;
}

.external-filter-bar .MuiTextField-root {
  min-width: min(100%, 220px);
}

.external-table-container {
  overflow-x: auto;
}

.external-table-container .MuiTableHead-root {
  background: var(--bg-card-strong);
}

.external-table-container .MuiTableHead-root .MuiTableCell-root {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.external-table-container .MuiTableCell-root {
  white-space: nowrap;
  border-color: var(--row-border);
}

.external-table-container .MuiTableRow-hover:hover {
  background: var(--bg-hover) !important;
}

.external-empty {
  min-height: 200px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.external-skeleton {
  min-height: 50vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.external-page-number {
  min-width: 64px;
  display: grid;
  place-items: center;
}

/* Mobile record cards */

.external-mobile-card .external-mobile-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.36fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--row-border);
}

.external-mobile-card .external-mobile-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.external-mobile-card .external-mobile-row .MuiButton-root {
  min-height: 40px;
}

/* ---------------------------------------------------------------------------
 * Home (overview)
 * ------------------------------------------------------------------------- */

.external-hero {
  position: relative;
  overflow: hidden;
  padding: 22px 24px;
  border: 1px solid var(--primary-border);
  border-radius: 18px;
  background:
    radial-gradient(420px 180px at 12% -30%, rgba(214, 181, 110, 0.22), transparent 70%),
    linear-gradient(135deg, #1d1a12 0%, #14141a 55%, #101014 100%);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.external-hero-eyebrow {
  color: var(--text-tertiary) !important;
  font-size: 11px !important;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.external-hero-title {
  font-family: var(--font-display) !important;
  font-size: 26px !important;
  letter-spacing: 0.03em;
  margin: 4px 0 14px !important;
}

.external-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
}

.external-section-title {
  color: var(--text-tertiary) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.external-capability-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.external-capability-card {
  min-height: 140px;
  opacity: 0.62;
  border-color: var(--border-soft) !important;
}

.external-capability-card.is-enabled {
  opacity: 1;
}

.external-capability-card.is-enabled:hover {
  border-color: var(--primary-border) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(214, 181, 110, 0.12);
}

.external-capability-card .MuiCardActionArea-root,
.external-capability-card .MuiCardContent-root {
  height: 100%;
}

.external-capability-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(214, 181, 110, 0.35);
  background: linear-gradient(135deg, rgba(214, 181, 110, 0.16), rgba(214, 181, 110, 0.04));
  color: var(--primary-strong);
}

.external-capability-card:not(.is-enabled) .external-capability-icon {
  border-color: var(--neutral-border);
  background: var(--neutral-surface);
  color: var(--text-tertiary);
}

/* ---------------------------------------------------------------------------
 * Dialogs, inputs, misc chrome
 * ------------------------------------------------------------------------- */

.external-dialog-fields {
  padding-top: 8px;
}

.MuiDialog-paper {
  border: 1px solid var(--border);
  background-image: linear-gradient(180deg, rgba(214, 181, 110, 0.05), transparent 26%) !important;
  box-shadow: var(--shadow-dialog) !important;
}

.MuiBackdrop-root {
  background-color: var(--overlay-scrim) !important;
  backdrop-filter: blur(3px);
}

.MuiButton-containedPrimary:not(.Mui-disabled) {
  background-image: var(--brand-gradient);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 18px rgba(0, 0, 0, 0.4);
}

.MuiButton-containedPrimary:not(.Mui-disabled):hover {
  background-image: linear-gradient(135deg, #f5e6bd 0%, #e0c079 45%, #b28a45 100%);
}

.external-image-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 12px;
  border: 1px dashed var(--primary-border);
  border-radius: var(--radius-control);
  background: rgba(214, 181, 110, 0.03);
}

.external-image-field img,
.external-image-placeholder {
  width: 104px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-card-strong);
}

.external-banner-thumb {
  width: 88px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-card-strong);
}

.external-image-placeholder {
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  font-size: 12px;
}

@keyframes external-page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------------------- */

@media (max-width: 1199px) {
  .external-capability-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  .external-tabbar { display: flex; }
  .external-page {
    padding: 16px 16px calc(var(--tabbar-height) + 24px + env(safe-area-inset-bottom));
  }
  /* The fixed top bar already names the page on handsets; the in-page h1 would repeat it. */
  .external-page > .MuiStack-root:first-child h1 { display: none; }
  .external-capability-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .external-filter-bar .MuiTextField-root { width: 100%; }
  .external-filter-bar .MuiButton-root { min-height: var(--control-height); }
  .external-hero { padding: 20px; }
  .external-hero-title { font-size: 23px !important; }
}

@media (max-width: 599px) {
  .external-login-card .MuiCardContent-root { padding: 26px 20px 30px; }
  .external-page { gap: 14px; padding-inline: 14px; }
  .external-capability-grid { gap: 10px; }
  .external-capability-card { min-height: 118px; }
  .external-image-field { align-items: flex-start; flex-direction: column; }
  .external-header .external-language-switcher { min-width: 94px !important; max-width: 112px; }
  .external-hero-meta { gap: 8px 20px; }

  /* Every dialog becomes an app-style bottom sheet on handsets. */
  .MuiDialog-container {
    align-items: flex-end !important;
  }
  .MuiDialog-paper:not(.MuiDialog-paperFullScreen) {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90dvh !important;
    border-radius: 22px 22px 0 0 !important;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .MuiDialog-paper:not(.MuiDialog-paperFullScreen)::before {
    content: "";
    display: block;
    width: 44px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: rgba(214, 181, 110, 0.35);
  }
  .MuiDialogActions-root {
    padding: 12px 16px 16px !important;
  }
  .MuiDialogActions-root .MuiButton-root {
    min-height: 44px;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
