/* ========================================
   Search with Dropdown
   ======================================== */
.search-with-dropdown {
    display: flex;
    gap: 0.5rem;
}

.search-type-select {
    flex-shrink: 0;
    width: 140px;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1f2937;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.search-type-select:focus {
    outline: none;
    border-color: #d97706;
    box-shadow: 0 0 0 0.2rem rgba(217, 119, 6, 0.15);
}

.search-type-select:hover {
    border-color: #d97706;
}

.autocomplete-wrapper {
    flex: 1;
    position: relative;
}

.patron-search-input-wrap {
    position: relative;
}

.patron-search-input-wrap .form-control {
    padding-right: 2rem;
}

.patron-search-spinner {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.9rem;
    pointer-events: none;
}

.autocomplete-results {
    max-height: 300px;  /* Shows ~5-6 results */
    overflow-y: auto;
}

.autocomplete-item-comments {
    font-size: 0.78rem;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    /* white-space: nowrap; */
    margin-top: 1px;
}


/* ========================================
   Patron Selection (By Name / Anonymous)
   ======================================== */
.patron-selection {
    background-color: #fefce8;
    border: 2px solid #eab308;
    border-radius: 0.5rem;
    padding: 1rem;
}


/* ========================================
   Patron Info Card
   ======================================== */
.patron-info-card {
    background-color: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: 0.5rem;
    padding: 1.25rem;
    height: 100%;
}

.patron-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #fbbf24;
    gap: 1rem;
}

.patron-info-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    flex: 1; /* Allow title to take available space */
    min-width: 0; /* Allow text to wrap if needed */
}


.edit-patron-link {
    color: #d97706;
    font-size: 0.9rem;
    text-decoration: none;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0; /* Prevent button from shrinking */
    white-space: nowrap; /* Prevent text wrapping */
}

.edit-patron-link:hover {
    color: #b45309;
    text-decoration: underline;
}

.patron-info-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.patron-info-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.patron-info-label {
    font-weight: 600;
    color: #6b7280;
    min-width: 100px;
    font-size: 0.9rem;
}

.patron-info-value {
    color: #1f2937;
    font-size: 0.9rem;
    flex: 1;
}

/* ========================================
   Visit History Card (matches Patron Info styling)
   ======================================== */

.visit-history-card {
    background-color: #f0fdf4 !important;
    border: 2px solid #86efac !important;
    border-radius: 0.5rem !important;
    padding: 1.25rem !important;
    height: 100%;
}

.visit-history-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 1rem !important;
    padding-bottom: 0.75rem !important;
    border-bottom: 1px solid #86efac !important;
    gap: 1rem !important;
}

.visit-history-title {
    margin: 0 !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: #1f2937 !important;
    flex: 1 !important; /* Allow title to take available space */
    min-width: 0 !important; /* Allow text to wrap if needed */
}

.view-patron-link {
    color: #15803d !important;
    font-size: 0.9rem !important;
    text-decoration: none !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    cursor: pointer !important;
    transition: color 0.2s !important;
    flex-shrink: 0 !important; /* Prevent link from shrinking */
    white-space: nowrap !important; /* Prevent text wrapping */
}

.view-patron-link:hover {
    color: #166534 !important;
    text-decoration: underline !important;
}

.visit-history-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
}

.visit-history-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
}

.visit-history-label {
    font-weight: 600 !important;
    color: #6b7280 !important;
    min-width: 140px !important;
    font-size: 0.9rem !important;
}

.visit-history-value {
    color: #1f2937 !important;
    font-size: 0.9rem !important;
    flex: 1 !important;
}

.visit-history-value strong {
    color: #15803d !important;
    font-weight: 600 !important;
}


/* ========================================
   Recent Visits Card
   ======================================== */
.recent-visits-card {
    background: white;
    padding: 1.75rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 2rem;
    overflow-x: hidden;
}

.recent-visits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.recent-visits-header h4 {
    font-size: 1.25rem;
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.view-all-btn {
    color: #d97706;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.view-all-btn:hover {
    color: #b45309;
}

/* Recent Visits List */
.recent-visits-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 600px;
    overflow-y: auto;
}

/* Custom scrollbar */
.recent-visits-list::-webkit-scrollbar {
    width: 6px;
}

.recent-visits-list::-webkit-scrollbar-track {
    background: #fefef9;
}

.recent-visits-list::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 3px;
}

