/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --green:      #3a7d44;
    --green-dark: #2a5c32;
    --green-light:#e8f5e9;
    --accent:     #f4a93e;
    --accent-dark:#d4881e;
    --red:        #e53935;
    --red-light:  #ffebee;
    --text:       #222;
    --text-muted: #666;
    --border:     #cce0cc;
    --bg:         #f7fbf7;
    --white:      #ffffff;
    --radius:     12px;
    --radius-sm:  6px;
    --shadow:     0 2px 8px rgba(0,0,0,.10);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ===== Site Header ===== */
.site-header {
    background: var(--green);
    color: var(--white);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 60px;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.site-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--white);
    text-decoration: none;
    letter-spacing: -.5px;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.site-header nav a {
    color: var(--white);
    text-decoration: none;
    font-size: .9rem;
    padding: .3rem .6rem;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.site-header nav a:hover { background: rgba(255,255,255,.2); }

.nav-user { color: rgba(255,255,255,.95); font-size: .9rem; font-weight: 600; }
.nav-logout { display: inline; }
.nav-logout-btn {
    background: none;
    border: 0;
    color: var(--white);
    font-size: .9rem;
    padding: .3rem .6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
    font-family: inherit;
}
.nav-logout-btn:hover { background: rgba(255,255,255,.2); }

.form-page hr { margin: 2.25rem 0; border: 0; border-top: 1px solid var(--green-light); }

.btn-small {
    background: var(--accent);
    color: var(--text) !important;
    font-weight: 600;
    border-radius: var(--radius-sm);
}
.btn-small:hover { background: var(--accent-dark); }

/* ===== Main ===== */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* ===== Alerts ===== */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}
.alert-error   { background: var(--red-light); color: var(--red); border: 1px solid #f5c6cb; }
.alert-success { background: var(--green-light); color: var(--green-dark); border: 1px solid var(--border); }
.alert-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
}
.hero h1 { font-size: 2rem; color: var(--green-dark); margin-bottom: 1rem; }

.search-form {
    display: flex;
    gap: .5rem;
    max-width: 500px;
    margin: 0 auto;
}
.search-form input {
    flex: 1;
    padding: .65rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: border-color .15s;
}
.search-form input:focus { border-color: var(--green); }
.search-form button {
    padding: .65rem 1.2rem;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: background .15s;
}
.search-form button:hover { background: var(--green-dark); }

/* ===== Park Grid ===== */
.park-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.park-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: transform .15s, box-shadow .15s;
    display: flex;
    flex-direction: column;
}
.park-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.13); text-decoration: none; }

.park-card-img { overflow: hidden; background: var(--green-light); }
.park-card-img img { width: 100%; height: auto; display: block; }
.park-card-no-img { height: 160px; display: flex; align-items: center; justify-content: center; font-size: 3rem; }

