/*
  Portal Unified Layer
  --------------------
  This is the final, intentional presentation layer loaded after the older portal CSS.
  Older files are kept for compatibility. New design decisions belong here or in Portal Studio settings.
*/

:root{
  --ah-card-radius:var(--portal-radius-card,10px);
  --ah-card-pad:var(--portal-card-padding,22px);
  --ah-card-gap:var(--portal-card-gap,18px);
  --ah-card-shadow:var(--portal-card-shadow,0 1px 2px rgba(16,37,45,.035),0 12px 28px rgba(16,37,45,.055));
  --ah-card-border:var(--portal-card-border-width,1px) solid var(--portal-line,#cfe0e5);
  --ah-card-img-h:var(--portal-card-image-height,175px);
  --ah-card-img-fit:var(--portal-card-image-fit,cover);
  --ah-section-gap:var(--portal-section-gap,24px);
}

*{box-sizing:border-box}
body{background:var(--portal-bg,var(--bg,#f6f9fa));color:var(--portal-ink,var(--ink,#10252d));}

/* Main menu should be driven by the portal categories, not one-off hardcoded tool links. */
.sidebar .nav a,.mobile-nav a{min-height:42px;align-items:center;border-radius:10px;}
.sidebar .nav a.active,.mobile-nav a.active{background:rgba(72,155,173,.14);color:#fff;border-color:rgba(255,255,255,.14)}
.sidebar .nav a .nav-label,.mobile-nav a .nav-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}

/* Shared cards */
.hub-nav-card,
.hub-product-card,
.toolhub-card,
.product-card,
.portal-module-panel,
.portal-module-card,
.panel,
.admin-card,
.admin-list-item,
.ps-card,
.notice,
.empty-state{
  border:var(--ah-card-border);
  border-radius:var(--ah-card-radius);
  background:var(--portal-panel,#fff);
  box-shadow:var(--ah-card-shadow);
}

.hub-nav-card,.hub-product-card,.toolhub-card{position:relative;overflow:hidden;}
.hub-nav-content,.toolhub-copy,.hub-product-card .body{padding:var(--ah-card-pad);}
.hub-nav-title,.toolhub-title,.hub-product-card h3{font-size:19px;line-height:1.2;font-weight:760;letter-spacing:-.01em;margin:0;color:var(--portal-ink,#10252d);}
.hub-nav-desc,.toolhub-desc,.hub-product-card p{font-size:15px;line-height:1.5;color:var(--portal-muted,#536870);margin:0;}
.hub-product-actions,.toolhub-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:auto;}
.hub-nav-button,.btn,.primary-button,.secondary-button,.dl-vote,.muted-action{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:var(--portal-radius-button,8px);font-weight:var(--portal-button-weight,700);line-height:1.1;text-decoration:none;}
.hub-nav-button,.btn.primary,.primary-button{background:var(--portal-primary,var(--primary,#489BAD));border-color:var(--portal-primary,var(--primary,#489BAD));color:#fff;}
.muted-action{border:1px solid var(--portal-line,#cfe0e5);background:#fff;color:var(--portal-muted,#536870);padding:10px 14px;}

/* Dashboard top-level tiles */
.dashboard-main-tiles.hub-card-grid,
.hub-home:not(.section-hub-page) > .hub-explore-section > .hub-card-grid[data-home-nav]{
  display:grid!important;
  grid-template-columns:repeat(var(--portal-dashboard-desktop-columns,3),minmax(0,1fr))!important;
  gap:var(--ah-card-gap)!important;
  align-items:stretch!important;
}
.dashboard-main-tile,
.hub-home:not(.section-hub-page) [data-home-nav] > .hub-nav-card{
  display:flex!important;
  flex-direction:column!important;
  height:100%!important;
  padding:0!important;
}
.hub-home:not(.section-hub-page) [data-home-nav] .hub-nav-media{
  display:block;width:100%;height:var(--ah-card-img-h);min-height:var(--ah-card-img-h);border-bottom:1px solid var(--portal-line,#cfe0e5);overflow:hidden;
}
.hub-home:not(.section-hub-page) [data-home-nav] .hub-nav-media img{width:100%;height:100%;object-fit:var(--ah-card-img-fit);display:block;}
.hub-home:not(.section-hub-page) [data-home-nav] .hub-nav-content{display:flex;flex-direction:column;gap:10px;flex:1;}

/* Category/hub pages. The page data attributes decide the layout. */
.ah-category-page .hub-card-grid{display:grid;grid-template-columns:repeat(var(--hub-columns,3),minmax(0,1fr));gap:var(--ah-card-gap)!important;}
.ah-category-page[data-page-layout="list"] .hub-card-grid,
.ah-category-page[data-card-style="wide"] .hub-card-grid{grid-template-columns:1fr!important;}
.ah-category-page[data-page-layout="compact"] .hub-card-grid{gap:max(10px, calc(var(--ah-card-gap) - 6px))!important;}
.ah-category-page[data-page-layout="dashboard"] .dl-subgroup{border:var(--ah-card-border);border-radius:var(--ah-card-radius);background:var(--portal-panel,#fff);box-shadow:var(--ah-card-shadow);padding:18px;margin-bottom:var(--ah-section-gap);}
.ah-category-page[data-card-style="image_top"] .hub-nav-card{display:flex;flex-direction:column;padding:0;}
.ah-category-page[data-card-style="image_top"] .hub-nav-media{height:var(--ah-card-img-h);min-height:var(--ah-card-img-h);border-bottom:1px solid var(--portal-line,#cfe0e5);}
.ah-category-page[data-card-style="image_side"] .hub-nav-card,
.ah-category-page[data-card-style="compact"] .hub-nav-card,
.ah-category-page[data-card-style="wide"] .hub-nav-card{display:grid;grid-template-columns:clamp(150px,22vw,260px) minmax(0,1fr);align-items:stretch;padding:0;}
.ah-category-page[data-card-style="compact"] .hub-nav-card{grid-template-columns:96px minmax(0,1fr);}
.ah-category-page[data-card-style="image_side"] .hub-nav-media,
.ah-category-page[data-card-style="compact"] .hub-nav-media,
.ah-category-page[data-card-style="wide"] .hub-nav-media{height:100%;min-height:150px;border-right:1px solid var(--portal-line,#cfe0e5);}
.ah-category-page[data-card-style="compact"] .hub-nav-media{min-height:96px;}
.ah-category-page[data-card-style="text_only"] .hub-nav-media,
.ah-category-page[data-card-style="minimal"] .hub-nav-media{display:none!important;}
.ah-category-page[data-card-style="text_only"] .hub-nav-card,
.ah-category-page[data-card-style="minimal"] .hub-nav-card{display:block;padding:0;}
.ah-category-page .hub-nav-media img{display:block;width:100%;height:100%;object-fit:var(--ah-card-img-fit);object-position:center;}
.ah-category-page[data-image-mode="none"] .hub-nav-media{display:none!important;}
.ah-category-page[data-image-mode="square"] .hub-nav-media{aspect-ratio:1/1;height:auto;min-height:0;}
.ah-category-page[data-image-mode="portrait"] .hub-nav-media{aspect-ratio:3/4;height:auto;min-height:0;}
.ah-category-page[data-image-mode="circle"] .hub-nav-media{width:132px;height:132px;min-height:132px;border-radius:999px;margin:18px auto 0;border:1px solid var(--portal-line,#cfe0e5);}
.ah-category-page .dl-subgroup + .dl-subgroup{margin-top:var(--ah-section-gap);}
.ah-category-page .hub-section-head{display:flex;align-items:flex-end;justify-content:space-between;gap:14px;margin:0 0 14px;}

/* Favorite/star placement across cards */
.dl-fav-form{position:absolute;top:12px;right:12px;z-index:5;margin:0!important;}
.dl-fav{width:36px;height:36px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:rgba(255,255,255,.92);border:1px solid var(--portal-line,#cfe0e5);box-shadow:0 6px 18px rgba(16,37,45,.12);}

/* Modules should inherit the portal shell by default. */
.portal-module-page{max-width:var(--portal-page-width,1180px);margin:0 auto;display:grid;gap:var(--ah-section-gap);}
.portal-module-hero{margin-bottom:0;}
.portal-module-hero h1{font-size:var(--portal-h1-size,34px);line-height:1.12;margin:0 0 8px;}
.portal-module-kicker{text-transform:uppercase;letter-spacing:.08em;font-size:12px;font-weight:800;color:var(--portal-primary-dark,#347f8d);margin:0 0 8px;}
.portal-module-description{color:var(--portal-muted,#536870);max-width:78ch;}
.portal-module-content{display:grid;gap:var(--ah-section-gap);}
.portal-module-panel{padding:var(--ah-card-pad);}
.portal-module-panel h2{margin:0 0 10px;font-size:var(--portal-h2-size,22px);}
.portal-module-actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-top:14px;}
.portal-module-muted{color:var(--portal-muted,#536870);font-size:14px;}
.portal-module-panel input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.portal-module-panel select,
.portal-module-panel textarea,
.portal-legacy-native input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.portal-legacy-native select,
.portal-legacy-native textarea{
  width:100%;border:1px solid var(--portal-line,#cfe0e5);border-radius:var(--portal-radius-field,8px);padding:12px 14px;background:#fff;color:var(--portal-ink,#10252d);font:inherit;line-height:1.45;
}
.portal-module-panel textarea,.portal-legacy-native textarea{min-height:110px;resize:vertical;}
.portal-module-panel label,.portal-legacy-native label{font-weight:700;color:var(--portal-ink,#10252d);}

/* Legacy imports: embedded, contained, and normalized enough to look like the portal. */
.portal-legacy-import{display:grid;gap:16px;}
.portal-legacy-import-notice{border:1px solid color-mix(in srgb,var(--portal-primary,#489BAD) 35%,#fff);background:var(--portal-primary-soft,#eef8fa);border-radius:var(--ah-card-radius);padding:14px 16px;color:var(--portal-primary-dark,#347f8d);line-height:1.55;}
.portal-legacy-native{border:var(--ah-card-border);border-radius:var(--ah-card-radius);background:var(--portal-panel,#fff);box-shadow:var(--ah-card-shadow);padding:var(--ah-card-pad);overflow:hidden;}
.portal-legacy-native :where(h1,h2,h3){color:var(--portal-ink,#10252d);font-family:var(--portal-font-heading,inherit);line-height:1.15;}
.portal-legacy-native :where(p,li,small){color:var(--portal-muted,#536870);line-height:1.55;}
.portal-legacy-native :where(button,.button,.btn,input[type="button"],input[type="submit"]){border-radius:var(--portal-radius-button,8px)!important;font-weight:var(--portal-button-weight,700)!important;}
.portal-legacy-native :where(button,.button,.btn,input[type="button"],input[type="submit"]):not(.secondary):not(.outline){background:var(--portal-primary,#489BAD)!important;color:#fff!important;border:1px solid var(--portal-primary,#489BAD)!important;}
.portal-legacy-native :where(.card,.panel,.box,.tool-panel,.worksheet,.controls){border-radius:var(--ah-card-radius);border-color:var(--portal-line,#cfe0e5);}
.portal-legacy-native img,.portal-legacy-native canvas,.portal-legacy-native svg{max-width:100%;}
.portal-module-save-panel{border:1px solid var(--portal-line,#cfe0e5);border-radius:var(--ah-card-radius);background:#fff;padding:16px;display:grid;gap:10px;}
.portal-module-save-panel p{margin:0;color:var(--portal-muted,#536870);}
.portal-module-save-status{font-size:14px;color:var(--portal-muted,#536870);}
.portal-module-save-status.is-error{color:#9a4211;}

/* Portal Studio/Admin: actual visible previews, not tiny skeletons. */
.ps-choice-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px!important;}
.ps-choice{padding:0!important;border-radius:var(--ah-card-radius)!important;overflow:hidden;}
.ps-choice input{position:absolute;opacity:0;pointer-events:none;}
.ps-choice strong,.ps-choice small{display:block;padding:0 14px;}
.ps-choice strong{padding-top:12px;font-size:15px!important;}
.ps-choice small{padding-bottom:14px;font-size:13px!important;line-height:1.4;color:var(--portal-muted,#536870)!important;}
.ps-mini{height:auto!important;min-height:150px!important;display:block!important;background:#fff!important;border:0!important;border-bottom:1px solid var(--portal-line,#cfe0e5)!important;border-radius:0!important;padding:14px!important;}
.ps-mini .ps-live-hero,.ps-mini .ps-live-card{height:100%;min-height:122px;border:1px solid var(--portal-line,#cfe0e5);border-radius:var(--ah-card-radius);background:var(--portal-panel,#fff);box-shadow:var(--ah-card-shadow);overflow:hidden;display:flex;flex-direction:column;}
.ps-mini .ps-live-card-media{height:48px;background:linear-gradient(135deg,var(--portal-primary-soft,#eef8fa),#fff);border-bottom:1px solid var(--portal-line,#cfe0e5);}
.ps-mini .ps-live-card-body,.ps-mini .ps-live-hero-body{padding:12px;display:grid;gap:7px;}
.ps-mini .ps-live-kicker{font-size:10px;text-transform:uppercase;letter-spacing:.08em;font-weight:800;color:var(--portal-primary-dark,#347f8d);}
.ps-mini .ps-live-title{font-size:15px;line-height:1.15;font-weight:800;color:var(--portal-ink,#10252d);}
.ps-mini .ps-live-text{font-size:12px;line-height:1.35;color:var(--portal-muted,#536870);}
.ps-mini .ps-live-button{justify-self:start;border-radius:var(--portal-radius-button,8px);background:var(--portal-primary,#489BAD);color:#fff;padding:7px 10px;font-size:11px;font-weight:800;}
.ps-preview-hero-image .ps-live-hero{display:grid;grid-template-columns:1fr 42%;}
.ps-preview-hero-image .ps-live-card-media,.ps-preview-hero-bg .ps-live-card-media{height:auto;border:0;border-left:1px solid var(--portal-line,#cfe0e5);}
.ps-preview-hero-bg .ps-live-hero{background:linear-gradient(135deg,var(--portal-primary,#489BAD),#16343d);}
.ps-preview-hero-bg .ps-live-title,.ps-preview-hero-bg .ps-live-text,.ps-preview-hero-bg .ps-live-kicker{color:#fff;}
.ps-preview-list .ps-live-card,.ps-preview-compact .ps-live-card,.ps-preview-hero-image .ps-live-card{display:grid;grid-template-columns:38% 1fr;}
.ps-preview-list .ps-live-card-media,.ps-preview-compact .ps-live-card-media{height:auto;border-bottom:0;border-right:1px solid var(--portal-line,#cfe0e5);}
.ps-preview-text .ps-live-card-media{display:none;}
.ps-choice:has(input:checked){outline:2px solid var(--portal-primary,#489BAD);background:var(--portal-primary-soft,#eef8fa);}

@media(max-width:900px){.ps-choice-grid{grid-template-columns:1fr}.ps-shell{grid-template-columns:1fr!important}.ps-side{position:relative!important;top:auto!important}}
@media(max-width:760px){
  .dashboard-main-tiles.hub-card-grid,
  .hub-home:not(.section-hub-page)> .hub-explore-section > .hub-card-grid[data-home-nav]{grid-template-columns:repeat(var(--portal-dashboard-mobile-columns,2),minmax(0,1fr))!important;}
  .ah-category-page .hub-card-grid{grid-template-columns:repeat(var(--hub-mobile-columns,2),minmax(0,1fr));}
  .ah-category-page[data-card-style="image_side"] .hub-nav-card,
  .ah-category-page[data-card-style="compact"] .hub-nav-card,
  .ah-category-page[data-card-style="wide"] .hub-nav-card{grid-template-columns:1fr;}
  .ah-category-page[data-card-style="image_side"] .hub-nav-media,
  .ah-category-page[data-card-style="compact"] .hub-nav-media,
  .ah-category-page[data-card-style="wide"] .hub-nav-media{height:var(--ah-card-img-h);min-height:var(--ah-card-img-h);border-right:0;border-bottom:1px solid var(--portal-line,#cfe0e5);}
}
