/* public/css/library-map.css */

/* ============================================
   RESET & BASE STYLES
   ============================================ */
.library-map-container {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text-dark: #1f2937;
    --text-medium: #4b5563;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-focus: #2563eb;
    --background: #f8fafc;
    --background-white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
    
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-dark);
    background: var(--background);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.library-map-container *,
.library-map-container *::before,
.library-map-container *::after {
    box-sizing: border-box;
}

/* ============================================
   CONTROLS SECTION
   ============================================ */
.library-map-controls {
    padding: 24px;
    background: var(--background-white);
    border-bottom: 1px solid var(--border-color);
}

/* ============================================
   FORM INPUT BASE STYLES (shared)
   ============================================ */
.library-input-base {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--background-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.library-input-base:hover {
    border-color: #d1d5db;
}

.library-input-base:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.library-input-base::placeholder {
    color: var(--text-muted);
}

/* ============================================
   SEARCH INPUT
   ============================================ */
.library-search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.library-search-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.library-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.library-search-icon svg {
    width: 20px;
    height: 20px;
}

.library-search-input {
    width: 100%;
    height: 52px;
    padding: 0 52px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--background-white);
    border: 2px solid var(--border-color);
    border-radius: 24px !important;
    transition: var(--transition);
}

.library-search-input:hover {
    border-color: #d1d5db;
}

.library-search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.library-search-input::placeholder {
    color: var(--text-muted);
}

.library-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
    z-index: 1;
}

.library-search-clear:hover {
    background: #e5e7eb;
    color: var(--text-dark);
}

.library-search-clear svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   SEARCH RESULTS DROPDOWN
   ============================================ */
.library-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
}

.library-search-results::-webkit-scrollbar {
    width: 6px;
}

.library-search-results::-webkit-scrollbar-track {
    background: transparent;
}

.library-search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.library-search-results-section {
    padding: 8px 0;
}

.library-search-results-section:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.library-search-results-title {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.library-search-result-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
}

.library-search-result-item:hover {
    background: var(--primary-light);
}

.library-search-result-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: var(--primary-color);
}

.library-search-result-icon.location {
    background: #fef3c7;
    color: #d97706;
}

.library-search-result-icon.map {
    background: #d1fae5;
    color: #059669;
}

.library-search-result-icon.address {
    background: #fce7f3;
    color: #db2777;
}

.library-search-result-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.library-search-result-title {
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.library-search-result-subtitle {
    font-size: 13px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   FILTERS
   ============================================ */
.library-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.library-filter-group {
    flex: 1;
    min-width: 200px;
}

.library-filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-medium);
    margin-bottom: 8px;
}

.library-filter-select {
    width: 100%;
    height: 48px;
    padding: 0 40px 0 16px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark);
    background-color: var(--background-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.library-filter-select:hover {
    border-color: #d1d5db;
}

.library-filter-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.library-filter-select option {
    padding: 8px;
}

.library-clear-filters {
    height: 48px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #dc2626;
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.library-clear-filters:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.library-clear-filters:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
}

/* ============================================
   MAP CONTENT LAYOUT
   ============================================ */
.library-map-content {
    display: flex;
    height: 600px;
    background: var(--background);
}

#library-map {
    flex: 1;
    min-height: 400px;
    z-index: 1;
}

/* ============================================
   SIDEBAR
   ============================================ */
.library-sidebar {
    width: 380px;
    background: var(--background-white);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.library-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.library-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.library-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 6px 14px;
    border-radius: 20px;
}

.library-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.library-list::-webkit-scrollbar {
    width: 6px;
}

.library-list::-webkit-scrollbar-track {
    background: transparent;
}

.library-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ============================================
   LIBRARY LIST ITEMS
   ============================================ */
.library-list-item {
    display: flex;
    padding: 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 8px;
    border: 2px solid transparent;
}

.library-list-item:hover {
    background: var(--background);
    border-color: var(--border-color);
}

.library-list-item.active {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.library-list-item-image {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    margin-right: 14px;
    flex-shrink: 0;
    background: var(--background);
}

.library-list-item-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--primary-light);
}

.library-list-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.library-list-item-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-dark);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-list-item-address {
    font-size: 13px;
    color: var(--text-light);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.library-list-item-address svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--text-muted);
}

.library-list-item-address span {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ============================================
   POPUP STYLES
   ============================================ */
.library-popup {
    min-width: 300px;
    max-width: 340px;
}
h4.library-popup-title {
font-size: 20px !important;
color: #222 !important;
    margin: 0 0 6px 0;
    font-weight: 600;
    line-height: 1;

}
.library-popup-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 16px;
}

.library-popup-image {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    margin-right: 14px;
    flex-shrink: 0;
    background: var(--background);
}

.library-popup-title-wrapper {
    flex: 1;
    min-width: 0;
}



