/*

 */

/* Print stylesheet
 *
 * Loaded with media="print", so all rules here only apply when printing or
 * generating a PDF via the browser. Adjusts both the legacy layout and the
 * Tailwind-based "new look" so paper output focuses on content, not chrome.
 */

/* --- Hide UI chrome ------------------------------------------------------- */

/* Legacy layout chrome */
#header,
#console,
#footer,
#navigation,
#secondary_navigation,
#cookie-consent-stage,
.context_navigation ul,
.paginator,
.sidebar,
.tool {
  display: none !important;
}

/* New-look entity header navigation tabs */
nav[data-entity-header-nav="true"] {
  display: none !important;
}

/* Turbo-frame loading spinners */
turbo-frame .animate-spin,
[data-loading-spinner-target] {
  display: none !important;
}

/* --- Body & layout reset -------------------------------------------------- */

body {
  background-color: #ffffff;
  color: #000000;
  line-height: 1.5em;
}

/* Disable sticky positioning so floating headers don't pile up */
.sticky {
  position: static !important;
}

/* The decorative round entity-type icon is absolutely positioned next to the
 * header; in print there's no room for it to float, so drop it. */
.absolute.rounded-full.border-8 {
  display: none !important;
}

/* Tailwind colored surfaces -> white for ink-efficient printing */
.bg-slate-50,
.bg-slate-100,
.bg-slate-200,
.bg-slate-300,
.bg-slate-400,
.bg-slate-50.bg-opacity-60 {
  background-color: #ffffff !important;
}

/* Drop slate text colors to plain black */
[class*="text-slate-"] {
  color: #000000 !important;
}

/* Strip shadows that don't render well on paper */
.shadow,
.shadow-sm,
.shadow-md,
.shadow-lg,
[class*="shadow-["] {
  box-shadow: none !important;
}

/* Allow content area to use full page width */
.max-w-6xl,
.max-w-7xl,
.max-w-8xl,
.max-w-12xl {
  max-width: none !important;
}

/* --- Legacy branding ------------------------------------------------------ */

h1 {
  margin-top: 1em;
}

#branding {
  background-image: none;
  background-color: #ffffff;
  border-bottom: 0.1em solid #333333;
  font-weight: bold;
  padding-bottom: 0.4em;
}

#logo {
  background-image: none;
  color: #000000;
  padding: 0;
  text-indent: 0;
  text-decoration: none;
}

/* --- Tables (general) ----------------------------------------------------- */

th,
td {
  padding: 0.2em 0.5em 0 0.2em;
  text-align: left;
  vertical-align: top;
}

/* --- History tables (Historik tab) --------------------------------------- */

.history-content {
  padding: 0 !important;
}

.history-content h2,
[id^="historik-"] h2 {
  page-break-after: avoid;
  -moz-column-break-after: avoid;
       break-after: avoid-page;
  margin-top: 1.4em;
  margin-bottom: 0.4em;
  font-size: 1.1em;
}

.history-content ul {
  padding-left: 1.5em;
  margin: 0 0 1em;
}

/* New-look CompanyHistoryComponent / PersonHistoryComponent layout.
 *
 * The component uses Tailwind grid rows with `lg:grid-cols-[...]` arbitrary
 * values, plus column labels gated on `hidden lg:block`. The viewport meta
 * is width=992 (below the lg breakpoint of 1024), so when printing the grid
 * collapses to a single column and the column headers disappear — every row
 * renders as a vertical card. Restore the wide layout for print.
 *
 * Everything below is scoped to the `.history-tab` wrapper that
 * CompanyHistoryComponent / PersonHistoryComponent add, so we don't reach
 * into search result cards or other components that happen to share the
 * same Tailwind utility combinations. */

.history-tab [class*="lg:grid-cols-[2fr_6fr_2fr_2fr]"] {
  display: grid !important;
  grid-template-columns: 2fr 6fr 2fr 2fr !important;
  -moz-column-gap: 0.5em;
       column-gap: 0.5em;
}

.history-tab [class*="lg:grid-cols-[2fr_3fr_2fr_2fr_2fr_1fr]"] {
  display: grid !important;
  grid-template-columns: 2fr 3fr 2fr 2fr 2fr 1fr !important;
  -moz-column-gap: 0.5em;
       column-gap: 0.5em;
}

.history-tab [class*="lg:grid-cols-[2fr_10fr]"] {
  display: grid !important;
  grid-template-columns: 2fr 10fr !important;
  -moz-column-gap: 0.5em;
       column-gap: 0.5em;
}

.history-tab [class*="lg:grid-cols-[2fr_6fr]"] {
  display: grid !important;
  grid-template-columns: 2fr 6fr !important;
  -moz-column-gap: 0.5em;
       column-gap: 0.5em;
}

.history-tab .lg\:grid-cols-2 {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  -moz-column-gap: 0.5em;
       column-gap: 0.5em;
}

/* Reveal the column header labels that are normally only shown at lg+. */
.history-tab [role="row"] > .hidden.lg\:block {
  display: block !important;
}

/* Each section's row container — keep the rounded border but drop the shadow
 * and avoid splitting a row across pages. */
.history-tab .rounded.border.border-slate-400 {
  box-shadow: none !important;
  page-break-inside: auto;
}

.history-tab .rounded.border.border-slate-400 > div {
  page-break-inside: avoid;
  -moz-column-break-inside: avoid;
       break-inside: avoid;
}

