/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green-600: #16a34a;
    --green-700: #15803d;
    --green-800: #166534;
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #fff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green-700); text-decoration: none; }
a:hover { color: var(--green-800); text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* ── Header ──────────────────────────────────────────── */
.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 1rem;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--green-700);
    white-space: nowrap;
    flex-shrink: 0;
}
.logo:hover { text-decoration: none; color: var(--green-800); }
.logo svg { flex-shrink: 0; }
.main-nav a {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--green-700);
    padding: 0.4rem 1rem;
    border: 1px solid var(--green-600);
    border-radius: var(--radius);
    white-space: nowrap;
    transition: all .15s ease;
}
.main-nav a:hover { background: var(--green-600); color: var(--white); text-decoration: none; }

/* ── Breadcrumbs ─────────────────────────────────────── */
.breadcrumbs {
    padding: 1rem 0 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-500);
}
.breadcrumbs a { color: var(--green-700); }
.breadcrumbs a:hover svg { color: var(--green-800); }
.breadcrumbs strong { color: var(--gray-700); font-weight: 600; }

/* ── Hero ────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 2.5rem 0 1.5rem;
}
.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}
.subtitle {
    color: var(--gray-500);
    font-size: 1.1rem;
}

/* ── Search box (homepage) ──────────────────────────── */
.search-box {
    position: relative;
    max-width: 400px;
    margin: 1.25rem auto 0;
}
.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    outline: none;
    transition: border-color .15s ease;
    font-family: inherit;
}
.search-box input:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}
.search-box input::placeholder { color: var(--gray-400); }
.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 100;
    margin-top: 0.25rem;
    max-height: 320px;
    overflow-y: auto;
}
.search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s ease;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--green-50); text-decoration: none; }
.search-item strong { font-weight: 600; }
.search-item span { font-size: 0.8rem; color: var(--gray-500); }

/* ── Maps ────────────────────────────────────────────── */
.map-section { margin: 1.5rem 0; }
.map-full, .map-region, .map-city, .map-chain {
    height: 450px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    z-index: 1;
}
.map-region { height: 380px; }
.map-city { height: 350px; }
.map-chain { height: 400px; }
.map-detail {
    height: 280px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 1.5rem;
    z-index: 1;
}

/* ── Section titles ──────────────────────────────────── */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--gray-900);
}

/* ── Regions grid ────────────────────────────────────── */
.regions-section { padding: 2rem 0; }
.regions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
.region-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    transition: all .15s ease;
    display: block;
}
.region-card:hover {
    border-color: var(--green-600);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    transform: translateY(-2px);
}
.region-card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}
.region-card p {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* ── Chains grid (homepage) ─────────────────────────── */
.chains-section { padding: 1rem 0 2rem; }
.chains-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.chain-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all .15s ease;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.chain-card:hover {
    border-color: var(--green-600);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    transform: translateY(-2px);
}
.chain-card-logo {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 6px;
}
.chain-card-logo img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}
.chain-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.chain-card-body h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.2rem;
}
.chain-card-body p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.6rem;
}
.chain-card .card-link {
    align-self: flex-start;
    font-size: 0.75rem;
    padding: 0.3rem 0.75rem;
}

/* ── Types section (homepage) ─────────────────────────── */
.types-section, .store-section { padding: 1rem 0 1.5rem; }
.types-list, .store-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.type-link, .store-link {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--gray-700);
    transition: all .15s ease;
}
.type-link:hover, .store-link:hover {
    border-color: var(--green-600);
    color: var(--green-700);
    text-decoration: none;
}
.type-count {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ── Chain landing page ─────────────────────────────── */
.chain-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.chain-header-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

/* ── Cities grid ─────────────────────────────────────── */
.cities-section { padding: 1.5rem 0 2rem; }
.cities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.city-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: all .15s ease;
    display: block;
}
.city-card:hover {
    border-color: var(--green-600);
    box-shadow: var(--shadow);
    text-decoration: none;
}
.city-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}
.city-card p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.15rem;
}

/* ── Pharmacy cards (listing) ────────────────────────── */
.pharmacy-list { padding: 1rem 0 2rem; }
.pharmacy-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
    transition: all .15s ease;
}
.pharmacy-card:hover {
    border-color: var(--green-600);
    box-shadow: var(--shadow);
}
.card-content-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.card-logo {
    flex-shrink: 0;
    padding-top: 0.15rem;
}
.card-info {
    flex: 1;
    min-width: 0;
}
.pharmacy-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.35rem;
}
.pharmacy-card h3 a { color: var(--green-700); }
.pharmacy-card h3 a:hover { color: var(--green-800); }
.card-address {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: 0.35rem;
}
.card-phone {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}
.card-link {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--green-700);
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--green-600);
    border-radius: var(--radius);
    transition: all .15s ease;
}
.card-link:hover {
    background: var(--green-600);
    color: var(--white);
    text-decoration: none;
}