.park-card-body { padding: 1rem; flex: 1; }
.park-card-body h2 { font-size: 1.05rem; margin-bottom: .25rem; color: var(--green-dark); }
.park-location { font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; }
.park-rating { font-size: .9rem; font-weight: 600; color: var(--accent-dark); }
.no-rating { color: var(--text-muted); font-weight: 400; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state p { font-size: 1.2rem; margin-bottom: 1rem; }

/* ===== Park Detail ===== */
.park-detail { max-width: 800px; margin: 0 auto; }
.park-detail-header { margin-bottom: 1.5rem; }
.park-detail-header h1 { font-size: 2rem; color: var(--green-dark); }
.park-meta { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; }

.park-map { border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; box-shadow: var(--shadow); }

.park-notes { background: var(--white); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.park-notes h2 { margin-bottom: .5rem; }

.park-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0; }

/* ===== Ratings Summary ===== */
.ratings-summary { background: var(--white); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.ratings-summary h2 { margin-bottom: .75rem; }
.ratings-header { display: flex; align-items: center; justify-content: space-between; }
.ratings-header h2 { margin-bottom: .75rem; }
#rating-edit { margin-top: 1rem; }
.overall-score { font-size: 3rem; font-weight: 800; color: var(--green-dark); line-height: 1; margin-bottom: 1rem; }
.overall-score span { font-size: 1.2rem; color: var(--text-muted); font-weight: 400; }

.overall-notes {
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
    color: var(--text);
}
.overall-notes p { margin: 0; }
.overall-notes p + p { margin-top: .6rem; }

.category-ratings { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; }
.cat-rating { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .9rem; padding: .3rem .5rem; background: var(--green-light); border-radius: var(--radius-sm); }
.cat-emoji { font-size: 1.1rem; }
.cat-label-group { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.cat-label { }
.cat-description { font-size: .75rem; color: var(--text-muted); font-weight: 400; margin: 0 0 .5rem; }
.star-display { color: var(--accent); letter-spacing: 1px; }
.cat-notes { flex: 1 1 100%; font-size: .8rem; color: var(--text-muted); }
.cat-notes p { margin: .3rem 0 0; }
.cat-notes p:first-child { margin-top: .3rem; }
.cat-num { font-weight: 600; color: var(--green-dark); }

/* ===== Location search ===== */
.location-search-wrap { position: relative; }
.location-search-wrap input { width: 100%; }

.location-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--white);
    border: 2px solid var(--green);
    border-radius: var(--radius-sm);
    list-style: none;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.location-results li {
    padding: .6rem .9rem;
    cursor: pointer;
    font-size: .9rem;
    border-bottom: 1px solid var(--border);
    line-height: 1.35;
}
.location-results li:last-child { border-bottom: none; }
.location-results li:hover { background: var(--green-light); }
.location-no-results { color: var(--text-muted); cursor: default !important; }
.location-no-results:hover { background: none !important; }

.location-map {
    margin-top: .75rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--white);
}
#leaflet-map { height: 260px; width: 100%; }
.map-hint { font-size: .8rem; color: var(--text-muted); padding: .35rem .75rem 0; }
.location-map #location-clear { margin: .3rem .75rem .5rem; display: inline-block; }

/* ===== Gallery ===== */
.park-gallery { margin-bottom: 1.5rem; }
.park-gallery h2 { margin-bottom: .75rem; }
.gallery-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.gallery-header h2 { margin-bottom: 0; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; align-items: start; }
.gallery-item { background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.gallery-item img { width: 100%; height: auto; display: block; }
.gallery-img { cursor: pointer; }

/* ===== Photo gallery edit mode ===== */
.edit-hint { color: var(--text-muted); font-size: .9rem; margin-bottom: .75rem; }
.edit-photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.edit-photo-item {
    background: var(--white); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); cursor: grab; padding-bottom: .5rem; position: relative;
}
.edit-photo-item.dragging { opacity: .4; }
.edit-photo-item img { width: 100%; height: auto; display: block; }
.delete-photo-btn {
    position: absolute; top: .35rem; right: .35rem; z-index: 1;
    width: 1.6rem; height: 1.6rem; border-radius: 50%; border: none;
    background: rgba(0,0,0,.55); color: var(--white); font-size: 1.1rem;
    line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.delete-photo-btn:hover { background: var(--red); }
.edit-photo-item input[type="text"] {
    width: calc(100% - 1rem); margin: .5rem .5rem 0; font-size: .8rem; padding: .3rem .4rem;
}
.edit-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ===== Lightbox ===== */
.lightbox {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.9);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
}
.lightbox-img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: var(--radius-sm); }
.lightbox-caption { color: var(--white); margin-top: .75rem; text-align: center; }
.lightbox-close {
    position: absolute; top: 1rem; right: 1.5rem;
    background: none; border: none; color: var(--white);
    font-size: 2.5rem; line-height: 1; cursor: pointer;
}
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.15); border: none; color: var(--white);
    font-size: 2.5rem; line-height: 1; width: 3rem; height: 3rem;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-nav:hover { background: rgba(255,255,255,.3); }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.caption { font-size: .8rem; color: var(--text-muted); padding: .4rem .6rem; }