.recent-visits-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Individual Visit Item */
.recent-visit-item {
    background-color: #fefef9;
    border-radius: 0.5rem;
    padding: 1rem;
    transition: all 0.2s;
    /* border: 1px solid transparent; */
    border: 1px solid #e5e7eb;
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.recent-visit-item:hover {
    background-color: #fffbeb;
    border-color: #fbbf24;
}

.visit-patron {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.patron-icon {
    font-size: 1.25rem;
}

.patron-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.visit-details {
    font-size: 0.8rem;
    color: #6b7280;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.visit-separator {
    margin: 0 0.25rem;
}

.visit-type-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-right: 4px;
    vertical-align: middle;
}

.visit-type-badge.pantry {
    background-color: #fff3e0;
    color: #e65100;
}

.visit-type-badge.food-truck {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.patron-history-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: auto;
    flex-shrink: 0;
}

.patron-history-badge-inline {
    margin-left: 0.4rem;
    vertical-align: middle;
}

.patron-history-badge.badge-returning {
    background-color: #e0e7ff;
    color: #4338ca;
    border: 1.5px solid #4338ca;
}

.patron-history-badge.badge-first-of-month {
    background-color: #fff3e0;
    color: #e65100;
    border: 1.5px solid #e65100;
}

.patron-history-badge.badge-new {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1.5px solid #2e7d32;
}


/* ========================================
   Age Groups Section
   ======================================== */

.age-groups {
    background-color: #fefce8;
    border: 2px solid #eab308;
    border-radius: 0.5rem;
    padding: 1rem;
}

.age-groups .form-label {
    color: #1f2937;
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-align: center;
    display: block;
}

/* Center the age group labels on all screens */
.age-groups .form-label-sm {
    text-align: center;
    display: block;
    margin-bottom: 0.5rem;
}

/* Center the numbers in the age input boxes on all screens */
.age-groups input[type="number"] {
    text-align: center;
}


/* ========================================
   Visit Type Checkboxes
   ======================================== */

.visit-type-checkboxes {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.visit-type-checkboxes .form-check {
    margin: 0;
}

/* ========================================
   Autocomplete Dropdown Results
   ======================================== */
.autocomplete-results .autocomplete-item {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.75rem;
}

.autocomplete-item-name {
    font-weight: 600;
    color: #1f2937;
    flex-shrink: 0;
}

.autocomplete-item-details {
    font-size: 0.875rem;
    color: #6b7280;
}

/* ========================================
   Modal Enhancements
   ======================================== */
.modal-content {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding: 1.25rem 1.5rem;
    background-color: #fefef9;
}

.modal-title {
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    color: #1f2937;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    background-color: #fefef9;
}

/* ========================================
   No Visits Message
   ======================================== */
.no-visits-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
    font-style: italic;
}

.no-visits-message p {
    margin: 0;
}



/* ========================================
   City/State Autocomplete Dropdown
   ======================================== */
.city-state-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    margin-top: 0.25rem;
}

.city-state-dropdown .city-state-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f3f4f6;
}

.city-state-dropdown .city-state-item:last-child {
    border-bottom: none;
}

.city-state-dropdown .city-state-item:hover {
    background-color: #fffbeb;
}

.city-state-dropdown .city-state-item.selected {
    background-color: #fef3c7;
}

.city-state-city {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.city-state-details {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.125rem;
}


/* ========================================
   Front-end Validation Errors
   ======================================== */
.field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 38, 38, 0.15) !important;
}

.error-message {
    display: block;
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.error-shake {
    animation: shake 0.4s;
}

#patron-card-error {
    margin-top: 1rem;
    animation: shake 0.4s;
}


/* ========================================
   Household Size Section
   ======================================== */

.mb-3:has(#id_household_size) {
    display: none !important;
}

/* Age Input Wrapper with +/- Buttons */
.age-input-wrapper {
    position: relative;
    display: block;
}

.age-btn {
    display: none; /* Hidden by default (desktop) */
}


/* Add to visit_form.css */

/* ========================================
   Custom Date Warning Banner
   ======================================== */
.custom-date-warning {
    background-color: #fee2e2 !important;
    border: 2px solid #dc2626 !important;
    border-radius: 0.5rem;
    color: #991b1b !important;
    font-size: 1rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    animation: slideDown 0.3s ease-out;
}

.custom-date-warning i {
    font-size: 1.2rem;
}

.custom-date-warning .alert-link {
    color: #7f1d1d !important;
    font-weight: 600;
    text-decoration: underline;
}

.custom-date-warning .alert-link:hover {
    color: #450a0a !important;
}

.custom-date-warning strong {
    margin-right: 0.25rem; /* Space after "Important:" and before date */
}



/* ========================================
   Comments + Submit Row
   ======================================== */
.comments-submit-row {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.comments-col {
    flex: 1;
}

.comments-col #id_comments {
    height: 100%;
    min-height: 52px;  /* roughly one line + padding */
    resize: vertical;
}

.submit-col {
    flex-shrink: 0;
    width: 180px;
}





#editCity[readonly],
#editState[readonly] {
    background-color: #f3f4f6;
    color: #9ca3af;
    pointer-events: none;
    cursor: default;
}



@media (hover: hover) {
    #clearByNameBtn:hover,
    #clearByIdBtn:hover {
        background-color: #6c757d;
        color: white;
        border-color: #6c757d;
    }
}

