/* === RESET & PROMĚNNÉ === */
:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --card-hover: #fafafa;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --text: #1d1d1f;
    --sub: #86868b;
    --red: #ff3b30;
    --green: #34c759;
    --border: rgba(0,0,0,0.08);
    --header-bg: rgba(245,245,247,0.85);
    --modal-bg: rgba(0,0,0,0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --pending-bg: #fff3cd;
    --pending-border: #ffcc02;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --card: #2c2c2e;
        --card-hover: #3a3a3c;
        --text: #f5f5f7;
        --sub: #98989d;
        --border: rgba(255,255,255,0.1);
        --header-bg: rgba(28,28,30,0.85);
        --modal-bg: rgba(0,0,0,0.6);
        --shadow: 0 2px 12px rgba(0,0,0,0.2);
        --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
        --pending-bg: #3a3000;
        --pending-border: #ffcc02;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
}

/* === HEADER === */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-nav {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--border);
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
}

/* Admin aktivní */
.admin-active .icon-btn#btn-admin {
    background: var(--accent);
    color: white;
}

/* === FEED === */
.feed {
    max-width: 600px;
    margin: 0 auto;
    padding: 76px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* === KARTA NÁLEZU === */
.find-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    animation: fadeSlideIn 0.4s ease-out;
    padding: 5px;
}

.find-card.pending {
    border-color: var(--pending-border);
    box-shadow: 0 0 0 1px var(--pending-border), var(--shadow);
}



/* === UPLOAD OVERLAY === */
.upload-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--modal-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.upload-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.upload-modal {
    background: var(--card);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.upload-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.upload-modal p {
    font-size: 15px;
    color: var(--sub);
    font-weight: 500;
}

/* === MODAL (PIN) === */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--modal-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    width: min(340px, calc(100vw - 40px));
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.pin-input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 20px;
    text-align: center;
    letter-spacing: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.pin-input:focus {
    border-color: var(--accent);
}

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

.btn-modal {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal-cancel {
    background: var(--bg);
    color: var(--sub);
}

.btn-modal-ok {
    background: var(--accent);
    color: white;
}

.btn-modal-ok:hover {
    background: var(--accent-hover);
}

/* === CARD VIEWPORT & SWIPE === */
.card-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 12px;
}

.card-swipe {
    display: flex;
    width: 400%;
    height: 100%;
    will-change: transform;
}

.card-panel {
    width: calc(100% / 4);
    height: 100%;
    flex-shrink: 0;
}

.card-panel-photo {
    background: var(--card-hover);
}

.card-panel-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-panel-map {
    position: relative;
    background: var(--card-hover);
}

.card-map-container {
    width: 100%;
    height: 100%;
}

.no-gps {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sub);
    font-size: 14px;
    font-weight: 500;
}

.card-panel-info {
    padding: 16px;
    overflow-y: auto;
    background: var(--card);
}

/* === KOMENTÁŘE PANEL === */
.card-panel-comments {
    display: flex;
    flex-direction: column;
    background: var(--card);
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.comments-empty {
    color: var(--sub);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    padding: 40px 0;
}

.comment-item {
    position: relative;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg);
    border-radius: 12px;
    transition: opacity 0.2s;
}

.comment-item:last-child {
    margin-bottom: 0;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    padding-right: 20px;
}

.comment-ip {
    font-size: 11px;
    color: var(--sub);
    font-weight: 500;
}

.comment-date {
    font-size: 10px;
    color: var(--sub);
    opacity: 0.6;
}

.comment-text {
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
}

.comment-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    color: var(--red);
    font-size: 11px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s;
    padding: 2px 4px;
    line-height: 1;
}

.comment-delete:hover {
    opacity: 1;
}

.comment-form {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.comment-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.comment-input:focus {
    border-color: var(--accent);
}

.comment-send {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.comment-send:hover {
    background: var(--accent-hover);
}

.comment-send:active {
    transform: scale(0.9);
}

.comment-send svg {
    width: 14px;
    height: 14px;
}

.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
}

.info-label {
    font-size: 12px;
    color: var(--sub);
    font-weight: 500;
    white-space: nowrap;
}

.info-value {
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
    word-break: break-all;
}

.map-links {
    display: flex;
    gap: 8px;
}

.map-link {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.map-link:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Card bottom: meta + nav */
.card-bottom {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.find-date {
    font-size: 12px;
    color: var(--sub);
    font-weight: 500;
}

.find-device {
    font-size: 11px;
    color: var(--sub);
    opacity: 0.6;
}

.card-nav {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.card-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--sub);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.card-dot:hover {
    background: var(--border);
    color: var(--text);
}

.card-dot:active {
    transform: scale(0.9);
}

.card-dot.active {
    color: var(--accent);
}

.card-dot svg {
    width: 18px;
    height: 18px;
}

/* Admin dot overrides */
.admin-dot-ok {
    color: var(--green);
}

.admin-dot-ok:hover {
    background: var(--green);
    color: white;
}

.admin-dot-del {
    color: var(--red);
}

.admin-dot-del:hover {
    background: var(--red);
    color: white;
}

/* Pending badge - teď na kartě */
.find-card {
    position: relative;
}

.pending-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    background: var(--pending-border);
    color: #1d1d1f;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Rozmazaná fotka čekající na schválení */
.card-panel-photo {
    position: relative;
}

.card-panel-photo img.blurred {
    filter: blur(20px);
    transform: scale(1.05);
}

.pending-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pending-overlay span {
    background: rgba(255,255,255,0.9);
    color: #636366;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* === LOADING === */
.feed-loading {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 30px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sub);
    animation: pulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* === EMPTY STATE === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--sub);
    text-align: center;
    gap: 16px;
}

.empty-state p {
    font-size: 15px;
    line-height: 1.5;
}

/* === ANIMACE === */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === RESPONZIVITA === */
@media (min-width: 768px) {
    .feed {
        padding-top: 84px;
    }
    
    .find-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }
}

@media (max-width: 380px) {
    .header-inner {
        padding: 10px 12px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .feed {
        padding: 68px 10px 30px;
        gap: 12px;
    }
}

/* === LEAFLET OVERRIDES (dark mode) === */
@media (prefers-color-scheme: dark) {
    .leaflet-control-zoom a {
        background: var(--card) !important;
        color: var(--text) !important;
        border-color: var(--border) !important;
    }
    
    .leaflet-control-attribution {
        background: rgba(44,44,46,0.8) !important;
        color: var(--sub) !important;
    }
    
    .leaflet-control-attribution a {
        color: var(--accent) !important;
    }
}
