/**
 * Add Location Flyup Sheet and Modal Styles
 * Styles for the submission form, modals, and related UI components
 */

:root {
    --christmas-red: #c41e3a;
    --christmas-green: #2e7d32;
    --christmas-gold: #ffd700;
    --deep-forest: #1a472a;
}

/* Add Location Flyup Sheet Styles */
#addlocation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10002;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

#addlocation.open {
    transform: translateY(0);
}

#addlocation .sheet-close-btn:hover {
    color: #c41e3a;
}

#addlocation .action-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

#addlocation .btn-success:hover {
    background: #2e7d32 !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

/* Photo upload buttons */
#addlocation .btn-outline-success {
    background: white !important;
    color: #2e7d32 !important;
    border: 2px solid #2e7d32 !important;
    font-weight: 600;
    border-radius: 50px;
    transition: all 0.3s ease;
}

#addlocation .btn-outline-success:hover {
    background: #2e7d32 !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

/* Responsive adjustments for submission sheet - Full width on all screens */
@media (min-width: 768px) {
    #addlocation {
        /* Keep full width on desktop too */
        left: 0;
        right: 0;
        transform: translateY(100%);
    }
    
    #addlocation.open {
        transform: translateY(0);
    }
}

@media (max-width: 576px) {
    #addlocation .action-sheet-content {
        padding: 16px;
    }
}

/* How It Works Modal Content */
.step-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--christmas-gold);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: start;
    text-align: left;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-title {
    font-weight: 600;
    color: var(--christmas-red);
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.step-description {
    color: #555;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Help button styling */
.help-button-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-button-wrapper .btn-link {
    background: none !important;
    border: none !important;
    text-decoration: none !important;
    color: #2e7d32 !important;
    transition: all 0.2s ease;
}

.help-button-wrapper .btn-link:hover {
    transform: translateY(-4px) scale(1.1);
    color: #1b5e20 !important;
}

.help-button-wrapper .btn-link:focus {
    box-shadow: none !important;
    outline: none !important;
}

.help-button-wrapper .btn-link:focus-visible {
    outline: 3px solid #2e7d32 !important;
    outline-offset: 2px;
}

/* Help Modal Styles */
#helpModal .modal-body h6 {
    text-align: center;
}

#helpModal .modal-body > div:nth-child(2) p {
    text-align: left;
    font-size: 1rem;
}

/* Support SparkleTour button - match support chip style */
#helpModal .btn-success {
    display: inline-flex !important;
    align-items: center !important;
    padding: 0.5rem 0.9rem !important;
    border-radius: 999px !important;
    background: #c41e3a !important;
    border: none !important;
    color: white !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    text-decoration: none !important;
    box-shadow: 0 6px 20px rgba(196, 30, 58, 0.4) !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

#helpModal .btn-success:hover,
#helpModal .btn-success:focus {
    background: #a01729 !important;
    color: white !important;
    text-decoration: none !important;
    box-shadow: 0 8px 24px rgba(196, 30, 58, 0.5) !important;
    transform: translateY(-4px) scale(1.1) !important;
    outline: none !important;
}

#helpModal .btn-success:active {
    transform: translateY(-2px) scale(1.05) !important;
}

/* Social media buttons - red style */
#helpModal .btn-primary,
#helpModal .btn-danger {
    background: white !important;
    color: #c41e3a !important;
    border: 2px solid #c41e3a !important;
    font-weight: 600;
    border-radius: 50px;
    text-decoration: none !important;
    transition: all 0.3s ease;
}

#helpModal .btn-primary:hover,
#helpModal .btn-primary:focus,
#helpModal .btn-danger:hover,
#helpModal .btn-danger:focus {
    background: #c41e3a !important;
    color: white !important;
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196, 30, 58, 0.3);
    outline: none !important;
}

/* Modal Positioning - Top of Screen */
.modal-dialog {
    margin: 0.5rem auto;
    max-width: 700px;
    width: 95%;
    position: relative;
    top: 0;
}

@media (min-width: 768px) {
    .modal-dialog {
        max-width: 750px;
        margin: 1rem auto;
    }
}

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, 0);
}

.modal.show .modal-dialog {
    transform: translate(0, 0);
}

.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-height: none;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: linear-gradient(140deg,rgba(196, 30, 58, 1) 0%, rgba(30, 121, 44, 1) 100%);
    color: white;
    border-bottom: 2px solid var(--christmas-gold);
    padding: 0.875rem 1rem;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-title {
    font-weight: 700;
    font-size: 1.125rem;
}

.modal-body {
    padding: 1rem 1.25rem;
    overflow-y: visible !important;
    flex: 1 1 auto;
    max-height: none !important;
}

