/* Akademia Transportu — mobile-first UI dla aplikacji kierowcy.
   Jeden ekran na telefonie na raz, duże cele dotykowe (min. 48px), czytelne na słońcu. */

:root {
    --color-brand: #1b4332;
    --color-brand-dark: #10281f;
    --color-brand-light: #2d6a4f;
    --color-danger: #9d0208;
    --color-danger-bg: #fde8e8;
    --color-warning: #7a5c00;
    --color-warning-bg: #fff3cd;
    --color-info: #084a91;
    --color-info-bg: #e7f1ff;
    --color-bg: #f4f6f5;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #5f6b66;
    --color-border: #d9e0dc;

    --radius: 14px;
    --radius-sm: 8px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --tap-min: 48px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Several component classes below (.stacked-form, .action-grid, ...) set their own
   `display`, which would otherwise silently override the native [hidden] attribute
   at equal specificity — reassert it so JS-driven show/hide keeps working. */
[hidden] {
    display: none !important;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

button, input {
    font-family: inherit;
}

a {
    color: inherit;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Layout */

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: calc(var(--space-3) + var(--safe-top)) var(--space-4) var(--space-3);
    background: var(--color-brand);
    color: #fff;
}

.app-header__brand {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
}

.app-header__home {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #fff;
    opacity: 0.9;
}

.app-header__home svg {
    width: 20px;
    height: 20px;
}

.app-header__logout {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #fff;
    opacity: 0.9;
}

.app-header__logout svg {
    width: 20px;
    height: 20px;
}

.app-main {
    padding: var(--space-4) calc(var(--space-4) + var(--safe-right)) calc(var(--space-6) + var(--safe-bottom)) calc(var(--space-4) + var(--safe-left));
    max-width: 480px;
    margin: 0 auto;
}

.screen__title {
    margin: 0 0 var(--space-1);
    font-size: 24px;
    font-weight: 700;
}

.screen__subtitle {
    margin: 0 0 var(--space-4);
    color: var(--color-text-muted);
    font-size: 15px;
}

.date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.date-nav__label .screen__title,
.date-nav__label .screen__subtitle {
    margin-bottom: 0;
}

.date-nav__calendar-btn {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-brand);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.date-nav__calendar-btn svg {
    width: 22px;
    height: 22px;
}

.date-nav__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.screen--centered {
    min-height: calc(100vh - var(--safe-top) - var(--safe-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.screen--centered .screen__title,
.screen--centered .screen__subtitle {
    text-align: center;
}

.screen--centered {
    position: relative;
    isolation: isolate;
}

.screen--centered::before,
.screen--centered::after {
    content: "";
    position: absolute;
    inset: -24px;
}

.screen--centered::before {
    background: url("../images/login-bg-road-Ats_-pI.jpg") center/cover no-repeat;
    z-index: -2;
}

.screen--centered::after {
    background: rgba(244, 246, 245, 0.45);
    z-index: -1;
}

.back-link {
    display: inline-block;
    margin-bottom: var(--space-3);
    padding: var(--space-2) 0;
    color: var(--color-brand);
    font-weight: 600;
    text-decoration: none;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap-min);
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn--primary {
    background: var(--color-brand);
    color: #fff;
}

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-brand);
    border: 1.5px solid var(--color-brand);
}

.btn--link {
    background: none;
    color: var(--color-text-muted);
    font-weight: 500;
    min-height: auto;
    padding: var(--space-2);
}

.btn--big {
    width: 100%;
    min-height: 56px;
    font-size: 18px;
    border-radius: var(--radius);
}

.btn--pickup {
    background: var(--color-brand-light);
    color: #fff;
}

.btn--deliver {
    background: var(--color-brand-dark);
    color: #fff;
}

/* Forms */

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.field-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-top: var(--space-2);
}

.field-input {
    min-height: var(--tap-min);
    padding: var(--space-3);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-size: 17px;
    color: var(--color-text);
}

.field-input:focus {
    outline: none;
    border-color: var(--color-brand);
}

.field-input--pin {
    letter-spacing: 0.5em;
    text-align: center;
    font-size: 22px;
}

.field-hint {
    min-height: 1.2em;
    font-size: 13px;
    color: var(--color-text-muted);
}

.field-hint--error {
    color: var(--color-danger);
    font-weight: 600;
}

/* Alerts */

.alert {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: var(--space-4);
}

.alert--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.alert--warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.alert--info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

/* Route block — wraps one whole trasa (progress bar, Start/Koniec, stop list).
   Only visually separated (border + heading) when the driver has more than one
   route the same day — see route_groups in dashboard/index.html.twig. */

.route-block--grouped {
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: 12px;
}

.route-block__heading {
    margin: 0 0 var(--space-3);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted, var(--color-brand));
}

.route-block__heading-count {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
}

/* Route progress */

.route-progress {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.route-progress__bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--color-border);
    overflow: hidden;
}

