:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --accent: #198754;
    --bg-ocean: #e8f4f8;
}

* { box-sizing: border-box; }

html {
    scrollbar-gutter: stable; /* Rezervira prostor za scrollbar na svim stranicama -- sprječava pomak sadržaja kad se pojavi/nestane scrollbar */
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
}

/* Auth pages */
.auth-page {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-icon {
    font-size: 3rem;
    color: var(--primary);
}

/* Flash messages */
.flash-container {
    position: fixed;
    top: 60px;
    right: 0;
    left: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.flash-container .alert {
    pointer-events: auto;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Dashboard / Map */
.dashboard-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.dashboard-page .navbar {
    flex-shrink: 0;
    z-index: 1100;
}

.navbar-toggler {
    -webkit-tap-highlight-color: transparent;
    transition: background 0.3s;
}

.navbar-toggler:focus,
.navbar-toggler:focus-visible,
.navbar-toggler.active {
    box-shadow: none !important;
    outline: none !important;
}

.navbar-toggler.toggler-blink {
    background: rgba(255, 255, 255, 0.25) !important;
}

#map {
    flex: 1;
    width: 100%;
    z-index: 1;
}

/* Floating action buttons */
.btn-save-spot, .btn-save-reef {
    position: fixed;
    right: 1rem;
    z-index: 1000;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-save-spot {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 36px);
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.4);
}

.btn-save-reef {
    bottom: calc(4.2rem + env(safe-area-inset-bottom, 0px) + 36px);
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
}

.btn-save-spot:hover, .btn-save-reef:hover {
    transform: translateY(-2px);
}

.btn-locate {
    position: fixed;
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px) + 36px);
    left: 2rem;
    z-index: 1000;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid #dee2e6;
    background: #fff;
    color: #212529;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.btn-locate:hover,
.btn-locate:focus,
.btn-locate:focus-visible,
.btn-locate.active {
    background: #fff !important;
    color: #212529 !important;
    border-color: #dee2e6 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    outline: none !important;
}

.btn-locate.locating {
    background: #0d6efd !important;
    color: #fff !important;
    border-color: #0d6efd !important;
}

.btn-locate.following {
    background: #0d6efd !important;
    color: #fff !important;
    border-color: #0d6efd !important;
    animation: followPulse 2s ease-in-out infinite;
}

@keyframes followPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(13, 110, 253, 0); }
}

/* Leaflet popup styling */
.spot-popup {
    min-width: 260px;
    max-width: 340px;
}

.spot-popup h6 {
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

.spot-popup .spot-detail {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.spot-popup .spot-detail .label {
    font-weight: 600;
    color: #555;
    margin-right: 8px;
}

.spot-popup .spot-detail .value {
    text-align: right;
    color: #333;
}

.spot-popup .spot-image {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 8px;
}

.spot-popup .spot-notes {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 8px;
    font-size: 0.85rem;
    font-style: italic;
    color: #555;
}

.spot-popup .popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.spot-popup .popup-actions button {
    flex: 1;
    font-size: 0.8rem;
}

.spot-popup .shared-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}

/* User location marker pulse */
.user-location-marker {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--primary), 0 0 12px rgba(13, 110, 253, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 2px var(--primary), 0 0 0 4px rgba(13, 110, 253, 0.3); }
    70% { box-shadow: 0 0 0 2px var(--primary), 0 0 0 12px rgba(13, 110, 253, 0); }
    100% { box-shadow: 0 0 0 2px var(--primary), 0 0 0 4px rgba(13, 110, 253, 0); }
}

/* Temp marker for map click */
.temp-marker-pin {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    background: #dc3545;
    transform: rotate(-45deg);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce-in 0.3s ease-out;
    cursor: grab;
}

.temp-marker-pin i {
    color: #fff;
    font-size: 14px;
    transform: rotate(45deg);
    font-weight: bold;
}

.temp-marker-pin:hover {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.7);
}

@keyframes bounce-in {
    0% { transform: rotate(-45deg) scale(0); }
    60% { transform: rotate(-45deg) scale(1.15); }
    100% { transform: rotate(-45deg) scale(1); }
}

/* Map click hint */
.map-hint {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 90%;
    backdrop-filter: blur(4px);
}

.map-hint .btn-close-sm {
    width: 0.6rem;
    height: 0.6rem;
    filter: invert(1);
    opacity: 0.7;
}