/* Allow modal to scroll as a whole on small screens */
@media (max-height: 650px) {
    body.modal-open {
        overflow-y: auto !important;
    }
    
    .modal-dialog {
        margin: 0.25rem auto;
    }
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

/* Form Styling */
.form-label {
    font-weight: 600;
    color: var(--christmas-green);
    margin-bottom: 0.35rem;
    text-align: left;
    display: block;
    font-size: 0.9rem;
}

/* Reduce spacing between form groups */
.mb-3 {
    margin-bottom: 0.875rem !important;
}

/* Compact row spacing */
.row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.row > [class*='col-'] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Form animation for submission */
#addlocationform {
    transition: opacity 0.4s ease-out, max-height 0.4s ease-out, margin 0.4s ease-out;
    max-height: 5000px;
    overflow: hidden;
}

#addlocationform.form-submitting {
    opacity: 0;
    max-height: 0;
    margin: 0;
    pointer-events: none;
}

/* Loading spinner */
#loading-spinner {
    display: none;
    text-align: center;
    padding: 2rem;
}

#loading-spinner.show {
    display: block;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Ensure thanks message is visible and prominent when it has content */
#thanks:not(:empty) {
    min-height: 60px;
    margin-bottom: 1rem;
}

#thanks:empty {
    display: none;
}

.form-control {
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    padding: 0.75rem;
    transition: border-color 0.3s ease;
    height: auto;
}

input.form-control {
    height: calc(1.5em + 0.75rem + 4px);
}

textarea.form-control {
    height: auto;
}

.form-control:focus {
    border-color: var(--christmas-green);
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.15);
}

.btn-success {
    background: #dc3545;
    border: none;
    padding: 0.625rem 1.75rem;
    font-weight: 600;
    border-radius: 50px;
    font-size: 0.95rem;
}

.btn-success:hover {
    background: #c82333;
}

/* Compact feature checkboxes */
.feature-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
}

.feature-checkboxes .checkbox {
    margin: 0;
    font-size: 0.85rem;
}

.feature-checkboxes label {
    margin: 0;
    font-weight: normal;
}

/* Compact photo preview */
#photo-preview img {
    max-height: 120px !important;
}

#photo-preview .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Google Places Autocomplete - Must be above flyup sheet */
.pac-container {
    z-index: 10003 !important;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.pac-item {
    padding: 8px 12px !important;
    cursor: pointer !important;
}

.pac-item:hover {
    background-color: #f0f0f0 !important;
}

.pac-item-query {
    font-size: 14px !important;
}

/* Select2 Optimizations for City Selector - All Devices */

/* Ensure Select2 dropdown renders within the scrollable content area */
.select2-container--open .select2-dropdown--below {
    border-top: none !important;
}

.select2-container--open .select2-dropdown--above {
    border-bottom: none !important;
}

/* Allow dropdown to take full available height */
.select2-dropdown {
    max-height: none !important;
}

.select2-results {
    max-height: 50vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

.select2-results__options {
    max-height: 50vh !important;
    overflow-y: auto !important;
}

/* Better spacing for all devices */
#citySelectorSheet .select2-container .select2-selection--single {
    min-height: 44px !important;
    padding: 10px !important;
}

#citySelectorSheet .select2-container .select2-selection__rendered {
    line-height: 24px !important;
    padding-left: 10px !important;
}

#citySelectorSheet .select2-container .select2-selection__arrow {
    height: 42px !important;
}

#citySelectorSheet .select2-results__option {
    padding: 10px 14px !important;
}

/* Desktop: Style optgroup labels for better province visibility */
#citySelectorSheet .select2-results__group {
    font-weight: 700 !important;
    color: var(--christmas-red) !important;
    background: #f8f9fa !important;
    padding: 8px 14px !important;
    font-size: 0.9rem !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
}

/* Desktop: Set explicit height */
@media (min-width: 768px) {
    #citySelectorSheet {
        height: 90vh !important;
        max-height: 90vh !important;
    }
    
    /* Ensure Select2 dropdown fits within desktop flyup */
    #citySelectorSheet .select2-results {
        max-height: 60vh !important;
    }
    
    #citySelectorSheet .select2-results__options {
        max-height: 60vh !important;
    }
}

/* Tablet and smaller screens - reduce dropdown height */
@media (max-width: 1024px) {
    #citySelectorSheet .select2-results {
        max-height: 40vh !important;
    }
    
    #citySelectorSheet .select2-results__options {
        max-height: 40vh !important;
    }
}

/* Small screens - further reduce dropdown height */
@media (max-height: 700px) {
    #citySelectorSheet .select2-results {
        max-height: 30vh !important;
    }
    
    #citySelectorSheet .select2-results__options {
        max-height: 30vh !important;
    }
}

/* Mobile: Use native select, simpler styling */
@media (max-width: 767px) {
    /* Taller flyup on mobile */
    #citySelectorSheet {
        height: 70vh !important;
        max-height: 70vh !important;
    }
    
    /* Style native select on mobile */
    #citySelector {
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 14px !important;
        min-height: 52px !important;
        border: 2px solid #e0e0e0 !important;
        border-radius: 8px !important;
        background-color: white !important;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px !important;
    }
    
    /* Style optgroups in native select */
    #citySelector optgroup {
        font-weight: 700;
        color: var(--christmas-red);
        font-size: 0.95rem;
        padding: 8px 0;
    }
    
    #citySelector option {
        padding: 12px 16px;
        font-size: 16px;
    }
}