/* ═══════════════════════════════════════════════════════════════════════════
   GdzieCwiczyc.pl — Modern CSS with Glassmorphism
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --accent: #10B981;
    --accent-light: #34D399;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg: #F0F2F5;
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --text: #1F2937;
    --text-muted: #6B7280;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
    backdrop-filter: blur(20px);
    background: rgba(17, 24, 39, 0.9) !important;
    z-index: 1050;
    padding: 0.4rem 0.75rem;
    height: 48px;
}

.navbar-brand {
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.navbar-actions {
    flex-shrink: 0;
    flex-wrap: nowrap !important;
}

/* ─── Search Bar ──────────────────────────────────────────────────────────── */
.search-bar-container {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    z-index: 1040;
    padding: 0.6rem 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.3);
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.search-input-group .form-control {
    border-radius: 50px;
    border: 2px solid transparent;
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    transition: var(--transition);
}

.search-input-group .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.search-input-group .btn {
    border-radius: 50px;
    padding: 0.7rem 1.5rem;
    font-weight: 600;
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transition: var(--transition);
}

.search-input-group .btn:hover {
    background: var(--accent-light);
    transform: scale(1.02);
}

/* Suggestions dropdown */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1060;
    display: none;
    margin-top: 4px;
}

.suggestions-dropdown.active {
    display: block;
}

.suggestion-item {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
    font-size: 0.9rem;
}

.suggestion-item:hover,
.suggestion-item.suggestion-active {
    background: #EEF2FF;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* ─── Main Content ────────────────────────────────────────────────────────── */
.main-content {
    margin-top: 110px;
    padding-bottom: 60px;
}

/* ─── Map ─────────────────────────────────────────────────────────────────── */
.map-container {
    position: sticky;
    top: 110px;
    height: calc(100vh - 160px);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 1;
}

.map-container .leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

/* Custom numbered markers */
.gym-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
    border: 2px solid white;
    transition: var(--transition);
}

.gym-marker:hover {
    transform: scale(1.2);
}

/* Fix #27b: Highlighted marker — smooth CSS class transition, no setIcon() */
.gym-marker-highlighted {
    background: #f59e0b !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.3), 0 4px 12px rgba(245, 158, 11, 0.5) !important;
}

.search-marker {
    background: var(--danger) !important;
    width: 16px;
    height: 16px;
    border: 3px solid white;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ─── Stats Bar — Fix #6: z-index above search bar ─────────────────────── */
.stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10;
}

.stats-text {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sort-select {
    width: auto;
    min-width: 140px;
}

.sort-dir-btn {
    font-size: 1.1rem;
    font-weight: bold;
    padding: 0.15rem 0.5rem;
    line-height: 1;
    border-color: var(--border-color);
    transition: all 0.2s;
}

.sort-dir-btn.sort-desc {
    color: #6c757d;
    border-color: #6c757d;
}

/* ─── Results Grid ────────────────────────────────────────────────────────── */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Result Card ─────────────────────────────────────────────────────────── */
.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity 0.3s;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.result-card:hover::before {
    opacity: 1;
}

.card-rank {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.card-class-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
    padding-right: 40px;
}

.card-time {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* Fix #5: Duration inline next to time */
.card-duration-inline {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
}

.card-date {
    font-size: 0.9rem;
    color: var(--text);
}

/* Fix #5: Day of week styling */
.card-day-of-week {
    font-weight: 600;
    color: var(--primary);
}

.card-club {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 0.5rem;
}

.card-club-rank {
    color: var(--primary);
    font-weight: 700;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.card-meta-item {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-meta-item i {
    margin-right: 0.25rem;
}

.card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.card-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.badge-category {
    background: #EEF2FF;
    color: var(--primary);
}

.badge-dyscyplina {
    background: #F0FDF4;
    color: #166534;
}

.badge-intensity {
    background: #FFF7ED;
    color: #9A3412;
}

.badge-free {
    background: #ECFDF5;
    color: var(--accent);
}

.badge-card {
    background: #EFF6FF;
    color: #1D4ED8;
}

.badge-link {
    background: var(--primary);
    color: white;
}

.badge-link:hover {
    background: var(--primary-dark);
    color: white;
}

.card-distance {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.card-address {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.card-trainer {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.card-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── Floating Filters Panel ──────────────────────────────────────────────── */
.filters-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1030;
    width: 340px;
    max-height: calc(100vh - 180px);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    transition: var(--transition);
    overflow: hidden;
}

.filters-panel.collapsed {
    width: auto;
    max-height: 50px;
}

.filters-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.filters-header:hover {
    background: var(--primary-dark);
}

.filters-panel.collapsed .filters-header {
    border-radius: 25px;
}

.filters-chevron {
    margin-left: auto;
    transition: transform 0.3s;
}

.filters-panel:not(.collapsed) .filters-chevron {
    transform: rotate(180deg);
}

.filters-body {
    display: none;
    padding: 0.5rem;
}

.filters-panel:not(.collapsed) .filters-body {
    display: block;
}

.filters-scroll {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.filters-scroll::-webkit-scrollbar {
    width: 4px;
}

.filters-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

/* ─── Filter Groups ───────────────────────────────────────────────────────── */
.filter-group {
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    font-size: 0.85rem;
}

.filter-header:hover {
    background: rgba(255, 255, 255, 0.8);
}

.filter-label {
    font-weight: 600;
    color: var(--text);
}

.filter-summary {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.filter-content {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* ─── Checkbox list ───────────────────────────────────────────────────────── */
.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
    cursor: pointer;
}

.checkbox-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ─── Filter search input (Fix #10) ───────────────────────────────────────── */
.filter-search {
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.6);
    transition: var(--transition);
}

.filter-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ─── Date Calendar ───────────────────────────────────────────────────────── */
.date-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
    font-size: 0.8rem;
}

.day-header {
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.3rem;
    font-size: 0.7rem;
}

.day-cell {
    padding: 0.4rem;
    border-radius: 4px;
    cursor: default;
    transition: var(--transition);
}

.day-cell.available {
    cursor: pointer;
    background: #EEF2FF;
    color: var(--primary);
    font-weight: 500;
}

.day-cell.available:hover {
    background: #C7D2FE;
}

.day-cell.selected {
    background: var(--primary) !important;
    color: white !important;
    font-weight: 700;
}

.day-cell.disabled {
    color: #D1D5DB;
    background: transparent;
}

/* ─── Range Slider ────────────────────────────────────────────────────────── */
.range-slider {
    padding: 0.5rem 0;
}

.range-slider .form-range {
    width: 100%;
}

/* ─── Pill buttons ────────────────────────────────────────────────────────── */
.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.pill-btn {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
}

.pill-btn:hover {
    background: #EEF2FF;
    border-color: var(--primary-light);
}

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

.pill-btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.footer {
    background: rgba(17, 24, 39, 0.9);
    color: white;
    padding: 1rem;
    font-size: 0.85rem;
}

.footer a {
    color: white;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--primary-light);
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .filters-panel {
        width: calc(100% - 20px);
        left: 10px;
        bottom: 10px;
    }

    .filters-panel:not(.collapsed) {
        width: calc(100% - 20px);
    }

    .main-content {
        margin-top: 110px;
    }

    .map-container {
        height: 250px;
        position: sticky;
        top: 110px;
        z-index: 10;
    }

    .stats-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .sort-controls {
        width: 100%;
        justify-content: flex-end;
    }
}
