@import '~svv-hradm-css-bibliotek/sass/base/_variables';
@import '~svv-hradm-css-bibliotek/sass/base/_ikon-variabler-generert';
@import '~svv-hradm-css-bibliotek/sass/mixins/_piler';
@import '~svv-hradm-css-bibliotek/sass/moduler/uthevet-melding';
@import '~svv-hradm-css-bibliotek/sass/moduler/modal-dialog';
@import './komponenter/arbeidskort';

@import '~react-datepicker/dist/react-datepicker';
@import 'ikoner';

@function stripUnit($value) {
	@return $value / ($value * 0 + 1);
}

@function calculateRem($size) {
	$remSize: calc(1rem * #{stripUnit($size)} / 16);
	//Default font size on html element is 100%, equivalent to 16px;
	@return #{$remSize};
}

body {
	font-size: 1rem;
	color: #010000;
}

.brodtekst-med-bottom-margin {
	margin-bottom: 20px;

	a {
		text-decoration: underline;
	}
}

.banner-blokk.util-sekundaer + .banner-blokk.util-sekundaer {
	padding-top: 0;
}

.info {
	box-sizing: content-box;
	display: inline-block;
	width: 100%;
	max-width: 40px;
	height: 39px;
	background-image: inline-image($ikon-bibliotek-info-lysegraa);
}

.input-mellomstor {
	width: 100%;
	max-width: 30rem;
}

.input-ekstra-stor {
	width: 100%;
	max-width: 50rem;
}

.input-ekstra-liten {
	width: 100%;
	max-width: 5rem;
}

.liste-kolonner {
	columns: 3;
	-webkit-columns: 3;
	-moz-columns: 3;
}

/* Her kommer det noen stiler som overstyrer global dinside-css, så vi bruker ekstra
   spesifisitet ved å sjekke radiosjekk-kolonne _og_ liste-kolonner
   Disse overstyringene trengs for å vise kolonner med sjekkbokser konsekvent i alle
   nettlesere (men jeg ser spesifikt på deg Firefox)

   Ideen er: Firefox er mye mer medgjørlig på å ikke breake midt i elementer som er
   inline-block hvis det er satt columns på ytre container. Da må vi også passe på
   at elementene får nok bredde.

   I tillegg blir eksisterende margin-regler feil, siden et element aldri breakes før
   margin lengre, så vi bytter om og sier at alle labeles som _ikke_ er siste har en
   margin-bottom (før fikk alle unntatt første label en margin-top).
 */
.radiosjekk-kolonne.liste-kolonner label {
	display: inline-block;
	width: 100%;
}

.radiosjekk-kolonne.liste-kolonner label:not(:first-of-type) {
	margin-top: 0;
}

.radiosjekk-kolonne.liste-kolonner label:not(:last-of-type) {
	margin-bottom: 15px;
}

/* Slutt på overstyring av css for sjekkboksgruppe i kolonner */

.util-graa-light {
	background-color: $gray-light;
}

.util-leselengde {
	width: 100%;
	max-width: 500px;
}

.spinner-tekst {
	margin: 0 auto; // Fiks for å sentrere spinner-tekst når vi bruker max-width i .util-leselengde
}

.util-naboblokker {
	display: flex;
	flex-wrap: wrap;
	@media screen and (min-width: $screen-sm-min) {
		& > :not(:first-child) {
			margin-left: 15px;
		}
	}

	.skjemagruppe p {
		max-width: fit-content;
	}
}

.sokefelt {
	display: block;

	&.sokefelt-ekstra-stor {
		width: 100%;
		max-width: 30rem;
	}
}

.sokeforslag {
	& > ul {
		display: inline-block;
		padding: 7px 8px 17px 8px;
		width: 100%;
		background-color: #fff;

		& > li {
			padding: 8px 37px 8px 7px;

			&.valg {
				cursor: pointer;

				&.aktiv {
					background-color: $gray-regular;
				}
			}
		}
	}
}

.knapp-blokk {
	padding-left: 15px;
	padding-right: 15px;
}

.knapperad {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: center;

	&-left {
		justify-content: left;
	}
}

.klikkbar {
	cursor: pointer;
}

.tabell {
	overflow-x: auto;

	&:not(.tabell-separert) {
		padding: 30px;
		background-color: #fff;

		&:not(.undertabell) {
			border-top: 2px solid $blue-regular;
		}
	}

	& > p {
		font-weight: bold;
	}

	& > table {
		width: 100%;

		th {
			text-align: left;
		}
	}

	&:not(.tabell-separert) > table th {
		th {
			font-weight: normal;
		}

		td {
			font-weight: bold;
		}
	}

	&.tabell-separert > table {
		border-collapse: separate;
		border-spacing: 0 10px;

		thead th,
		tbody td {
			&:first-child {
				padding-left: 20px;
			}

			padding: 10px;
			height: 60px;
			background-color: #fff;
		}

		tfoot td {
			padding: 5px;
			height: 40px;
			background-color: #fff;

			.pil-ned,
			.pil-opp {
				margin-left: 10px;
			}
		}

		&:not(.undertabell) th {
			border-top: 2px solid $blue-regular;
		}
	}
}

.filfelt-brukt {
	width: 420px;
}

.filfelt-progress-ytre {
	display: flex;
	background-color: #ffffff;
}

.filfelt-progress-indre {
	display: inline-block;
	height: 5px;
	background-color: $blue-regular;
	transition: width 1s;
}

.filfelt-brukt-tekst {
	font-size: 80%;
	margin-top: 5px;

	& *:first-child {
		float: left;
	}

	& *:last-child {
		float: right;
	}

	margin-bottom: 15px;
}

.klikkbar .pil-ned {
	@include pil-ned($gray-dark);

	&:before,
	&:after {
		margin-top: 6px;
	}
}

.klikkbar .pil-opp {
	@include pil-opp($gray-dark);

	&:before,
	&:after {
		margin-top: 6px;
	}
}

@mixin ikon-front($ikon, $size, $ikon-spacing, $background-size) {
	&::before {
		content: '';
		display: inline-block;
		width: $size;
		height: $size;
		background: $ikon no-repeat;
		padding-right: $ikon-spacing;
		background-position-x: left;
		background-position-y: center;
		background-size: $background-size;
	}
	text-decoration: none;
}

.filfelt-brukt {
	margin-top: 60px;
	margin-bottom: 40px;
}

.filopplastingsfelt {
	margin-top: 40px;
}

.filnedlastingsfelt {
	display: inline-block;
	width: 100%;

	& .filnavn {
		width: calc(100% - 100px);
		max-width: 100%;
	}

	& .last-ned {
		float: right;
		width: 100px;
	}
}

.filnavn {
	display: inline-block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	@include ikon-front(url($ikon-custom-fil-uten-handling), 15px, 8px, 11px);
}

.filnavn-med-handling {
	@include ikon-front(url($ikon-custom-fil), 15px, 8px, 11px);
}

.valgte-filer-tittel {
	font-size: 1rem;
	line-height: 1.2;
	font-weight: 600;
	margin-bottom: 15px;
}

.valgte-filer {
	& li {
		& div {
			width: 550px;
			display: grid;
			box-sizing: border-box;
			grid-template-areas: 'filnavn storrelse slett';
			grid-template-columns: 340px 80px 130px;
		}

		&:last-child div {
			padding-bottom: 15px;
		}
	}

	& li {
		&::after {
			content: '';
			display: block;
			width: 600px;
			border-bottom: 1px solid $gray-regular-dark;
			height: 1px;
		}

		&:last-child::after {
			height: 0;
			border-bottom: 0;
		}
	}

	& .filnavn {
		display: inline-block;
		max-width: 345px;
		grid-area: filnavn;
	}

	& .filstorrelse {
		display: inline-block;
		text-align: right;
		justify-self: end;
		grid-area: storrelse;
		font-size: 80%;
	}

	& .slett {
		display: inline-block;
		justify-self: end;
		grid-area: slett;
		@include ikon-front(url($ikon-custom-soppel), 15px, 8px, 14px);

		&:hover {
			text-decoration: underline;
		}
	}

	a {
		display: inline-block;
		justify-self: end;
	}
}

.last-ned {
	display: inline-block;
	padding-left: #{calculateRem(10px)};
	color: $gray-dark;
	grid-area: lastned;
	justify-self: end;
	@include ikon-front(url($ikon-custom-lastned), 15px, 8px, 15px);

	&:hover {
		text-decoration: underline;
	}
}

.flytt-hoyre {
	float: right;
}

.lenke-med-handling[role='button']:hover {
	color: $blue-regular;
	border-color: $orange;
	cursor: pointer;
}

/* Lenker skal generelt ha understreking */
.lenke-med-handling,
.klikkbar {
	text-decoration: underline;
}

/* Men ikke i stegviseren */
.steg-lenke.klikkbar {
	text-decoration: none;
}

.steg {
	&.disabled {
		opacity: 0.4;
	}
}

/* Litt egen styring av stegindikatoren sine tekster for mange steg */
@media (max-width: $screen-md-min) {
	.stegindikator .beskrivelse {
		display: none;
	}
}

@media (min-width: $screen-md-min) {
	.stegindikator .beskrivelse {
		display: inline;
	}
}

.ikon-kartmarkor {
	display: inline-block;
	width: 1em;
	height: 1em;
	background-size: 1em 1em;

	&.svarthvitt {
		background-image: url($ikon-kartmarkor-svart);
	}

	&:not(.svarthvitt) {
		background-image: url($ikon-kartmarkor-bla);
	}
}

.ikon-skilt-110-stilk {
	display: inline-block;
	width: 0.5em;
	height: 1em;
	background-size: 0.5em 1em;

	&.svarthvitt {
		background-image: url($ikon-skilt-110-stilk-svarthvitt);
	}

	&:not(.svarthvitt) {
		background-image: url($ikon-skilt-110-stilk);
	}
}

.markorikon {
	background-size: 40px 54px;
}

.varslingsikon {
	background-size: 45px 80px;
}

.oppsummering-blokk {
	margin-bottom: #{calculateRem(60px)};

	.leaflet-container {
		height: 500px;
		width: 100%;
	}

	.oppsummering-blokk-tittel {
		h3 {
			display: flex;
			align-items: center;
			margin: 0;
			font-size: 130%;
		}

		a {
			display: flex;
			align-items: center;

			&:hover {
				text-decoration: underline;
			}
		}

		display: flex;
		justify-content: space-between;
		margin-bottom: #{calculateRem(20px)};
		align-items: baseline;
	}

	&.har-valideringsfeil {
		.oppsummering-boks-wrapper {
			border: 2px solid $red-regular;
		}
	}

	.oppsummering-valideringsfeil {
		display: flex;
		align-content: center;
		align-items: center;
		@include ikon-front(
			url($ikon-bibliotek-advarsel-utropstegn-rod),
			25px,
			30px,
			25px
		);
		padding: #{calculateRem(30px)} #{calculateRem(10px)};

		&.ingen-bakgrunn {
			background-color: inherit;
		}

		@media (min-width: $screen-md-min) {
			padding: #{calculateRem(30px)} #{calculateRem(100px)};
		}
	}

	.ikon-rediger {
		@include ikon-front(url($ikon-custom-rediger), 15px, 10px, 15px);
		text-decoration: underline;
	}

	.oppsummering-boks-wrapper {
		background-color: white;
	}

	.oppsummering-blokk-innhold {
		padding: #{calculateRem(45px)} #{calculateRem(10px)};
		word-wrap: break-word;

		@media (min-width: $screen-md-min) {
			padding: #{calculateRem(45px)} #{calculateRem(100px)};
		}

		h4 {
			font-weight: normal;
			font-size: 120%;
		}

		h5 {
			font-size: 100%;
		}

		pre {
			font-family: inherit;
			word-break: break-word;
			white-space: pre-wrap;
		}

		.oppsummering-underpunkt {
			&:not(:first-child) {
				margin-top: #{calculateRem(45px)};
			}
		}

		.oppsummering-blokk-punkt {
			margin-top: #{calculateRem(45px)};
			display: flex;
			flex-direction: column;

			h4 {
				margin-bottom: #{calculateRem(30px)};
			}

			&:first-child {
				margin-top: 0;
			}

			&:not(:last-child) {
				&:after {
					justify-self: center;
					padding-top: #{calculateRem(28px)};
					content: '';
					width: 100%;
					display: inline-block;
					border-bottom: 2px solid $gray-light;
				}
			}
		}
	}

	.oppsummering-filer {
		ul {
			margin: 0;
			list-style-type: none;
			padding: 0;
		}

		// Dette var inkonsistent med resten av utseende.
		//.filer-tittel {
		//	font-size: 100%;
		//	font-weight: bold;
		//}

		li {
			> * {
				display: flex;
				align-content: center;
			}

			> .blokk {
				display: block;
			}

			> ul.liste-ustilet {
				margin: 5px 20px;

				li::after {
					margin: 0;
					border: none;
				}
			}

			&::after {
				content: '';
				height: 1px;
				display: block;
				border-bottom: 2px solid $gray-regular;
				margin: #{calculateRem(5px)} 0 #{calculateRem(15px)} 0;
				width: #{calculateRem(500px)};
			}

			&:last-child::after {
				display: none;
				border: none;
			}
		}

		.filnavn {
			box-sizing: border-box;
			display: inline-block;
			width: #{calculateRem(400px)};
			max-width: #{calculateRem(400px)};
		}
	}

	.blokk {
		display: block;
	}
}

.info-mangler {
	color: $red-regular;
}

.luft-over {
	margin-top: 15px;
	margin-bottom: 0;
}

.oppsummering-tabell {
	table-layout: fixed;
	width: 100%;

	td,
	th {
		margin: 0;
		padding: 2px 2px #{calculateRem(15px)} 2px;
		text-align: left;
		word-break: break-word;
		vertical-align: top;
	}

	tr:last-child td {
		padding-bottom: 0;
	}

	&.kolonner-2 {
		th {
			width: 50%;
		}
	}

	&.kolonner-3 {
		th {
			width: 33.3333%;
		}

		th:last-child:nth-child(2) {
			width: 66.6666%;
		}
	}

	&.kolonner-4 {
		th {
			width: 25%;
		}

		th:last-child:nth-child(2) {
			width: 75%;
		}

		th:last-child:nth-child(3) {
			width: 50%;
		}
	}

	&.kolonner-5 {
		th {
			width: 20%;
		}

		th:last-child:nth-child(2) {
			width: 80%;
		}

		th:last-child:nth-child(3) {
			width: 60%;
		}

		th:last-child:nth-child(4) {
			width: 40%;
		}
	}
}

/* Vi trenger høyere presedens for å sikre at vår stiling virker */
div.dialog-modalboks,
div.dialog-backdrop {
	z-index: 1005; /* Den minste som overgår leaflet */
}

.dialog-modalboks {
	min-width: 30rem;
	width: auto;

	.kapitteltittel {
		width: 100%;

		&.advarsel-om-feil {
			width: calc(100% - 35px);
		}
	}

	&.bred-dialog {
		width: 50rem;
	}
}

.knapp-neste.knapp-handling:disabled {
	&:hover {
		color: #3d505a;
	}

	&:before {
		border-left-color: #d1d3d4;
	}

	&:after {
		border-left-color: black;
	}
}

.ikon-person {
	@include ikon-front(url($ikon-custom-person), 25px, 10px, 20px);
}

.ikon-tid {
	@include ikon-front(url($ikon-custom-tid), 25px, 10px, 25px);
}

.ikon-fil {
	@include ikon-front(url($ikon-custom-fil), 25px, 10px, 11px);
}

.ikon-vedlegg {
	@include ikon-front(url($ikon-custom-vedlegg), 25px, 10px, 25px);
}

.ikon-sted {
	@include ikon-front(url($ikon-custom-sted), 25px, 10px, 19px);
}

.ikon-tekst {
	@include ikon-front(url($ikon-custom-tekst), 25px, 10px, 18px);
}

.ikon-info {
	@include ikon-front(url($ikon-custom-info), 25px, 10px, 18px);
}

.ikon-tommelopp {
	@include ikon-front(url($ikon-custom-tommelopp), 25px, 10px, 18px);
}

.ikon-flagg {
	@include ikon-front(url($ikon-custom-flagg), 20px, 10px, 20px);
}

.tekstfelt:disabled,
.tekstboks:disabled,
.nedtrekksliste:disabled {
	background-color: $gray-regular;
}

.ekstrainnrykk {
	margin-left: 2em;
}

.infoboks-tilbakemelding {
	border: 1px solid $blue-regular;
	padding: 45px 100px;
	margin: 25px 0px;
}

.knappSomLenke {
	border: none;
	background: none;
	text-decoration: underline;
	width: 100%;
}

.ingen-luft-under {
	margin-bottom: 0px;
	padding-bottom: 0px;
}

.liste-ustilet {
	margin: 0;
	padding: 0;

	dt,
	dd {
		margin: 0;
		padding: 0;
	}
}

.definition-list-horisontal {
	dt,
	dd {
		display: inline;
	}
}

.fieldset-disabled {
	.radiosjekk-kolonne,
	label {
		opacity: 0.5;
	}
}

fieldset {
	border: none;
}

.saksbehandling-redigert-informasjon-liste {
	background-color: #e8f3e9;
	padding: 4px;
}

.saksbehandling-redigert-informasjon {
	box-shadow: -5px 0px 0px #1d7721;
	background-color: #e8f3e9;
	padding: 4px;
}

.saksbehandling-redigert-informasjon tr {
	background-color: transparent;
}

.slettet-informasjonsboks {
	background-color: #fedfe1;
	padding: 8px;
	margin-top: 8px;

	p {
		margin: 0;
	}
}
