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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f8ff;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */

header {
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #0066cc 0%, #004080 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* ─── Auth bar ────────────────────────────────────────────────────────────── */

#authBar {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 36px;
}

#authLoggedIn {
    align-items: center;
    gap: 10px;
}

.auth-loading {
    font-size: 13px;
    opacity: 0.7;
}

.auth-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.6);
    vertical-align: middle;
}

.auth-name {
    font-size: 14px;
    font-weight: 500;
    color: white;
}

.btn-auth {
    background: white;
    color: #0066cc;
    font-size: 13px;
    padding: 6px 16px;
}

.btn-auth:hover {
    background: #e6f0ff;
}

.btn-auth-outline {
    background: transparent;
    color: white;
    font-size: 13px;
    padding: 6px 16px;
    border: 1px solid rgba(255,255,255,0.6);
}

.btn-auth-outline:hover {
    background: rgba(255,255,255,0.15);
}

/* ─── Main layout ─────────────────────────────────────────────────────────── */

.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    margin-bottom: 30px;
}

.map-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#map {
    height: 600px;
    width: 100%;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

/* ─── Panels ──────────────────────────────────────────────────────────────── */

.form-container,
.list-container,
.info-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.list-container {
    max-height: 600px;
    overflow-y: auto;
}

.form-container h3,
.list-container h3,
.info-container h3 {
    margin-bottom: 20px;
    color: #0066cc;
    border-bottom: 2px solid #0066cc;
    padding-bottom: 10px;
}

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-hint {
    font-size: 13px;
    color: #888;
    margin-bottom: 15px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #0066cc;
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background-color: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    flex: 1;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* ─── Sighting cards ──────────────────────────────────────────────────────── */

.sighting-item {
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sighting-item:hover {
    background-color: #f5f5f5;
    border-color: #0066cc;
}

.sighting-item h4 {
    color: #0066cc;
    margin-bottom: 5px;
}

.sighting-item p {
    font-size: 14px;
    color: #666;
    margin-bottom: 3px;
}

#sightingInfo p {
    margin-bottom: 10px;
    line-height: 1.6;
}

#sightingInfo strong {
    color: #0066cc;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */

footer {
    text-align: center;
    padding: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: #666;
}

.footer-attribution {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
}

.footer-attribution a {
    color: #999;
    text-decoration: underline;
}

/* ─── Map filters ─────────────────────────────────────────────────────────── */

.map-filters {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.map-filters select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    flex: 1;
    min-width: 140px;
}

.btn-filter {
    background-color: #0066cc;
    color: white;
    padding: 8px 16px;
    white-space: nowrap;
}

.btn-filter:hover {
    background-color: #0052a3;
}

/* ─── Photos ──────────────────────────────────────────────────────────────── */

input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px dashed #ddd;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    background: #fafafa;
}

input[type="file"]:hover {
    border-color: #0066cc;
    background: #f0f8ff;
}

.photos-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.photos-preview img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ddd;
}

/* ─── Leaflet custom markers ──────────────────────────────────────────────── */

.whale-marker {
    background-color: #0066cc;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ─── Status messages ─────────────────────────────────────────────────────── */

.loading {
    text-align: center;
    padding: 20px;
    color: #0066cc;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border-left: 4px solid #c62828;
}

.success-message {
    background-color: #e8f5e9;
    color: #2e7d32;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border-left: 4px solid #2e7d32;
}

/* ─── Header link ─────────────────────────────────────────────────────────── */

.header-link {
    display: inline-block;
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    transition: color 0.2s, border-color 0.2s;
}

.header-link:hover {
    color: white;
    border-color: white;
}

/* ─── About modal ─────────────────────────────────────────────────────────── */

.about-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.about-overlay.active {
    display: flex;
}

.about-modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
}

.about-modal h2 {
    color: #0066cc;
    font-size: 1.6em;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0066cc;
}

.about-modal p {
    line-height: 1.7;
    color: #444;
    margin-bottom: 16px;
    font-size: 15px;
}

.about-modal strong {
    color: #0066cc;
}

.about-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.about-close:hover {
    color: #333;
}

.about-cta {
    background: #f0f8ff;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.about-cta h3 {
    color: #0066cc;
    font-size: 1.1em;
    margin-bottom: 12px;
}

.about-cta ol {
    padding-left: 20px;
    color: #555;
    line-height: 1.8;
    font-size: 14px;
}