.library-popup-location {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

.library-popup-body {
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.library-popup-address {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-medium);
    line-height: 1.4;
}

.library-popup-address svg {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 2px;
}

.library-popup-contact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.library-popup-contact > div {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.library-popup-contact svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.library-popup-contact a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.library-popup-contact a:hover {
    text-decoration: underline;
}

.library-popup-footer {
    display: flex;
    gap: 10px;
    padding-top: 16px;
}

.library-popup-footer a {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}

.library-popup-website {
    background: var(--background);
    color: var(--text-medium);
    border: 1px solid var(--border-color);
}

.library-popup-website:hover {
    background: var(--border-color);
    color: var(--text-dark);
}

.library-popup-details {
    background: var(--primary-color);
    color: white !important;
}

.library-popup-details:hover {
    background: var(--primary-hover);
}

/* ============================================
   CUSTOM MARKER
   ============================================ */
.library-marker-container {
    background: transparent !important;
    border: none !important;
}

.library-marker {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50% 50% 50% 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    border: 3px solid white;
}

.library-marker-inner {
    transform: rotate(45deg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-marker-inner svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   CLUSTER STYLES
   ============================================ */
.marker-cluster-small {
    background: rgba(37, 99, 235, 0.2);
}

.marker-cluster-small div {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.marker-cluster-medium {
    background: rgba(37, 99, 235, 0.3);
}

.marker-cluster-medium div {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.marker-cluster-large {
    background: rgba(37, 99, 235, 0.4);
}

.marker-cluster-large div {
    background: var(--primary-hover);
    color: white;
    font-weight: 600;
    font-size: 15px;
}

/* ============================================
   LOADING STATE
   ============================================ */
.library-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-light);
    text-align: center;
}

.library-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   NO RESULTS STATE
   ============================================ */
.library-no-results {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-light);
}

.library-no-results-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.8;
}

.library-no-results p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

/* ============================================
   LEAFLET POPUP OVERRIDE
   ============================================ */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md) !important;
    padding: 0 !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 20px !important;
    font-family: inherit !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.leaflet-popup-close-button {
    top: 12px !important;
    right: 12px !important;
    width: 28px !important;
    height: 28px !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    color: var(--text-light) !important;
    background: var(--background) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    line-height: 1 !important;
    transition: var(--transition) !important;
}

.leaflet-popup-close-button:hover {
    background: var(--border-color) !important;
    color: var(--text-dark) !important;
}

.leaflet-popup-tip {
    box-shadow: var(--shadow-md) !important;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1024px) {
    .library-sidebar {
        width: 320px;
    }
}

@media (max-width: 900px) {
    .library-map-content {
        flex-direction: column;
        height: auto;
    }
    
    #library-map {
        height: 450px !important;
    }
    
    .library-sidebar {
        width: 100%;
        height: 350px;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

@media (max-width: 640px) {
    .library-map-controls {
        padding: 16px;
    }
    
    .library-search-wrapper {
        margin-bottom: 16px;
    }
    
    .library-search-input {
      width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px !important;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    }
    
    .library-filters {
        flex-direction: column;
        gap: 12px;
    }
    
    .library-filter-group {
        min-width: 100%;
    }
    
    .library-filter-select {
        height: 48px;
        font-size: 16px;
    }
    
    .library-clear-filters {
        width: 100%;
        justify-content: center;
    }
    
    #library-map {
        height: 350px !important;
    }
    
    .library-sidebar {
        height: 300px;
    }
    
    .library-sidebar-header {
        padding: 16px;
    }
    
    .library-list {
        padding: 8px;
    }
    
    .library-list-item {
        padding: 12px;
    }
    
    .library-list-item-image {
        width: 56px;
        height: 56px;
    }
    
    .library-popup {
        min-width: 260px;
        max-width: 300px;
    }
    
    .leaflet-popup-content {
        margin: 16px !important;
    }
}

@media (max-width: 480px) {
    .library-map-container {
        border-radius: 0;
    }
    
    .library-popup-header {
        flex-direction: column;
    }
    
    .library-popup-image {
        width: 100%;
        height: 120px;
        margin-right: 0;
        margin-bottom: 12px;
    }
    
    .library-popup-footer {
        flex-direction: column;
    }
}

/* ============================================
   DARK MODE SUPPORT (optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    .library-map-container.dark-mode {
        --text-dark: #f9fafb;
        --text-medium: #e5e7eb;
        --text-light: #9ca3af;
        --text-muted: #6b7280;
        --border-color: #374151;
        --background: #111827;
        --background-white: #1f2937;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.library-search-input:focus-visible,
.library-filter-select:focus-visible,
.library-clear-filters:focus-visible,
.library-list-item:focus-visible,
.library-search-clear:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .library-map-controls,
    .library-search-wrapper,
    .library-filters {
        display: none !important;
    }
    
    .library-map-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}