:root {
    --branches-bg: #f9fafb;
    --branches-card-bg: #ffffff;
    --branches-text: #1f2937;
    --branches-border: #e5e7eb;
    --map-height: 500px;
}

:root[data-theme="dark"],
html[data-theme="dark"],
body.theme-dark {
    --branches-bg: #0f1729;
    --branches-card-bg: #1a2745;
    --branches-text: #e5e7eb;
    --branches-border: #2d3f5b;
}

.branches-section {
    padding: 3rem 0;
    background: var(--branches-bg);
    min-height: calc(100vh - 200px);
}

.branches-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--branches-card-bg);
    border: 2px solid var(--branches-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 70, 151, 0.1);
}

.search-box i {
    color: var(--text-sub);
    margin-right: 0.75rem;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--branches-text);
    font-size: 0.95rem;
    font-family: 'Cairo', sans-serif;
}

.search-box input::placeholder {
    color: var(--text-sub);
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-control {
    padding: 0.75rem 1rem;
    background: var(--branches-card-bg);
    border: 2px solid var(--branches-border);
    color: var(--text-sub);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Cairo', sans-serif;
}

.btn-control:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.btn-control.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-text {
    display: inline;
}

.map-container {
    margin-bottom: 2rem;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.branches-map {
    width: 100%;
    height: var(--map-height);
    border-radius: 1rem;
}

.leaflet-container {
    font-family: 'Cairo', sans-serif;
}

.branches-popup {
    border-radius: 0.5rem;
}

.leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    background: var(--branches-card-bg) !important;
    color: var(--branches-text) !important;
}

.leaflet-popup-tip {
    background: var(--branches-card-bg) !important;
}

.branches-list-container {
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.branches-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 4px 15px rgba(52, 70, 151, 0.2);
    animation: slideUp 0.6s ease;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.95rem;
    opacity: 0.9;
}

.branches-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    animation: fadeIn 0.6s ease 0.2s both;
}

.branch-card {
    background: var(--branches-card-bg);
    border: 1px solid var(--branches-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.branch-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(52, 70, 151, 0.15);
}

.branch-card.nearest {
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, rgba(52, 70, 151, 0.05), rgba(181, 182, 183, 0.05));
}

.branch-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.nearest-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.nearest-badge i {
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

.branch-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--branches-text);
    margin-bottom: 0.5rem;
}

.branch-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: var(--text-sub);
    font-size: 0.9rem;
}

.branch-info i {
    color: var(--primary);
    width: 16px;
    text-align: center;
    margin-top: 2px;
}

.branch-phone {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--branches-border);
    font-weight: 500;
}

.branch-phone i {
    color: var(--primary);
}

.branch-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--branches-border);
}

.branch-action-btn {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
}

.branch-action-btn:hover {
    background: var(--primary);
    color: white;
}

.branch-distance {
    background: rgba(52, 70, 151, 0.1);
    color: var(--primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin-top: 0.75rem;
}

.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-sub);
}

.no-results i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results p {
    font-size: 1.1rem;
}

.location-notice {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--branches-card-bg);
    border: 2px solid var(--primary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 45;
    max-width: 400px;
    animation: slideInUp 0.4s ease;
}

@keyframes slideInUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.notice-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.notice-content i {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.notice-content p {
    color: var(--branches-text);
    margin-bottom: 1rem;
}

.notice-content .btn {
    width: 100%;
}

.cta-branches {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.cta-content h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.cta-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .branches-controls {
        flex-direction: column;
    }

    .search-box {
        order: 2;
    }

    .control-buttons {
        order: 1;
        width: 100%;
        justify-content: flex-start;
    }

    .branches-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .branches-stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    :root {
        --map-height: 400px;
    }

    .location-notice {
        right: 1rem;
        bottom: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

@media (max-width: 600px) {
    .branches-section {
        padding: 1.5rem 0;
    }

    .branches-controls {
        gap: 0.5rem;
    }

    .search-box {
        min-width: auto;
        padding: 0.5rem 0.75rem;
    }

    .search-box i {
        margin-right: 0.5rem;
    }

    .control-buttons {
        gap: 0.25rem;
    }

    .btn-control {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .btn-text {
        display: none;
    }

    .branches-list {
        grid-template-columns: 1fr;
    }

    .branches-stats {
        grid-template-columns: 1fr;
    }

    :root {
        --map-height: 300px;
    }

    .branch-card {
        padding: 1rem;
    }

    .branch-name {
        font-size: 1.1rem;
    }

    .cta-content h2 {
        font-size: 1.5rem;
    }

    .cta-content p {
        font-size: 1rem;
    }

    .cta-buttons {
        flex-direction: column;
    }

    .cta-buttons .btn {
        width: 100%;
    }

    .location-notice {
        right: 0.5rem;
        bottom: 0.5rem;
        padding: 1rem;
        max-width: calc(100vw - 1rem);
    }
}