/*
 * The trip dialog of the charging plan.
 *
 * PrimeFaces places a dialog with jQuery UI's position(), and until #831 every page of this
 * template loaded its own jQuery on top of the one PrimeFaces brings - so the plugin it asked for
 * was not on the jQuery it ended up using, and the call quietly left the dialog in the top left
 * corner of the window: half of it under the header, taller than the screen, with the Save button
 * below the fold. The trip could be filled in and not saved.
 *
 * These rules place the dialog and cap its height without asking jQuery UI for anything, and stay
 * after #831 because they are the placement wanted anyway: below the fixed header, never taller
 * than the window. !important is what it takes - PrimeFaces writes top, left and z-index into the
 * element's own style attribute as it shows it. It is also why the dialog is draggable="false".
 */
.trip-dialog {
    position: fixed !important;
    top: 84px !important;
    left: 50% !important;
    transform: translateX(-50%);
    max-width: 94vw;
    max-height: calc(100vh - 104px);
    /* over the fixed header of the template, which would otherwise cover the dialog's own title */
    z-index: 1200 !important;
}

/* A long form stays reachable: the dialog keeps its frame, the fields inside it scroll. */
.trip-dialog .ui-dialog-content {
    max-height: calc(100vh - 104px - 3rem);
    overflow-y: auto;
}

/* The modal mask covers the header too, or a menu stays clickable behind an open dialog. */
.ui-widget-overlay {
    z-index: 1190 !important;
}

/* On a phone the header is shorter and every pixel of width counts. */
@media (max-width: 576px) {
    .trip-dialog {
        top: 64px !important;
        max-width: 96vw;
        max-height: calc(100vh - 80px);
    }

    .trip-dialog .ui-dialog-content {
        max-height: calc(100vh - 80px - 3rem);
    }
}


/*
 * The charging plan page.
 *
 * Two things need saying visually, and only two. A trip inside the week the plan simulated is not
 * the same as one booked eleven weeks out, and a day on which nothing happens should recede rather
 * than take the same space as one that carries three drives and a grid charge.
 */
.plan-day {
    border-left: 4px solid #2ecc71;
}

.plan-day-quiet {
    border-left-color: #d5d8dc;
    opacity: .75;
}

/* The trips of the week the plan actually covers - the rest are booked, but not yet simulated. */
.plan-trip-table .plan-trip-soon > td {
    background-color: rgba(46, 204, 113, .08);
}

/* A window table sits inside a day card and should read as part of it, not as a second table. */
.plan-window-table .ui-datatable-header,
.plan-window-table .ui-datatable-footer {
    display: none;
}

.plan-window-table td,
.plan-window-table th {
    padding: .3rem .5rem;
    font-size: .85rem;
}

/*
  The charging plan's header buttons: one row, right-aligned, all the same height. On a phone the
  row wraps as a whole rather than leaving one button hanging under the others.
*/
.plan-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: stretch;
    gap: .5rem;
}

.plan-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    margin: 0;
}

/*
  The plan's growl in the bottom right corner, not the top right. Up there it covered the header
  buttons, and a growl stops fading while the pointer is on it - so the click meant for
  "New trip" landed on the message instead, for as long as the pointer stayed there (#673).
*/
#rebuildForm\:planMessages_container {
    top: auto;
    bottom: 20px;
}

/* ── one car's battery over the plan's week (#742, common/batteryLane.xhtml) ── */
.battery-lane {
	margin: 12px 0;
}

.battery-lane .lane-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	margin-bottom: 8px;
}

.battery-lane .lane-title {
	font-weight: 700;
}

.battery-lane .lane-verdict {
	font-size: 13px;
	font-weight: 600;
	color: #1e6b3e;
	margin-left: auto;
}

.battery-lane .lane-low,
.battery-lane .lane-low .lane-after {
	color: #a1231a;
}

.battery-lane .lane-chart-box {
	position: relative;
	height: 160px;
	margin-left: 34px;
}

.battery-lane .lane-chart {
	display: block;
	width: 100%;
	height: 160px;
	overflow: visible;
}

.battery-lane .lane-chart line,
.battery-lane .lane-chart polyline {
	vector-effect: non-scaling-stroke;
}

.battery-lane .lane-band-sun {
	fill: #e8a317;
	opacity: 0.28;
}

.battery-lane .lane-band-grid {
	fill: #c23b32;
	opacity: 0.22;
}

.battery-lane .lane-day-line {
	stroke: #eef0f5;
	stroke-width: 1;
}

