:root {
    --primary-color: #4285F4;
    --primary-hover: #3367D6;
    --secondary-color: #34A853;
    --danger-color: #EA4335;
    --warning-color: #FBBC04;
    --muted-color: #9AA0A6;
}

.page-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    color: #333;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: #666;
    margin: 0;
}

/* Search and Filter Section */
.search-filter-section {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.search-container {
    position: relative;
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 1.1rem;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filter-select {
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.filter-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
    outline: none;
}

/* Searchable Select Dropdown */
.searchable-select {
    position: relative;
    width: 100%;
}

.select-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.select-input:hover {
    border-color: var(--primary-color);
}

.searchable-select.active .select-input {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.searchable-select.disabled .select-input {
    background: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.6;
}

.select-text {
    color: #333;
    font-weight: 500;
}

.searchable-select.disabled .select-text {
    color: #6c757d;
}

.select-arrow {
    color: #6c757d;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.searchable-select.active .select-arrow {
    transform: rotate(180deg);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.searchable-select.active .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-search {
    position: relative;
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.dropdown-search i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 0.9rem;
}

.dropdown-search input {
    width: 100%;
    padding: 0.5rem 0.5rem 0.5rem 2rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.dropdown-search input:focus {
    border-color: var(--primary-color);
}

.dropdown-options {
    max-height: 200px;
    overflow-y: auto;
}

.dropdown-option {
    padding: 0.75rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 0.9rem;
    border-bottom: 1px solid #f8f9fa;
}

.dropdown-option:hover {
    background: rgba(66, 133, 244, 0.05);
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option.selected {
    background: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.location-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.location-toggle:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.location-toggle.disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Category Selection */
.category-selection {
    margin-top: 1rem;
}

.category-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
}

.category-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: #e9ecef transparent;
}

.category-buttons::-webkit-scrollbar {
    height: 4px;
}

.category-buttons::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 2px;
}

.category-buttons::-webkit-scrollbar-thumb {
    background: #e9ecef;
    border-radius: 2px;
}

.category-buttons::-webkit-scrollbar-thumb:hover {
    background: #dee2e6;
}

.category-btn {
    position: relative;
    padding: 1rem 0.75rem;
    border: 2px solid #e9ecef;
    background: white;
    color: #666;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 80px;
    min-width: 80px;
    touch-action: manipulation;
    flex-shrink: 0;
}

.category-image {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.category-text {
    text-align: center;
    line-height: 1.2;
    font-size: 0.75rem;
}

.category-btn.active .category-image {
    opacity: 1;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.category-btn:hover {
    border-color: var(--primary-color);
    background: rgba(66, 133, 244, 0.05);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.category-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.category-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.category-btn.active .category-icon {
    opacity: 1;
}

/* Different shapes for different categories */
.category-btn[data-shape="square"] .category-icon {
    border-radius: 3px;
}

.category-btn[data-shape="circle"] .category-icon {
    border-radius: 50%;
}

.category-btn[data-shape="diamond"] .category-icon {
    border-radius: 0;
    transform: rotate(45deg);
}

.category-btn[data-shape="triangle"] .category-icon {
    border-radius: 0;
    background: transparent;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid currentColor;
    width: 0;
    height: 0;
}

.category-btn.active[data-shape="triangle"] .category-icon {
    border-bottom-color: currentColor;
}

/* Responsive category buttons */
@media (max-width: 480px) {
    .category-buttons {
        gap: 0.5rem;
        padding-bottom: 0.75rem;
    }
    
    .category-btn {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    .category-image {
        width: 20px;
        height: 20px;
    }

    .category-icon {
        width: 14px;
        height: 14px;
    }

    .category-btn[data-shape="triangle"] .category-icon {
        border-left-width: 7px;
        border-right-width: 7px;
        border-bottom-width: 12px;
    }
}

/* Provider Cards */
.providers-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.provider-card {
    background: white;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
}

.provider-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(66, 133, 244, 0.15);
}

.provider-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.provider-image {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.provider-info {
    flex: 1;
}

.provider-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.provider-category {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.provider-location {
    font-size: 0.8rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.provider-area {
    font-size: 0.8rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.provider-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.provider-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stars {
    display: flex;
    gap: 0.125rem;
}

.star {
    color: #ffc107;
    font-size: 0.9rem;
}

.star.empty {
    color: #e9ecef;
}

.rating-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
}

.provider-distance {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
    cursor: help;
    position: relative;
}

.provider-distance .distance-info {
    color: #999;
    transition: opacity 0.2s ease;
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.7;
}

.provider-distance:hover .distance-info {
    opacity: 1;
}

/* Tooltip styles for distance info */
.provider-distance[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
    pointer-events: none;
}

.provider-distance[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    margin-bottom: -5px;
    pointer-events: none;
}

/* Provider Contact Information */
.provider-contact {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.contact-item i {
    color: var(--primary-color);
    font-size: 0.9rem;
    width: 16px;
}

.contact-link {
    color: #333;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.contact-link:hover {
    color: var(--primary-color);
}

.contact-link.hotline {
    color: var(--secondary-color);
    font-weight: 600;
}

.contact-link.hotline:hover {
    color: var(--primary-color);
}

/* Directions Button */
.directions-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    touch-action: manipulation;
}

.directions-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.directions-btn i {
    font-size: 0.9rem;
}

/* Loading and Empty States */
.loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-icon {
    font-size: 3rem;
    color: #e9ecef;
    margin-bottom: 1rem;
}

/* Results Counter */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}

.results-count {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.sort-options {
    font-size: 0.85rem;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Sort Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 0;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #333;
}

.modal-body {
    padding: 0 1.5rem 2rem;
}

.sort-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sort-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    min-height: 80px;
    height: 80px;
}

.sort-option:hover {
    border-color: var(--primary-color);
    background: rgba(66, 133, 244, 0.05);
}

.sort-option.active {
    border-color: var(--primary-color);
    background: rgba(66, 133, 244, 0.1);
}

.sort-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8f9fa;
}

.sort-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.sort-option.disabled .sort-icon {
    background: #dee2e6;
}

.sort-details {
    flex: 1;
}

.sort-details h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 0.25rem 0;
}

.sort-details p {
    font-size: 0.875rem;
    color: #666;
    margin: 0;
}

.sort-check {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sort-option.active .sort-check {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        margin: 0;
        box-shadow: none;
    }
    
    .app-main {
        padding: 1rem 0.75rem;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
    
    .provider-header {
        gap: 0.75rem;
    }
    
    .provider-image {
        width: 50px;
        height: 50px;
    }

    .provider-contact {
        flex-direction: column;
        gap: 0.5rem;
    }

    .directions-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* PWA Safe Area Support */
@supports (padding: max(0px)) {
    .app-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .app-main {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }

    .modal-content {
        padding-bottom: max(0, env(safe-area-inset-bottom));
    }
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.pagination-info {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e9ecef;
    background: white;
    color: #333;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-btn.disabled {
    background: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
    cursor: not-allowed;
}

.pagination-btn.disabled:hover {
    background: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
}

/* Responsive pagination */
@media (max-width: 480px) {
    .pagination-controls {
        padding: 1rem;
        margin-top: 1.5rem;
    }
    
    .pagination-buttons {
        gap: 0.25rem;
    }
    
    .pagination-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 35px;
    }
}

/* Location Loading Popup */
.location-loading-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.location-loading-popup.show {
    opacity: 1;
}

.loading-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.location-loading-popup.show .loading-content {
    transform: scale(1);
}

.loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 60px;
    height: 60px;
    top: 10px;
    left: 10px;
    border-top-color: #34a853;
    animation-delay: 0.2s;
}

.spinner-ring:nth-child(3) {
    width: 40px;
    height: 40px;
    top: 20px;
    left: 20px;
    border-top-color: #fbbc04;
    animation-delay: 0.4s;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h3 {
    color: #333;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.loading-content p {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: dots 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes dots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive loading popup */
@media (max-width: 480px) {
    .loading-content {
        padding: 1.5rem;
        max-width: 280px;
    }
    
    .loading-spinner {
        width: 60px;
        height: 60px;
        margin-bottom: 1rem;
    }
    
    .spinner-ring:nth-child(2) {
        width: 45px;
        height: 45px;
        top: 7.5px;
        left: 7.5px;
    }
    
    .spinner-ring:nth-child(3) {
        width: 30px;
        height: 30px;
        top: 15px;
        left: 15px;
    }
    
    .loading-content h3 {
        font-size: 1.1rem;
    }
    
    .loading-content p {
        font-size: 0.9rem;
    }
}
