/* Custom styles for the mobile app */

/* CSS Custom Properties for viewport handling */
:root {
    --vh: 1vh;
    --mobile-vh: 1vh;
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    background-color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.container-fluid {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 0.5rem;
}

/* Mobile viewport height adjustments */
.vh-100-mobile {
    height: calc(var(--mobile-vh, 1vh) * 100);
}

/* Safe area adjustments for devices with notches */
@supports (padding: max(0px)) {
    .container-fluid {
        padding-top: max(0.5rem, var(--safe-area-inset-top));
        padding-bottom: max(0.5rem, var(--safe-area-inset-bottom));
        padding-left: max(0.5rem, env(safe-area-inset-left, 0.5rem));
        padding-right: max(0.5rem, env(safe-area-inset-right, 0.5rem));
    }
}

/* Override vh-100 on mobile devices */
@media screen and (max-width: 768px) and (orientation: portrait) {
    .vh-100 {
        height: calc(var(--mobile-vh, 1vh) * 100) !important;
    }
    
    /* Adjust container for mobile browsers with dynamic UI */
    .container-fluid {
        min-height: calc(var(--mobile-vh, 1vh) * 100);
    }
    
    /* Prevent horizontal scrolling on mobile */
    body {
        overflow-x: hidden;
    }
    
    /* Better touch handling */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
}

/* Ensure the Bootstrap column takes full height */
.row.flex-grow-1 .col-12 {
    height: 100%;
}

/* Screen management */
.screen {
    display: none;
    height: 100%;
}

.screen.active {
    display: block;
}

/* Card styling */
.card {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

/* Additional spacing for content-heavy screens */
#no-service-screen .card:last-child {
    margin-bottom: 0;
}

/* Ensure bingo screen accordion has proper spacing */
#bingo-screen .accordion {
    margin-bottom: 1rem;
}

/* Team screen spacing */
#team-screen .list-group {
    margin-bottom: 0;
}

/* Form styling */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #999999;
    padding: 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: #0085FC;
    box-shadow: 0 0 0 0.2rem rgba(0, 133, 252, 0.25);
}

.form-control::placeholder {
    color: #6C767D;
}

/* Button styling */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
}

.btn-primary {
    background-color: #0085FC;
    border-color: #0085FC;
}

.btn-primary:hover {
    background-color: #0066CC;
    border-color: #0066CC;
}

.btn-danger {
    background-color: #DB2843;
    border-color: #DB2843;
}

.btn-danger:hover {
    background-color: #C11E3A;
    border-color: #C11E3A;
}

.btn-link {
    text-decoration: none;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Alert styling */
.alert-warning {
    background-color: #FFBC26;
    border-color: #D89F20;
    color: #ffffff;
}

.alert-warning .alert-heading {
    background-color: #F7B625;
    margin: -1rem -1rem 1rem -1rem;
}

/* List group styling */
.list-group-item {
    border-color: #DFDFDF;
    padding: 1rem;
}

.list-group-item:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.list-group-item:last-child {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* Badge styling */
.badge.rounded-circle {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.bg-light.text-dark {
    background-color: #F8F9FA !important;
    color: #000000 !important;
    border: 1px solid #DEE2E6;
}

/* Progress bar styling */
.progress {
    height: 20px;
    background-color: #f6f6f6;
    border-radius: 4px;
}

.progress-bar {
    background-color: #0085FC;
}

/* Image placeholder styling */
.bg-info.bg-opacity-25 {
    background-color: #DDF3F9 !important;
    border: 1px solid #DFDFDF;
    color: #555555;
}

.bg-secondary {
    background-color: #868E96 !important;
}

/* Breadcrumb styling */
.breadcrumb {
    background-color: #E9ECEF;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

/* Navigation container background */
nav[aria-label="breadcrumb"] .d-flex {
    background-color: #E9ECEF;
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

/* Override breadcrumb styling when inside unified container */
nav[aria-label="breadcrumb"] .breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    color: #6C757D;
}

.breadcrumb-item.active {
    color: #6C757D;
}

/* Map styles */
#map {
    border-radius: 6px !important;
    overflow: hidden;
}

.maplibregl-canvas {
    border-radius: 6px;
}

.maplibregl-ctrl-group {
    border-radius: 4px;
    box-shadow: 0 0 10px 2px rgba(0,0,0,.1);
}

/* Map container responsive adjustments */
@media (max-width: 768px) {
    #map {
        height: 250px !important;
    }
}

@media (max-width: 576px) {
    #map {
        height: 200px !important;
    }
}

/* Modal styling */
.modal-content {
    border-radius: 8px;
    border: 1px solid #C8C8C8;
}

.modal-header {
    border-bottom: 1px solid #dddddd;
    padding: 1rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #dddddd;
    padding: 1rem 1.5rem;
}

.modal .btn {
    width: 100%;
}

/* Responsive design */
@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.75rem 1rem;
    }
    
    .btn-lg {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
    }
}

/* Mobile landscape orientation adjustments */
@media screen and (max-width: 812px) and (orientation: landscape) {
    .vh-100 {
        height: calc(var(--mobile-vh, 1vh) * 100) !important;
    }
    
    .container-fluid {
        min-height: calc(var(--mobile-vh, 1vh) * 100);
    }
    
    /* Reduce map height in landscape to leave more room for content */
    #map {
        height: 180px !important;
    }
}