.map-hint .btn-close-sm:hover {
    opacity: 1;
}

/* Tide chart */
.tide-chart-card {
    background: #f0f7ff;
    border: 1px solid #c7ddf5;
    border-radius: 10px;
    padding: 14px 16px;
}

.tide-chart-wrapper {
    height: 160px;
    position: relative;
}

#detailModal .tide-chart-wrapper {
    height: 140px;
}

#detailModal .forecast-chart-wrapper {
    height: 130px;
}

.tide-info-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.tide-info-item {
    text-align: center;
    min-width: 100px;
}

.tide-info-label {
    font-size: 0.72rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tide-info-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0d6efd;
}

.tide-info-sub {
    font-size: 0.8rem;
    color: #198754;
    font-weight: 600;
}

.tide-extremes {
    flex: 1;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tide-extreme-item {
    text-align: center;
    flex: 1;
    min-width: 80px;
    background: #fff;
    border-radius: 8px;
    padding: 6px 8px;
    border: 1px solid #dee2e6;
}

.tide-extreme-item .te-type {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.tide-extreme-item .te-type.high { color: #0d6efd; }
.tide-extreme-item .te-type.low { color: #dc3545; }

.tide-extreme-item .te-time {
    font-size: 0.9rem;
    font-weight: 600;
}

.tide-extreme-item .te-height {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Moon phase card */
.moon-info-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    border-radius: 10px;
    padding: 14px 18px;
    border: 1px solid #2a2a4a;
}

.moon-info-card .fw-bold {
    color: #fff;
}

.moon-info-card .text-muted {
    color: #aab !important;
}

.moon-emoji {
    font-size: 2.8rem;
    line-height: 1;
}

/* Forecast charts (pressure, wind) */
.forecast-chart-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 12px 14px;
}

.forecast-chart-wrapper {
    height: 170px;
    position: relative;
}

/* Loading spinner for weather fetch */
.weather-loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.weather-loading .spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Modal improvements */
.modal-header.bg-primary .btn-close-white {
    filter: brightness(0) invert(1);
}

/* Image preview */
#imagePreview {
    text-align: center;
}

/* Locked fields (auto-populated, not editable after save) */
.field-locked {
    pointer-events: none;
    background-color: #e9ecef !important;
    opacity: 0.8;
}

/* iOS safe area padding for PWA standalone mode */
@supports (padding-top: env(safe-area-inset-top)) {
    .dashboard-page .navbar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }
}

/* Fix datetime-local input on iOS */
input[type="datetime-local"] {
    -webkit-appearance: none;
    max-width: 100%;
    min-height: 38px;
}

/* Mobile form labels */
@media (max-width: 576px) {
    .form-label {
        font-size: 0.82rem;
        margin-bottom: 0.2rem;
    }

    .form-control, .form-select {
        font-size: 0.9rem;
    }

    #spotModal .modal-dialog,
    #activityModal .modal-dialog,
    #realActivityModal .modal-dialog,
    #forecastModal .modal-dialog,
    #fishGuideModal .modal-dialog,
    #myPostsModal .modal-dialog,
    #reefModal .modal-dialog {
        margin: 0.5rem;
    }

    #detailModal .modal-dialog {
        margin: 0.5rem;
        margin-top: 56px;
    }

    #detailModal .modal-footer {
        flex-wrap: wrap;
        gap: 4px;
    }

    #detailModal .modal-footer .btn {
        font-size: 0.78rem;
        padding: 4px 8px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .btn-save-spot {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 36px);
        right: 0.8rem;
        padding: 10px 16px;
        font-size: 0.82rem;
    }

    .btn-save-reef {
        bottom: calc(3.8rem + env(safe-area-inset-bottom, 0px) + 36px);
        right: 0.8rem;
        padding: 10px 16px;
        font-size: 0.82rem;
    }

    .btn-locate {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 36px);
        left: 0.8rem;
    }

    .auth-card {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .spot-popup {
        min-width: 220px;
    }
}

/* Admin table */
.table th, .table td {
    vertical-align: middle;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: 4px;
    margin: 1px;
}

/* Detail modal */
#detailModal .modal-dialog {
    max-height: 70vh;
    margin-top: 70px;
}

#detailModal .modal-content {
    max-height: 70vh;
}

#detailModal .modal-body {
    max-height: calc(70vh - 120px);
    overflow-y: auto;
}

