@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/OpenSans-Light.ttf') format('truetype');
}
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/OpenSans-Regular.ttf') format('truetype');
}
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/OpenSans-SemiBold.ttf') format('truetype');
}
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/OpenSans-Bold.ttf') format('truetype');
}
body {
    font-family: 'Open Sans', sans-serif;
}
:root {
    color-scheme: light;
}
input,
select,
textarea {
    color: #1f2937;
    background-color: #ffffff;
    -webkit-text-fill-color: #1f2937;
}
input::placeholder,
textarea::placeholder {
    color: #6b7280;
    opacity: 1;
}
.font-open-sans-light { font-family: 'Open Sans', sans-serif; font-weight: 300; }
.font-open-sans-regular { font-family: 'Open Sans', sans-serif; font-weight: 400; }
.font-open-sans-semibold { font-family: 'Open Sans', sans-serif; font-weight: 600; }
.font-open-sans-bold { font-family: 'Open Sans', sans-serif; font-weight: 700; }

/* Address Validation Icons */
.validation-icon {
    display: inline-block;
    min-width: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.validation-icon.incomplete {
    color: #f59e0b; /* amber-500 */
}

.validation-icon.validating {
    color: #3b82f6; /* blue-500 */
    animation: pulse 1.5s ease-in-out infinite;
}

.validation-icon.valid {
    color: #10b981; /* green-500 */
    font-weight: bold;
}

.validation-icon.invalid {
    color: #ef4444; /* red-500 */
    font-weight: bold;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Route info styling */
.route-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
}
.route-info.loading {
    opacity: 0.7;
}
/* Items grid alignment */
.items-grid {
    display: grid;
    grid-template-columns: 40px 80px 100px 100px 100px 110px 1fr 90px 90px 90px;
    gap: 10px;
    align-items: center;
}
/* Header row styling */
#items-legend.items-grid > div {
    font-size: 12px;
    color: #6b7280; /* gray-500 */
}
/* Validation styles */
.field-error {
    border-color: #ef4444 !important; /* red-500 */
    box-shadow: 0 0 0 1px #ef4444 inset;
}
.error-box {
    background: #fef2f2; /* red-50 */
    border: 1px solid #fecaca; /* red-200 */
    color: #b91c1c; /* red-700 */
    padding: 10px 12px;
    border-radius: 6px;
}

/* Tooltip for Step 1.4 info icons */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-bubble {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    background: #ffffff;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    padding: 16px 18px;
    z-index: 50;
}
.tooltip-wrap:hover .tooltip-bubble,
.tooltip-wrap:focus-within .tooltip-bubble {
    display: block;
}
.tooltip-bubble::before, .tooltip-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
}
/* border outline arrow */
.tooltip-bubble::before {
    border-top: 8px solid #e5e7eb; /* gray-200 */
    bottom: -9px;
}
/* white fill arrow */
.tooltip-bubble::after {
    border-top: 8px solid #ffffff;
    bottom: -8px;
}
/* Mobile compact wizard and responsive improvements */
@media (max-width: 1024px) {
    .items-grid { grid-template-columns: 40px 1fr 1fr; }
}
@media (max-width: 768px) {
    /* Reserve space for sticky header/footer chrome */
    body {
        padding-top: calc(52px + env(safe-area-inset-top));
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }
    /* Collapse two/three column grids */
    #step1 .grid.grid-cols-2,
    #step1 .grid.grid-cols-3,
    #step2 .grid.grid-cols-2,
    #step2 .grid.grid-cols-3,
    #step3 .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    /* Ensure items that span 2 columns shrink to 1 column on mobile to avoid shorter boxes */
    #step2 .col-span-2 {
        grid-column: span 1 / span 1 !important;
    }
    /* Items editor compaction */
    .items-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
    #items-legend.items-grid { display: none !important; }

    /* Hide desktop bottom bars (use sticky footer on mobile) */
    #step1 .flex.items-end.justify-between,
    #step2 .flex.items-end.justify-between,
    #step3 .mt-\[40px\].flex.items-center.justify-between {
        display: none !important;
    }
    /* Utility to hide any element explicitly on mobile */
    .hide-on-mobile {
        display: none !important;
    }
}
/* Responsive tweaks */
@media (max-width: 1024px) { .items-grid { grid-template-columns: 40px 1fr 1fr; } }
@media (max-width: 768px) {
    .items-grid { grid-template-columns: 1fr; gap: 12px; }
    #items-legend.items-grid { display: none !important; }
    .route-info { padding: 12px; }
}
@media (max-width: 768px) { .stackable-box { position: static; margin-top: 10px; align-self: flex-end; } }
@media (max-width: 640px) {
    .tooltip-bubble { width: 260px; }
}
/* Responsive tweaks */
@media (max-width: 1024px) {
    /* items grid compresses */
    .items-grid {
        grid-template-columns: 40px 1fr 1fr;
    }
}
@media (max-width: 768px) {
    .items-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    #items-legend.items-grid {
        display: none !important;
    }
    .route-info { padding: 12px; }
}
@media (max-width: 640px) {
    .tooltip-bubble { width: 260px; }
}
/* Step 1.4 mobile layout */
@media (max-width: 768px) {
    #step-1-4 .services-list {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }
    #step-1-4 .service-row {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    #step-1-4 input[type="checkbox"]{
        width: 22px;
        height: 22px;
    }
}