/* ── Chain logo ──────────────────────────────────────── */
.chain-logo {
    vertical-align: middle;
    margin-right: 0.5rem;
    border-radius: 4px;
}
.pharmacy-detail h1 .chain-logo {
    vertical-align: text-bottom;
    margin-right: 15px;
}

/* ── Pharmacy detail ─────────────────────────────────── */
.pharmacy-detail { padding: 1.5rem 0 2rem; }
.pharmacy-detail h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 1.5rem;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.detail-section {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.detail-section h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-100);
}
.address-block {
    line-height: 1.8;
    color: var(--gray-700);
}
.contact-item {
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: var(--gray-700);
}
.contact-item .label {
    font-weight: 600;
    color: var(--gray-600);
}
.detail-row {
    padding: 0.35rem 0;
    font-size: 0.875rem;
    color: var(--gray-600);
}
.detail-row .label {
    font-weight: 600;
    color: var(--gray-500);
}

/* ── Edit link ───────────────────────────────────────── */
.edit-link {
    text-align: right;
    margin-top: 0.5rem;
}
.edit-link a {
    font-size: 0.75rem;
    color: var(--gray-400);
}
.edit-link a:hover {
    color: var(--gray-600);
    text-decoration: underline;
}

/* ── Opening hours table ─────────────────────────────── */
.hours-table {
    width: 100%;
    border-collapse: collapse;
}
.hours-table th, .hours-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}
.hours-table th {
    color: var(--gray-500);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}
.hours-table td {
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}
.hours-table tr.open td {
    font-weight: 400;
    color: var(--gray-700);
}
.hours-table tr.closed td {
    color: var(--gray-400);
    font-style: italic;
}

/* ── Nearby pharmacies ──────────────────────────────── */
.nearby-pharmacies {
    padding: 2rem 0;
    border-top: 1px solid var(--gray-200);
    margin-top: 1rem;
}
.nearby-pharmacies h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}
.btn-outline {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--white);
    color: var(--green-700);
    border: 2px solid var(--green-600);
    border-radius: var(--radius);
    font-weight: 600;
    transition: all .15s ease;
    margin-top: 0.5rem;
}
.btn-outline:hover {
    background: var(--green-600);
    color: var(--white);
    text-decoration: none;
}

/* ── Contact page ────────────────────────────────────── */
.contact-page {
    max-width: 600px;
    padding: 2rem 0;
}
.contact-page h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 1.5rem;
}
.contact-page p {
    margin-bottom: 1rem;
    color: var(--gray-700);
}
.contact-email a {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Error page ──────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 4rem 0;
}
.error-page h1 {
    font-size: 2rem;
    color: var(--gray-900);
    margin-bottom: 1rem;
}
.error-page p { color: var(--gray-500); margin-bottom: 2rem; }
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--green-600);
    color: var(--white);
    border-radius: var(--radius);
    font-weight: 600;
    transition: background .15s ease;
}
.btn:hover { background: var(--green-700); text-decoration: none; color: var(--white); }

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1.5rem 0;
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--gray-500);
}
.site-footer p { margin-bottom: 0.25rem; }
.site-footer a { color: var(--gray-600); }

/* ── Text muted ──────────────────────────────────────── */
.text-muted { color: var(--gray-400); font-style: italic; }

/* ── Leaflet popup ───────────────────────────────────── */
.leaflet-popup-content { font-family: inherit; font-size: 0.875rem; }
.leaflet-popup-content a { color: var(--green-700); font-weight: 600; }
.leaflet-popup-content .popup-address { color: var(--gray-500); font-size: 0.8rem; margin: 0.25rem 0 0; }
.leaflet-popup-content .popup-detail {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--green-700);
    text-decoration: underline;
    font-weight: 400;
}
.leaflet-popup-content .popup-detail:hover {
    color: var(--green-800);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.5rem; }
    .container > h1, .pharmacy-detail h1 { font-size: 1.35rem; }
    .map-full, .map-region, .map-city, .map-chain { height: 300px; }
    .detail-grid { grid-template-columns: 1fr; }
    .regions-grid { grid-template-columns: 1fr 1fr; }
    .cities-grid { grid-template-columns: 1fr 1fr; }
    .chains-grid { grid-template-columns: 1fr; }
    .logo span { font-size: 0.95rem; }
    .nearby-pharmacies h2 { font-size: 1.1rem; }
}
@media (max-width: 480px) {
    .regions-grid { grid-template-columns: 1fr; }
    .cities-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.25rem; }
    .container > h1, .pharmacy-detail h1 { font-size: 1.15rem; }
    .map-full, .map-region, .map-city, .map-chain { height: 250px; }
    .logo span { font-size: 0.85rem; }
}
