* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Search bar */
#search-bar {
    background: #fff;
    padding: 12px 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
}

#search-form {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 500px;
}

#eircode-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

#eircode-input:focus {
    border-color: #009b50;
}

#search-btn {
    padding: 8px 20px;
    background: #009b50;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

#search-btn:hover {
    background: #007a3e;
}

#search-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#search-status {
    font-size: 13px;
    color: #666;
}

#search-status:empty {
    display: none;
}

#search-status.error {
    color: #d32f2f;
}

/* Recenter button */
#recenter-btn {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: all 0.2s;
    flex-shrink: 0;
}

#recenter-btn:hover {
    border-color: #009b50;
    color: #009b50;
}

/* Scrollable bar wrapper */
.scroll-bar-wrap {
    position: relative;
    z-index: 1000;
}

#filter-bar-wrap {
    z-index: 10000;
}

.scroll-bar-wrap .scroll-arrow {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    border: none;
    padding: 0;
    font-size: 22px;
    font-weight: 700;
    color: #555;
    transition: opacity 0.2s;
}

.scroll-bar-wrap .scroll-arrow.scroll-left {
    left: 0;
    background: linear-gradient(to right, #f5f5f5 60%, transparent);
}

.scroll-bar-wrap .scroll-arrow.scroll-right {
    right: 0;
    background: linear-gradient(to left, #f5f5f5 60%, transparent);
}

.scroll-bar-wrap .scroll-arrow.scroll-hidden {
    opacity: 0;
    pointer-events: none;
}

#filter-bar-wrap .scroll-arrow.scroll-left {
    background: linear-gradient(to right, #fafafa 60%, transparent);
}

#filter-bar-wrap .scroll-arrow.scroll-right {
    background: linear-gradient(to left, #fafafa 60%, transparent);
}

/* Category bar */
#category-bar {
    background: #f5f5f5;
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

#category-bar::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.cat-btn:hover {
    background: #e8f5e9;
    border-color: #009b50;
}

.cat-btn.active {
    background: #009b50;
    color: #fff;
    border-color: #009b50;
}

/* Map */
#map {
    flex: 1;
    z-index: 1;
}

/* Bottom drawer */
#drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 25vh;
    background: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    border-radius: 12px 12px 0 0;
}

#drawer.hidden {
    transform: translateY(100%);
}

#drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    cursor: grab;
}

#drawer-title {
    font-weight: 600;
    font-size: 15px;
}

#drawer-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

#drawer-content {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

/* Drawer list items */
.drawer-item {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-item:hover,
.drawer-item.highlighted {
    background: #e8f5e9;
}

.drawer-item > div:first-child {
    flex: 1;
    min-width: 0;
}

.drawer-item-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-item-detail {
    font-size: 12px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-item-distance {
    font-size: 13px;
    color: #999;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
    min-width: 50px;
}

/* PPR specific */
.drawer-item-price {
    font-weight: 600;
    color: #009b50;
    white-space: nowrap;
}

/* Transport agencies */
.drawer-item-agencies {
    font-size: 12px;
    color: #555;
    margin-top: 2px;
}

/* School level badge */
.school-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    margin-left: 6px;
}

.school-badge.primary_mainstream { background: #1976d2; }
.school-badge.primary_special { background: #f57c00; }
.school-badge.post_primary { background: #c62828; }

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Override hidden for drawer (use transform instead) */
#drawer.hidden {
    display: flex !important;
    transform: translateY(100%);
}

/* Leaflet popup overrides */
.leaflet-popup-content {
    font-size: 13px;
    line-height: 1.4;
}

/* Price label on map */
.price-label {
    background: #fff;
    border: 1px solid #009b50;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #009b50;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Directions button */
.directions-btn {
    background: none;
    border: 1px solid #009b50;
    border-radius: 50%;
    color: #009b50;
    cursor: pointer;
    width: 30px;
    height: 30px;
    padding: 0;
    margin-left: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.directions-btn:hover {
    background: #009b50;
    color: #fff;
}

.directions-btn svg {
    width: 16px;
    height: 16px;
}

/* Green house marker */
.house-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mode selector */
.mode-selector {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.mode-btn {
    padding: 5px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: #009b50;
}

.mode-btn.active {
    background: #009b50;
    color: #fff;
    border-color: #009b50;
}

/* Route summary */
.route-summary {
    padding: 10px 16px;
    background: #f0f9f4;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* Transit route options */
.transit-options {
    padding: 0;
}

.transit-option {
    padding: 10px 16px;
    border-bottom: 2px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.15s;
}

.transit-option:hover {
    background: #f5f5f5;
}

.transit-option.active {
    background: #f0f9f4;
    border-left: 3px solid #009b50;
    cursor: default;
}

.transit-option-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.transit-option-time {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.transit-option-distance {
    font-size: 12px;
    color: #999;
}

.transit-option-lines {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.transit-line-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.transit-line-walk {
    font-size: 12px;
    color: #666;
}

.transit-line-arrow {
    color: #bbb;
    font-size: 12px;
    margin: 0 2px;
}

.transit-option-times {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Route steps */
.route-steps {
    padding: 0;
    list-style: none;
    margin-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.route-step {
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    gap: 8px;
}

.route-step-transit {
    display: block;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.route-step-transit-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.route-step-transit-stops {
    font-size: 12px;
    color: #555;
    padding-left: 4px;
    line-height: 1.6;
}

.transit-stop-from::before,
.transit-stop-to::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.transit-stop-from::before {
    background: #009b50;
}

.transit-stop-to::before {
    background: #d32f2f;
}

.route-step-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: #009b50;
}

.route-step-text {
    flex: 1;
}

.route-step-detail {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Back button */
.back-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 8px 16px;
    padding: 8px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #e8e8e8;
}

/* Directions loading */
.directions-loading {
    padding: 20px 16px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Deprivation legend */
.deprivation-legend {
    background: white;
    padding: 8px 10px;
    border-radius: 4px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    font-size: 12px;
    line-height: 20px;
}

.deprivation-legend span {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 2px;
}

/* Filter bar */
#filter-bar {
    background: #fafafa;
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

#filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-dropdown {
    position: relative;
    flex-shrink: 0;
}

.filter-btn {
    padding: 5px 12px;
    border: 1px solid #ccc;
    border-radius: 16px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-btn:hover {
    border-color: #009b50;
}

.filter-btn.has-selection {
    background: #e8f5e9;
    border-color: #009b50;
    color: #009b50;
}

.filter-chevron {
    font-size: 10px;
    transition: transform 0.2s;
}

.filter-dropdown.open .filter-chevron {
    transform: rotate(180deg);
}

.filter-dropdown-menu {
    position: fixed;
    min-width: 180px;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    padding: 4px 0;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
    white-space: nowrap;
}

.filter-option:hover {
    background: #f5f5f5;
}

.filter-option.disabled {
    opacity: 0.4;
    cursor: default;
}

.filter-option.disabled:hover {
    background: transparent;
}

.filter-option input[type="checkbox"] {
    accent-color: #009b50;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.filter-clear-btn {
    display: block;
    width: calc(100% - 16px);
    margin: 4px 8px;
    padding: 6px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.filter-clear-btn:hover {
    background: #e8e8e8;
}