.page {
    display: none;
}
.page.active {
    display: block;
}

/* Autocomplete container – min-width:0 prevents flex children from overflowing */
#sender-autocomplete-container,
#recipient-autocomplete-container,
[data-waypoint-container] {
    min-width: 0;
}

/* When address is confirmed (chip visible), clip overflow safely – dropdown not needed */
#sender-autocomplete-container.address-confirmed,
#recipient-autocomplete-container.address-confirmed,
[data-waypoint-container].address-confirmed {
    overflow: hidden;
}

/* Styling for NEW Google Places PlaceAutocompleteElement (2025 API) */
gmp-place-autocomplete {
    flex: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    font-family: 'Open Sans', sans-serif !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    color: #1f2937 !important;
    background: transparent !important;
    border: none !important;
    color-scheme: light !important;
}

/* Style the inner input of the web component */
gmp-place-autocomplete input {
    font-family: 'Open Sans', sans-serif !important;
    font-size: 16px !important;
    line-height: 20px !important;
    color: #1f2937 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    width: 100% !important;
    padding: 0 !important;
    box-shadow: none !important;
    -webkit-text-fill-color: #1f2937 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

gmp-place-autocomplete input::placeholder {
    color: #6b7280 !important;
    opacity: 1 !important;
}

/* Remove any default styling from the web component */
gmp-place-autocomplete::part(input) {
    background: transparent !important;
    border: none !important;
    color: #1f2937 !important;
    -webkit-text-fill-color: #1f2937 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

gmp-place-autocomplete::part(icon) {
    display: none !important;
}

/* Clear/X buttons for address fields */
.clear-address-btn,
.waypoint-clear-btn {
    display: none;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #6b7280;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.clear-address-btn:hover,
.waypoint-clear-btn:hover {
    background: #374151;
}

/* Show X button when address is confirmed */
.address-confirmed .clear-address-btn,
.address-confirmed .waypoint-clear-btn {
    display: flex !important;
}

/* Address chip text containment */
.address-chip {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==========================================
   ADDRESS DETAIL MODAL – Responsive Styles
   ========================================== */

.adm-dialog {
    background: #fff;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    margin: 24px auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.adm-header {
    background: #111827;
    padding: 24px 28px;
    border-radius: 12px 12px 0 0;
    position: relative;
}

.adm-body {
    padding: 24px 28px;
}

.adm-footer {
    display: flex;
    gap: 12px;
    padding: 0 28px 24px;
    flex-wrap: wrap;
}

.adm-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.adm-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: 'Open Sans', sans-serif;
}

/* Straße / Nr. row */
.adm-row-street {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* PLZ / Ort / Land row – desktop: 3 columns */
.adm-row-plz {
    display: grid;
    grid-template-columns: 120px 1fr 140px;
    gap: 12px;
    margin-bottom: 16px;
}

/* Kontakt row – desktop: 2 columns */
.adm-row-contact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---- Mobile breakpoint ---- */
@media (max-width: 639px) {
    .adm-dialog {
        margin: 8px auto;
        border-radius: 10px;
    }

    .adm-header {
        padding: 18px 20px;
        border-radius: 10px 10px 0 0;
    }

    .adm-body {
        padding: 18px 20px;
    }

    .adm-footer {
        padding: 0 20px 20px;
        flex-direction: column;
    }

    .adm-footer button {
        width: 100%;
        text-align: center;
    }

    .adm-footer button[style*="margin-left:auto"] {
        margin-left: 0 !important;
    }

    /* PLZ / Ort as 2 columns, Land full width below */
    .adm-row-plz {
        grid-template-columns: 1fr 1fr;
    }

    .adm-row-plz > div:nth-child(3) {
        grid-column: 1 / -1;
    }

    /* Kontakt stacks vertically */
    .adm-row-contact {
        grid-template-columns: 1fr;
    }
}

/* Step 2 layout base order */
.step2-contact-grid {
    grid-template-areas:
        "sender"
        "recipient"
        "waypoints";
}

.step2-contact-grid .step2-sender {
    grid-area: sender;
}

.step2-contact-grid .step2-recipient {
    grid-area: recipient;
}

.step2-contact-grid .step2-waypoints {
    grid-area: waypoints;
}

/* Step 2 desktop layout adjustments */
@media (min-width: 1024px) {
    .step2-contact-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "sender recipient"
            "waypoints waypoints";
    }

    .step2-contact-grid .step2-waypoints {
        display: grid;
        gap: 20px;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

.waypoint-drag-handle {
    border: none;
    background: transparent;
    cursor: grab;
    touch-action: none;
    color: #9ca3af;
}

.waypoint-drag-handle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.waypoint-dragging {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    cursor: grabbing;
}

.waypoint-placeholder {
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
}

body.waypoint-drag-active {
    user-select: none;
}

body.waypoint-drag-active .waypoint-drag-handle {
    cursor: grabbing;
}

/* Waypoints Mobile Optimization */
@media (max-width: 640px) {
    /* Zwischenstopp Container auf Mobile */
    #waypoints-container > div {
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    /* Waypoint Input Container - verhindert Overflow */
    #waypoints-container > div > div[id*="-container"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        box-sizing: border-box !important;
    }
    
    /* Remove Button volle Breite auf Mobile */
    #waypoints-container button[title*="entfernen"] {
        width: 100% !important;
        height: 44px !important;
        font-size: 18px !important;
        flex-shrink: 0 !important;
    }
    
    /* Add Waypoint Button auf Mobile */
    #add-waypoint-btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 12px 16px !important;
    }
    
    #add-waypoint-btn span:first-child {
        font-size: 20px !important;
    }

    .waypoint-wrapper .waypoint-drag-handle {
        width: 100% !important;
        height: 44px !important;
        justify-content: flex-start !important;
        padding-left: 8px !important;
        border-radius: 8px !important;
        background: #f3f4f6 !important;
    }
}

/* ============================================
   ISG Custom Alert Modal
   ============================================ */
.isg-alert-overlay {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    animation: isgAlertFadeIn 0.2s ease-out;
}
.isg-alert-overlay.active {
    display: flex;
}
.isg-alert-box {
    background: #ffffff;
    border-radius: 12px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    animation: isgAlertSlideUp 0.3s ease-out;
    overflow: hidden;
}
.isg-alert-header {
    background: #000000;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.isg-alert-header-icon {
    width: 32px;
    height: 32px;
    background: #e31d13;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 18px;
    flex-shrink: 0;
}
.isg-alert-header-text {
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
}
.isg-alert-header-bar {
    height: 4px;
    background: #e31d13;
}
.isg-alert-body {
    padding: 24px;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-line;
}
.isg-alert-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: center;
}
.isg-alert-btn {
    background: #e31d13;
    color: #ffffff;
    border: none;
    padding: 12px 48px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'Open Sans', sans-serif;
}
.isg-alert-btn:hover {
    background: #c91910;
}
@keyframes isgAlertFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes isgAlertSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