.about-footer-text {
    font-style: italic;
    color: #888 !important;
    font-size: 13px !important;
    text-align: center;
    margin-top: 20px;
    margin-bottom: 0 !important;
}

/* ─── Mobile sidebar toggle button ────────────────────────────────────────── */

.btn-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0066cc;
    color: white;
    border: none;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.btn-sidebar-toggle:hover {
    background: #0052a3;
    transform: scale(1.05);
}

/* Overlay behind sidebar on mobile */
.sidebar-overlay {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤968px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 968px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 20px;
        margin-bottom: 10px;
        border-radius: 8px;
    }

    header h1 {
        font-size: 2em;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 10px;
    }

    #map {
        height: 45vh;
    }

    .map-container {
        border-radius: 8px;
    }

    footer {
        border-radius: 8px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤640px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    body {
        background-color: #fff;
    }

    .container {
        padding: 0;
        max-width: 100%;
    }

    /* ── Header: compact ──────────────────────────────────────────────── */
    header {
        border-radius: 0;
        padding: 16px 12px;
        margin-bottom: 0;
    }

    header h1 {
        font-size: 1.5em;
        margin-bottom: 4px;
    }

    header p {
        font-size: 0.85em;
    }

    #authBar {
        margin-top: 10px;
        gap: 8px;
    }

    .auth-name {
        font-size: 12px;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .auth-avatar {
        width: 28px;
        height: 28px;
    }

    .btn-auth, .btn-auth-outline {
        font-size: 12px;
        padding: 5px 12px;
    }

    /* ── Map: full width, tall viewport ───────────────────────────────── */
    .main-content {
        display: flex;
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }

    .map-container {
        border-radius: 0;
        box-shadow: none;
    }

    #map {
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px);
    }

    /* ── Map filters: hidden on mobile ────────────────────────────────── */
    .map-filters {
        display: none;
    }

    /* ── Sidebar: bottom sheet overlay ────────────────────────────────── */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: #f0f8ff;
        max-height: 70vh;
        overflow-y: auto;
        padding: 16px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        -webkit-overflow-scrolling: touch;
    }

    /* Drag handle indicator */
    .sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 0 auto 12px;
    }

    .sidebar.open {
        transform: translateY(0);
    }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* FAB button to open sidebar */
    .btn-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ── Panels inside sidebar ────────────────────────────────────────── */
    .form-container,
    .list-container,
    .info-container {
        border-radius: 8px;
        padding: 16px;
    }

    .form-container h3,
    .list-container h3,
    .info-container h3 {
        margin-bottom: 14px;
        font-size: 1.1em;
    }

    /* Stack lat/lng on mobile */
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;  /* Prevents iOS zoom on focus */
        padding: 12px;
    }

    textarea {
        font-size: 16px;
        padding: 12px;
    }

    .form-buttons {
        margin-top: 16px;
    }

    /* Action buttons: full width */
    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .action-buttons .btn {
        width: 100%;
        text-align: center;
    }

    /* ── Sighting cards: tighter padding ──────────────────────────────── */
    .sighting-item {
        padding: 12px;
    }

    .sighting-item h4 {
        font-size: 15px;
    }

    .sighting-item p {
        font-size: 13px;
    }

    /* ── Status messages ──────────────────────────────────────────────── */
    .error-message,
    .success-message {
        padding: 12px;
        font-size: 13px;
        border-radius: 5px;
    }

    /* ── Photos preview: smaller on mobile ────────────────────────────── */
    .photos-preview img {
        width: 60px;
        height: 60px;
    }

    /* ── Hide close button on detail view ─────────────────────────────── */
    #btnCloseInfo {
        display: none;
    }

    /* ── About modal: full screen on mobile ──────────────────────────── */
    .about-overlay {
        padding: 0;
    }

    .about-modal {
        max-height: 100vh;
        max-height: 100dvh;
        height: 100%;
        border-radius: 0;
        padding: 20px;
        padding-top: 48px;
    }

    /* ── Footer: minimal ──────────────────────────────────────────────── */
    footer {
        display: none;
    }

    /* ── Leaflet controls: push above FAB ─────────────────────────────── */
    .leaflet-bottom.leaflet-right {
        bottom: 70px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Small phones (≤380px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 380px) {
    header h1 {
        font-size: 1.3em;
    }

    header p {
        font-size: 0.8em;
    }

    .auth-name {
        display: none;
    }

    .map-filters {
        flex-direction: column;
    }

    .map-filters select {
        width: 100%;
    }
}