/* iOS Safari specific adjustments */
@supports (-webkit-touch-callout: none) {
    @media screen and (max-width: 768px) {
        .vh-100 {
            height: calc(var(--mobile-vh, 1vh) * 100) !important;
        }
        
        .container-fluid {
            min-height: calc(var(--mobile-vh, 1vh) * 100);
            /* iOS Safari bounce fix */
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
        }
        
        /* Ensure scrollable content area */
        .row.flex-grow-1.overflow-scroll {
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }
    }
}

/* Chrome mobile specific adjustments */
@media screen and (max-width: 768px) {
    /* Handle Chrome mobile address bar behavior */
    @supports (height: 100dvh) {
        .vh-100 {
            height: 100dvh !important;
        }
        .container-fluid {
            min-height: 100dvh;
        }
    }
    
    /* Fallback for browsers without dvh support */
    @supports not (height: 100dvh) {
        .vh-100 {
            height: calc(var(--mobile-vh, 1vh) * 100) !important;
        }
        .container-fluid {
            min-height: calc(var(--mobile-vh, 1vh) * 100);
        }
    }
}

/* Custom checkbox styling */
.form-check-input:checked {
    background-color: #0085FC;
    border-color: #0085FC;
}

/* Text muted styling */
.text-muted {
    color: #6C767D !important;
}

/* Spacing utilities */
.mb-4 {
    margin-bottom: 1.5rem !important;
}

/* Card title styling */
.card-title {
    font-weight: 600;
}

/* Form label styling */
.form-label {
    font-weight: 500;
    color: #212529;
    margin-bottom: 0.5rem;
}

/* Bingo accordion styling */
.accordion-button {
    padding: 1rem;
    font-weight: 500;
}

.accordion-button:not(.collapsed) {
    background-color: #e7f3ff;
    border-color: #0085FC;
}

.accordion-button:focus {
    border-color: #0085FC;
    box-shadow: 0 0 0 0.25rem rgba(0, 133, 252, 0.25);
}

.accordion-button .badge {
    pointer-events: none;
}

.accordion-body {
    padding: 1rem;
}

/* Challenge badge styling */
.accordion-button .badge.rounded-circle {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.accordion-button .badge.rounded-pill {
    min-width: 1.5rem;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

/* Image placeholder styling */
.accordion-body .bg-info {
    border: 2px dashed #dee2e6;
    transition: all 0.3s ease;
}

.accordion-body .bg-info:hover {
    border-color: #0085FC;
    background-color: rgba(0, 133, 252, 0.1) !important;
}

/* Back button styling */
#back-button {
    border: none;
    background: none;
    color: #0085FC;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-button:hover {
    background-color: rgba(0, 133, 252, 0.1);
    color: #0056b3;
}

#back-button:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 133, 252, 0.25);
}

#back-button svg {
    width: 20px;
    height: 20px;
}

/* Navigation area */
nav[aria-label="breadcrumb"] {
    background-color: #f8f9fa;
}

/* Fix for log location screen flex container */
#log-location-screen .d-flex.flex-column {
    height: 100%;
}

/* ==========================
   Loading spinner + overlay
   ========================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1055; /* above modals backdrop but below modal dialog */
    color: #0085FC; /* spinner color via currentColor */
}

.loading-overlay.active { display: flex; }

.lds-roller,
.lds-roller div,
.lds-roller div:after { box-sizing: border-box; }
.lds-roller { display: inline-block; position: relative; width: 80px; height: 80px; }
.lds-roller div { animation: lds-roller 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; transform-origin: 40px 40px; }
.lds-roller div:after { content: " "; display: block; position: absolute; width: 7.2px; height: 7.2px; border-radius: 50%; background: currentColor; margin: -3.6px 0 0 -3.6px; }
.lds-roller div:nth-child(1) { animation-delay: -0.036s; }
.lds-roller div:nth-child(1):after { top: 62.62742px; left: 62.62742px; }
.lds-roller div:nth-child(2) { animation-delay: -0.072s; }
.lds-roller div:nth-child(2):after { top: 67.71281px; left: 56px; }
.lds-roller div:nth-child(3) { animation-delay: -0.108s; }
.lds-roller div:nth-child(3):after { top: 70.90963px; left: 48.28221px; }
.lds-roller div:nth-child(4) { animation-delay: -0.144s; }
.lds-roller div:nth-child(4):after { top: 72px; left: 40px; }
.lds-roller div:nth-child(5) { animation-delay: -0.18s; }
.lds-roller div:nth-child(5):after { top: 70.90963px; left: 31.71779px; }
.lds-roller div:nth-child(6) { animation-delay: -0.216s; }
.lds-roller div:nth-child(6):after { top: 67.71281px; left: 24px; }
.lds-roller div:nth-child(7) { animation-delay: -0.252s; }
.lds-roller div:nth-child(7):after { top: 62.62742px; left: 17.37258px; }
.lds-roller div:nth-child(8) { animation-delay: -0.288s; }
.lds-roller div:nth-child(8):after { top: 56px; left: 12.28719px; }
@keyframes lds-roller { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