/* ===== Visit Log ===== */
.park-visits { margin-bottom: 1.5rem; }
.visits-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.visits-header h2 { margin-bottom: 0; }
.visit-entry { background: var(--white); border-radius: var(--radius-sm); padding: .75rem 1rem; margin-bottom: .5rem; box-shadow: var(--shadow); }
.visit-entry p { margin-top: .25rem; color: var(--text-muted); }
.visit-entry-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.visit-entry-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.visit-entry-actions form { display: contents; }
.visit-edit-btn {
    width: 1.6rem; height: 1.6rem; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: .85rem;
    text-decoration: none; background: var(--bg); flex-shrink: 0;
}
.visit-delete-btn {
    width: 1.6rem; height: 1.6rem; border-radius: 50%; border: none;
    background: var(--bg); color: var(--text-muted); font-size: 1.1rem;
    line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.visit-delete-btn:hover { background: var(--red); color: var(--white); }

/* ===== Forms ===== */
.form-page { max-width: 700px; margin: 0 auto; }
.form-page-narrow { max-width: 440px; }
.form-page h1 { font-size: 1.75rem; color: var(--green-dark); margin-bottom: 1.25rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .95rem; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="search"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: .65rem .9rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    transition: border-color .15s;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--green); }
.form-group textarea { resize: vertical; min-height: 90px; }
.form-group small { color: var(--text-muted); font-weight: 400; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

fieldset.form-group { border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
fieldset.form-group legend { font-weight: 600; padding: 0 .4rem; }

.hint, .form-hint { font-size: .9rem; color: var(--text-muted); margin-bottom: .75rem; }
.form-hint { margin-top: 1rem; text-align: center; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: .65rem 1.4rem;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .1s;
    line-height: 1.4;
}
.btn:hover { background: var(--green-dark); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-secondary {
    background: var(--white);
    color: var(--green-dark);
    border: 2px solid var(--green);
}
.btn-secondary:hover { background: var(--green-light); }

.btn.btn-small  { padding: .35rem .8rem; font-size: .85rem; border-radius: var(--radius-sm); }
.btn.btn-danger { background: var(--red); }
.btn.btn-danger:hover { background: #c62828; }

.btn-link-danger {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: .85rem;
    padding: .2rem .4rem;
    text-decoration: underline;
}

/* ===== Star Picker ===== */
.star-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.star-group { background: var(--white); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.star-group label { font-weight: 600; font-size: .95rem; display: block; margin-bottom: .5rem; }
.star-group.na .star-picker { opacity: .35; pointer-events: none; }
.star-picker { display: flex; gap: .2rem; }
.na-checkbox { font-weight: 400 !important; font-size: .85rem; display: flex !important; align-items: center; gap: .4rem; margin: .5rem 0 0 !important; cursor: pointer; }
.cat-note-input { width: 100%; margin-top: .6rem; padding: .4rem .5rem; font-size: .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); box-sizing: border-box; }
.cat-note-input:focus { border-color: var(--green); outline: none; }
.star-btn {
    font-size: 1.6rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #ddd;
    line-height: 1;
    padding: 0 .1rem;
    transition: color .1s, transform .1s;
}
.star-btn.active { color: var(--accent); }
.star-btn:hover  { transform: scale(1.2); }

/* ===== Overall Picker ===== */
.overall-group { margin-bottom: 1.5rem; }
.overall-group label { font-size: 1.1rem; margin-bottom: .75rem; }
.overall-picker { display: flex; gap: .4rem; flex-wrap: wrap; }
.overall-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--white);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .1s, border-color .1s, transform .1s;
    color: var(--text);
}
.overall-btn.active { background: var(--green); border-color: var(--green-dark); color: var(--white); }
.overall-btn:hover { transform: scale(1.1); border-color: var(--green); }

/* ===== Photo Upload ===== */
.photo-previews { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.preview-item { position: relative; }
.preview-item img { width: 120px; height: 100px; object-fit: cover; border-radius: var(--radius-sm); border: 2px solid var(--border); }
.preview-item input[type="text"] { width: 120px; font-size: .8rem; padding: .25rem .4rem; margin-top: .25rem; }

/* ===== Admin ===== */
.admin-page h1 { color: var(--green-dark); margin-bottom: .25rem; }
.admin-section { margin-top: 2rem; }
.admin-section h2 { font-size: 1.2rem; margin-bottom: .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--border); }
.empty { color: var(--text-muted); padding: .5rem 0; }

.admin-category-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem 1rem; margin-bottom: 1rem; }
.admin-category-item label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.admin-category-item input[type="text"] { width: 100%; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); box-sizing: border-box; }
.admin-category-item input[type="text"]:focus { border-color: var(--green); outline: none; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th { background: var(--green-light); color: var(--green-dark); font-weight: 700; text-align: left; padding: .65rem 1rem; font-size: .9rem; }
.admin-table td { padding: .6rem 1rem; font-size: .9rem; border-top: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:hover td { background: #f9fdf9; }

/* ===== Error/Pending pages ===== */
.error-page, .pending-state {
    text-align: center;
    padding: 3rem 1rem;
    max-width: 400px;
    margin: 0 auto;
}
.error-icon, .pending-icon { font-size: 4rem; margin-bottom: 1rem; }
.error-page h1, .pending-state h1 { font-size: 1.8rem; color: var(--green-dark); margin-bottom: .75rem; }
.error-page p, .pending-state p { color: var(--text-muted); margin-bottom: .75rem; }
.pending-state .btn { margin: .4rem; }

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: .85rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