.battery-lane .lane-guide {
	stroke: #eef0f5;
	stroke-width: 1;
}

.battery-lane .lane-axis {
	stroke: #c9ceda;
	stroke-width: 1;
}

.battery-lane .lane-reserve {
	stroke: #c23b32;
	stroke-width: 1;
	stroke-dasharray: 4 4;
}

.battery-lane .lane-line {
	fill: none;
	stroke: #1d5fd1;
	stroke-width: 2.5;
	stroke-linejoin: round;
}

.battery-lane .lane-reserve-label {
	position: absolute;
	right: 0;
	font-size: 10px;
	line-height: 1;
	color: #5b6272;
	background: rgba(255, 255, 255, 0.85);
	padding: 1px 3px;
}

/* The y-axis, in the gutter left of the chart (#755). */
.battery-lane .lane-tick {
	position: absolute;
	left: -34px;
	width: 30px;
	text-align: right;
	transform: translateY(-50%);
	font-size: 10px;
	line-height: 1;
	color: #8a90a0;
	white-space: nowrap;
}

/* The battery on each flat stretch of the line, above it - or under it near 100 %. */
.battery-lane .lane-level,
.battery-lane .lane-now {
	position: absolute;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	color: #1d5fd1;
	white-space: nowrap;
	background: rgba(255, 255, 255, 0.85);
	padding: 1px 3px;
	border-radius: 3px;
}

.battery-lane .lane-level-above {
	transform: translate(-50%, -140%);
}

.battery-lane .lane-level-below {
	transform: translate(-50%, 40%);
}

/* Where the line starts: now, and the battery the plan expects the car to have. */
.battery-lane .lane-now-dot {
	position: absolute;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #1d5fd1;
	border: 2px solid #fff;
	box-shadow: 0 0 0 1px #1d5fd1;
	transform: translate(-50%, -50%);
}

.battery-lane .lane-now {
	transform: translate(4px, -150%);
	font-weight: 600;
}

/* What each charge or drive does, under the chart where it happens. */
.battery-lane .lane-changes {
	position: relative;
	margin-left: 34px;
	margin-top: 3px;
}

.battery-lane .lane-change {
	position: absolute;
	transform: translateX(-50%);
	font-size: 10px;
	font-weight: 600;
	line-height: 14px;
	white-space: nowrap;
}

.battery-lane .lane-change-sun {
	color: #9a6a00;
}

.battery-lane .lane-change-grid {
	color: #a1231a;
}

.battery-lane .lane-change-drive {
	color: #5b6272;
}

.battery-lane .lane-reserve-label {
	transform: translateY(-120%);
	font-weight: 600;
	color: #a1231a;
}

.battery-lane .lane-days {
	display: grid;
	margin-left: 34px;
	text-align: center;
	font-size: 11px;
	color: #5b6272;
	margin-top: 4px;
}

.battery-lane .lane-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	font-size: 11px;
	color: #5b6272;
	margin-top: 8px;
}

.battery-lane .lane-legend span {
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.battery-lane .lane-legend i {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 2px;
}

.battery-lane .lane-key-line {
	height: 3px !important;
	width: 14px !important;
	background: #1d5fd1;
}

.battery-lane .lane-key-sun {
	background: rgba(232, 163, 23, 0.45);
}

.battery-lane .lane-key-grid {
	background: rgba(194, 59, 50, 0.35);
}

.battery-lane .lane-events {
	list-style: none;
	padding: 0;
	margin: 10px 0 0;
	border-top: 1px solid #e1e4ec;
}

.battery-lane .lane-events li {
	display: grid;
	grid-template-columns: 96px minmax(0, 1fr) auto;
	gap: 10px;
	align-items: baseline;
	padding: 7px 0;
	border-bottom: 1px solid #eef0f5;
	font-size: 13px;
}

.battery-lane .lane-when {
	color: #5b6272;
	font-size: 12px;
	white-space: nowrap;
}

.battery-lane .lane-what {
	font-weight: 600;
	min-width: 0;
	overflow-wrap: anywhere;
}

.battery-lane .lane-what small {
	font-weight: 400;
	color: #5b6272;
	margin-left: 6px;
}

.battery-lane .lane-after {
	font-weight: 700;
	white-space: nowrap;
}

.plan-summary-fold summary {
	cursor: pointer;
	font-weight: 600;
	min-height: 32px;
	display: flex;
	align-items: center;
}