.route-progress__fill {
    height: 100%;
    width: 0%;
    background: var(--color-brand-light);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.route-progress__label {
    flex-shrink: 0;
    min-width: 72px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-brand);
}

.route-block__carrying {
    margin: 0 0 var(--space-3);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted, var(--color-brand));
}

/* Start trasy / Koniec trasy — centered milestone buttons */

.route-end-btn {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: var(--space-4) auto;
    padding: var(--space-3) var(--space-4);
    border: 1.5px solid var(--color-brand);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-brand);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.route-end-btn:disabled {
    border-color: var(--color-border);
    color: var(--color-text-muted);
    opacity: 0.6;
}

.route-end-btn--done {
    border-color: var(--color-brand-light);
    background: var(--color-brand-light);
    color: #fff;
}

/* Stop list (route) */

.stop-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.stop-list__item {
    /* Back-links from the stop's own screens jump to #stop-{id} (see
       location/show.html.twig, location/quantity.html.twig) - without this the
       sticky header (.app-header) would cover the top of whichever card the
       driver just came back to. */
    scroll-margin-top: calc(64px + var(--safe-top));
}

.stop-list__connector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin: calc(var(--space-2) * -1) 0;
}

.continue-arrow__time {
    min-width: 40px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-brand-light);
}

.continue-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--color-surface);
    color: var(--color-text-muted);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.continue-arrow svg {
    width: 18px;
    height: 18px;
}

.continue-arrow--done {
    background: var(--color-brand-light);
    color: #fff;
}

.add-location-btn {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-brand);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.add-location-btn svg {
    width: 18px;
    height: 18px;
}

.add-location-btn--locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.stop-list__connector--end {
    justify-content: stretch;
    margin-top: 0;
}

.add-location-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius);
    color: var(--color-brand);
    font-weight: 600;
    text-decoration: none;
}

.add-location-row svg {
    width: 18px;
    height: 18px;
}

.stop-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.stop-card--added-during-route {
    background: var(--color-danger-bg);
    box-shadow: inset 0 0 0 1.5px #f3b8b8;
}

/* Completed wins over "added during route" (both classes can be set at once -
   completing the stop is what the red highlight is even asking the driver to
   notice and act on) - this rule MUST come after --added-during-route above so
   it wins with equal specificity. */
.stop-card--completed {
    background: #e3f2e8;
    box-shadow: inset 0 0 0 1.5px var(--color-brand-light);
}

.stop-card__badge {
    align-self: flex-start;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--color-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stop-card__top {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.stop-card__actions {
    display: flex;
    gap: var(--space-2);
}

.stop-card__action-btn {
    flex: 1;
    min-height: 40px;
    font-size: 15px;
}

.stop-card__action-btn--locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.stop-card__sequence {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-brand);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.stop-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.stop-card__name {
    font-weight: 600;
    font-size: 16px;
}

.stop-card__address {
    color: var(--color-text-muted);
    font-size: 13px;
}

.stop-card__hours {
    color: var(--color-text-muted);
    font-size: 12px;
}

.stop-card__maps,
.location-heading__maps {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--color-info-bg);
    color: var(--color-info);
}

.stop-card__maps svg,
.location-heading__maps svg {
    width: 22px;
    height: 22px;
}

.location-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.location-heading .screen__title {
    margin: 0;
}

.stop-card__counts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
    flex-shrink: 0;
}