/* Force the historical tables to actually render as tables (some Tailwind
 * resets and narrow widths can cause cells to wrap awkwardly), and keep rows
 * intact across page breaks. */
table.historical {
  display: table !important;
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 0 0 1em;
  page-break-inside: auto;
}

table.historical thead {
  display: table-header-group !important;
}

table.historical tbody {
  display: table-row-group !important;
}

table.historical tr {
  display: table-row !important;
  page-break-inside: avoid;
  -moz-column-break-inside: avoid;
       break-inside: avoid;
}

table.historical th,
table.historical td {
  display: table-cell !important;
  border: 1px solid #999 !important;
  padding: 0.25em 0.5em !important;
  vertical-align: top !important;
}

table.historical thead th {
  font-weight: bold;
  text-align: left;
  border-bottom: 2px solid #333 !important;
}

table.historical th.rowhead {
  width: auto;
  font-weight: 600;
  white-space: nowrap;
}

table.historical td.period {
  white-space: nowrap;
}

/* --- Relations (Profil tab) ----------------------------------------------
 *
 * Same shape as the .history-tab fix above: each
 * `EntitiesProfilTab::Relations::RelationTypeComponent` renders its column
 * header strip and per-relation rows as `lg:grid lg:grid-cols-7`, with the
 * header strip additionally `hidden` below the lg breakpoint. The print
 * viewport sits below lg, so the grid never engages and the header strip
 * stays hidden — every relation collapses to a left-aligned vertical
 * stack. Restore the desktop 7-column layout for paper.
 *
 * Scoped to the `.relations-tab` marker on the outer entity_types turbo
 * frame so we don't reach into other components that happen to share the
 * `lg:grid-cols-7` utility. */

.relations-tab [class*="lg:grid-cols-7"] {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  -moz-column-gap: 0.5em;
       column-gap: 0.5em;
}

/* Reveal the column-header strip that is otherwise `hidden` below lg. */
.relations-tab .hidden[class*="lg:grid-cols-7"] {
  display: grid !important;
}

/* Alignment utilities gated on lg — apply unconditionally for print so
 * role/ownership, start date and end date columns right-align. */
.relations-tab .lg\:text-right   { text-align: right !important; }
.relations-tab .lg\:justify-end  { justify-content: flex-end !important; }
.relations-tab .lg\:items-center { align-items: center !important; }

/* Keep each relation row intact across page breaks. */
.relations-tab .divide-y > a {
  page-break-inside: avoid;
  -moz-column-break-inside: avoid;
       break-inside: avoid;
}

/* Drop the card shadow; the rounded border alone reads fine on paper. */
.relations-tab .border.border-slate-400.rounded {
  box-shadow: none !important;
}

/* --- Network listing ------------------------------------------------------ */

ol.network .connections {
  font-size: 0.8em;
  font-weight: normal;
}

ol.network li {
  margin-bottom: 1em;
}

ol.network a.entity {
  font-weight: bold;
}

/* --- Key figures (Nøgletal) page -----------------------------------------
 *
 * Everything below is scoped to the `.key-figures-tab` marker class that
 * `companies/_key_figures.html+turbo.erb` adds to its content wrapper, so
 * we don't accidentally pull horizontal padding off annual-accounts,
 * ownership-list, or other `#tab_content` views that share `px-10`. */

/* The key-figures view wraps content in `<turbo-frame id="tab_content"
 * class="scale-75">`. The CSS transform doesn't shrink the layout box, so on
 * paper the right edge of the chart / table runs past the page margin. Drop
 * the transform when the scale-75 class is present so the layout flows
 * naturally and the rules below can size each piece. */
turbo-frame#tab_content.scale-75 {
  transform: none !important;
}

/* Pull the key-figures content out of its `px-10` (40px) Tailwind padding so
 * tables and charts can use the full printable width. */
.key-figures-tab {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* D3 charts (`#results_chart`, `#balance_chart`, etc.) are rendered at the
 * container's pixel width on first paint, so the SVG keeps its on-screen
 * dimensions even when the print sheet is narrower. Constrain the SVG to
 * its container width and let height scale proportionally. */
.company_key_figures_chart {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden;
}

.company_key_figures_chart svg {
  max-width: 100% !important;
  height: auto !important;
}

/* `table.key_figures` has one column per year — easily 8-10 columns. Shrink
 * the body font and force a fixed table-layout so columns share the page
 * width evenly instead of overflowing the right margin. */
table.key_figures {
  border-collapse: collapse;
  margin-top: 0;
  margin-bottom: 1em;
  width: 100% !important;
  table-layout: fixed !important;
  font-size: 0.75em !important;
}

table.key_figures th,
table.key_figures td {
  padding: 0.2em 0.3em !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

table.key_figures th.title {
  vertical-align: middle;
}

table.key_figures th.amount {
  text-align: right;
}

table.key_figures td {
  text-align: right;
  vertical-align: middle;
}

table.key_figures td .amount {
  display: none;
}

.chart {
  /* Printing the charts looks terrible, so we'd better remove them until we figure out a proper print */
  display: none;
}

div.visual-legend {
  display: none;
}

/* --- Links --------------------------------------------------------------- */

a,
a:visited {
  color: #000000;
  text-decoration: none;
}

/* --- Page setup ---------------------------------------------------------- */

@page {
  margin: 1.5cm;
}