#spotModal .modal-dialog,
#activityModal .modal-dialog,
#realActivityModal .modal-dialog,
#forecastModal .modal-dialog,
#fishGuideModal .modal-dialog,
#myPostsModal .modal-dialog,
#reefModal .modal-dialog {
    margin-top: 70px;
}

#spotModal .modal-content,
#activityModal .modal-content,
#realActivityModal .modal-content,
#forecastModal .modal-content,
#fishGuideModal .modal-content,
#myPostsModal .modal-content,
#reefModal .modal-content {
    max-height: 85vh;
}

#spotModal .modal-body,
#activityModal .modal-body,
#realActivityModal .modal-body,
#forecastModal .modal-body,
#fishGuideModal .modal-body,
#myPostsModal .modal-body,
#reefModal .modal-body {
    max-height: calc(85vh - 120px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.detail-data-card {
    font-size: 0.9rem;
}

.detail-data-card .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-data-card .detail-row .dl { font-weight: 600; color: #555; }
.detail-data-card .detail-row .dv { text-align: right; color: #333; }

.detail-data-card .catch-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.catch-badge.success { background: #d1e7dd; color: #0f5132; }
.catch-badge.fail { background: #f8d7da; color: #842029; }

.shared-tag {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid #c8e6c9;
}

.record-nav {
    background: #f8f9fa;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.record-nav select {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-footer {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

/* Pin badge for multiple records */
.pin-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    z-index: 10;
}

/* Activity gauge */
.gauge-container {
    position: relative;
    width: 200px;
    height: 120px;
    margin: 0 auto 10px;
}

.gauge-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin-top: 4px;
}

.gauge-label {
    font-size: 0.85rem;
    color: #6c757d;
}

.activity-conditions {
    text-align: left;
    font-size: 0.82rem;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 14px;
}

.activity-conditions .ac-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #eee;
}

.param-bar-container {
    text-align: left;
    margin-top: 12px;
}

.param-bar {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.82rem;
}

.param-bar .pb-label {
    width: 110px;
    flex-shrink: 0;
    color: #555;
}

.param-bar .pb-track {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.param-bar .pb-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.param-bar .pb-val {
    width: 40px;
    text-align: right;
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 6px;
}

.species-list {
    text-align: left;
    margin-top: 14px;
}

.species-row {
    display: flex;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.species-row .sr-name {
    flex: 1;
    font-weight: 600;
}

.species-row .sr-bar {
    width: 80px;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    margin: 0 8px;
}

.species-row .sr-fill {
    height: 100%;
    border-radius: 3px;
}

.species-row .sr-pct {
    width: 45px;
    text-align: right;
    font-weight: 700;
}

.species-row .sr-count {
    width: 50px;
    text-align: right;
    font-size: 0.75rem;
    color: #888;
}

/* Footer */
.app-footer {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.78rem;
    color: #6c757d;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.app-footer a {
    color: #6c757d;
    text-decoration: none;
}

.app-footer a:hover {
    color: #0d6efd;
    text-decoration: underline;
}

.dashboard-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    font-size: 0.7rem;
    gap: 8px;
}

/* GPS required overlay */
.gps-required-overlay {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15000;
    animation: slideDown 0.3s ease;
}

.gps-required-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    border: 2px solid #ffc107;
    max-width: 400px;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* GDPR banner */
.gdpr-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20000;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    padding: 16px 20px;
    font-size: 0.85rem;
}

.gdpr-banner a { color: #7ec8ff; }

.gdpr-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.gdpr-content p { margin: 0; flex: 1; min-width: 200px; }

@keyframes gdprPulse {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-3px); }
}

/* Leaflet controls repositioning */
.leaflet-top.leaflet-right {
    top: 10px;
}

.leaflet-control-layers {
    font-size: 0.85rem;
    cursor: pointer;
}

.leaflet-control-layers-expanded {
    padding: 8px 12px;
    padding-top: 24px;
    position: relative;
}

.layers-close-btn {
    position: absolute;
    top: 2px;
    right: 6px;
    font-size: 18px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    line-height: 1;
    width: 20px;
    height: 20px;
    text-align: center;
}

.layers-close-btn:hover {
    color: #000;
}

.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
    display: block;
    width: 100%;
    text-align: right;
    margin-bottom: 4px;
}

/* iOS safe area for Capacitor/PWA standalone mode */
@media (display-mode: standalone) {
    .auth-wrapper {
        padding-top: calc(2rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    }
}