@media (hover: none) {
    #clearByNameBtn:hover,
    #clearByIdBtn:hover {
        background-color: transparent;
        color: #6c757d;
        border-color: #adb5bd;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}


/* ========================================
   Responsive Adjustments
   ======================================== */

/* Show buttons on mobile/tablet */
@media (max-width: 1024px) {
    .age-input-wrapper {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .age-input-wrapper input {
        flex: 1;
        text-align: center;
        font-size: 1.125rem;
        font-weight: 600;
    }
    
    .age-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 2px solid #eab308;
        background: white;
        color: #eab308;
        font-size: 1.5rem;
        font-weight: 700;
        border-radius: 0.375rem;
        cursor: pointer;
        transition: all 0.2s;
        padding: 0;
        line-height: 1;
        user-select: none;
        flex-shrink: 0;
    }
    
    .age-btn:active {
        background: #eab308;
        color: white;
        transform: scale(0.95);
    }
}

/* Lock column widths above 992px to prevent layout shift when patron card appears */
@media (min-width: 992px) {
    .demo-section .col-lg-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
        min-width: 0;
    }

    .demo-section .col-lg-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
        min-width: 0;
    }
}

/* Prevent form card content from pushing column wider */
.form-card {
    min-width: 0;
    overflow: hidden;
}


/* FIND and REPLACE your @media (max-width: 992px) block with: */
@media (max-width: 992px) {
    .recent-visits-card {
        position: static;
        margin-top: 2rem;
    }

    .recent-visits-list {
        max-height: 400px;
    }

    .col-lg-6:has(#patronInfoCard[style*="display: none"]),
    .col-lg-6:has(#visitCountSection[style*="display: none"]) {
        margin-bottom: 0 !important;
    }

    #patronInfoCard[style*="display: none"],
    #visitCountSection[style*="display: none"] {
        margin: 0 !important;
        padding: 0 !important;
    }
}


@media (max-width: 768px) {
    .search-with-dropdown {
        flex-direction: column;
    }
    
    .search-type-select {
        width: 100%;
    }
    
    /* Keep patron info header flexible for wrapping if needed */
    .patron-info-header {
        flex-wrap: wrap; /* Allow wrapping only if necessary */
    }
    
    /* Keep visit history header on single row */
    .visit-history-header {
        flex-wrap: nowrap !important; /* Force single row */
    }
    
    .visit-history-title {
        text-align: left !important; /* Keep left-aligned on mobile */
    }
    
    .patron-info-label {
        min-width: 80px;
        font-size: 0.85rem;
    }
    
    .patron-info-value {
        font-size: 0.85rem;
    }
    
    .visit-history-label {
        min-width: 100px;
        font-size: 0.85rem;
    }
    
    .visit-history-value {
        font-size: 0.85rem;
    }
    
    /* Remove height matching on mobile - let cards be natural height */
    .patron-info-card,
    .visit-history-card {
        height: auto;
    }
    
    .date-display-wrapper {
        max-width: 100%;
    }
    
    .calendar-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        width: 90%;
        max-width: 320px;
        opacity: 0;
    }
    
    .calendar-dropdown.show {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    .custom-date-warning {
        font-size: 0.9rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 576px) {
    .visit-details {
        flex-direction: column;
        gap: 0.125rem;
    }
    
    .visit-separator {
        display: none;
    }
    
    .patron-info-card {
        padding: 1rem;
    }
    
    .patron-info-name {
        font-size: 1rem;
    }
    
    .date-selector-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .date-selector-row .form-label {
        margin-bottom: 0.5rem;
    }
    
    .date-selector-row .date-display-wrapper {
        max-width: 100%;
        min-width: 0;
    }
    
    .visit-history-card {
        padding: 1rem;
    }
    
    .visit-history-title {
        font-size: 1rem;
    }

        .comments-submit-row {
        flex-direction: column;
    }
    .submit-col {
        width: 100%;
    }
}

@media (max-width: 400px), (min-width: 992px) and (max-width: 1200px) {
    .visit-history-row {
        flex-direction: column !important;
        gap: 0.125rem !important;
    }
    
    .visit-history-label {
        min-width: unset !important;
        font-size: 0.8rem !important;
        color: #9ca3af !important;
    }
    
    .visit-history-value {
        font-size: 0.875rem !important;
    }
}

@media (max-width: 500px) {
    #byIdSection > div {
        flex-wrap: wrap;
    }

    #byIdSection .text-muted {
        width: 100%;
        margin-top: 0.5rem;
    }
}


@media (min-width: 993px) {
    .col-lg-6:has(#patronInfoCard[style*="display: none"]),
    .col-lg-6:has(#visitCountSection[style*="display: none"]) {
        margin-bottom: 0 !important;
    }

    .row:has(#patronInfoCard[style*="display: none"]):has(#visitCountSection[style*="display: none"]) {
        margin-bottom: 0 !important;
    }
}