.stop-count {
    min-width: 28px;
    padding: 2px var(--space-2);
    border-radius: 999px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.stop-count--picked {
    background: #c9720b;
}

.stop-count--delivered {
    background: var(--color-brand-light);
}

.empty-state {
    padding: var(--space-5) 0;
    text-align: center;
    color: var(--color-text-muted);
}

/* Full-screen "route changed underneath you" notice (route_poll_controller.js) */

.update-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(16, 40, 31, 0.85);
}

.update-overlay__box {
    max-width: 360px;
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius);
    background: var(--color-surface);
    text-align: center;
}

.update-overlay__title {
    margin: 0 0 var(--space-2);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-danger);
}

.update-overlay__text {
    margin: 0 0 var(--space-4);
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Location picker (driver adding an unplanned stop to their own route) */

.location-picker-search {
    width: 100%;
    margin-bottom: var(--space-4);
}

.location-picker-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.location-picker-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    text-align: left;
    cursor: pointer;
}

.location-picker-btn:active {
    transform: scale(0.98);
}

.location-picker-btn__name {
    font-weight: 600;
    font-size: 16px;
    color: var(--color-text);
}

.location-picker-btn__address {
    color: var(--color-text-muted);
    font-size: 13px;
}

.location-picker-btn__badge {
    font-size: 12px;
    color: var(--color-text-muted);
}

.location-picker-btn--closed {
    opacity: 0.4;
    cursor: not-allowed;
}

.location-picker-btn__badge--closed {
    color: var(--color-danger);
    font-weight: 600;
}

.logout-row {
    text-align: center;
    margin-top: var(--space-5);
}

/* Action history (below the confirm button on the pickup/deliver screen) */

.action-history {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.action-history__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.action-history__item:has(.action-history__status--cancelled) {
    opacity: 0.6;
}

.action-history__item:has(.action-history__status--cancelled) span:first-child {
    text-decoration: line-through;
}

.action-history__status {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
}

.action-history__status--pending {
    color: var(--color-warning);
}

.action-history__status--synced {
    color: var(--color-brand);
}

.action-history__status--cancelled {
    color: var(--color-danger);
}

.action-history__actions:not(:empty) {
    flex-shrink: 0;
}

.action-history__cancel {
    min-height: 32px;
    padding: 4px var(--space-2);
    border: 1.5px solid var(--color-danger);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--color-danger);
    font-size: 12px;
    font-weight: 700;
}

/* Location action grid */

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.action-grid .btn--big {
    min-height: 96px;
    font-size: 20px;
}

/* Quantity pad */

.quantity-pad {
    display: flex;
    align-items: stretch;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.quantity-pad__step {
    flex: 0 0 64px;
    height: 64px;
    border: none;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    font-size: 28px;
    font-weight: 700;
    color: var(--color-brand);
    cursor: pointer;
}

.quantity-pad__step:active {
    background: var(--color-border);
}

.quantity-pad__input {
    flex: 1;
    min-width: 0;
    height: 64px;
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
}

.quantity-pad__input:focus {
    outline: none;
    border-color: var(--color-brand);
}

/* Carrying counter (header badge) */

.carrying-counter {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
}

.carrying-counter__label {
    opacity: 0.85;
}

.carrying-counter__value {
    font-size: 15px;
    font-weight: 700;
}

.carrying-counter__unit {
    opacity: 0.85;
}

/* Offline banner */

.offline-banner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: calc(var(--space-2) + var(--safe-top)) var(--space-4) var(--space-2);
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: 13px;
}

.offline-banner--hidden {
    display: none;
}

.offline-banner__pending {
    font-weight: 700;
}

.offline-banner__sync-btn {
    margin-left: auto;
    flex-shrink: 0;
    min-height: 36px;
    padding: var(--space-1) var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-warning);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
