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

:root {
    --bg: #fafafa;
    --card: #ffffff;
    --border: #dbdbdb;
    --border-light: #efefef;
    --text: #262626;
    --text-secondary: #8e8e8e;
    --accent: #0095f6;
    --accent-hover: #1877f2;
    --danger: #ed4956;
    --heart: #ed4956;
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --max-width: 470px;
}

html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--text); text-decoration: none; }
img, video { max-width: 100%; display: block; }
button, input, textarea { font-family: inherit; font-size: inherit; }

/* === Header === */
.header {
    position: sticky;
    top: 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.95);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    flex: 1;
}

.back-link {
    font-size: 24px;
    color: var(--text);
    line-height: 1;
    flex: 0;
}

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

.header-link {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-link.active,
.header-link:hover {
    color: var(--text);
}

/* === Feed === */
.feed {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 0 60px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* === Post Card === */
.post-card {
    background: var(--card);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 12px;
}

@media (min-width: 500px) {
    .post-card {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 20px;
    }
    .feed { padding: 20px 0 60px; }
}

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
}

.post-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.post-author {
    font-weight: 600;
    font-size: 14px;
}

.post-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.post-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

/* === Media / Carousel === */
.post-media {
    position: relative;
    background: #000;
    overflow: hidden;
}

.post-media img,
.post-media video {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.carousel-track {
    display: flex;
    transition: transform 0.3s ease;
}

.carousel .carousel-slide {
    min-width: 100%;
    flex-shrink: 0;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.85);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 5px rgba(0,0,0,0.15);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text);
}

.post-media:hover .carousel-btn { opacity: 1; }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 2;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: background 0.2s, transform 0.2s;
}

.dot.active {
    background: white;
    transform: scale(1.2);
}

/* === Actions (like) === */
.post-actions {
    padding: 8px 14px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.like-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: transform 0.15s;
}

.like-btn:active { transform: scale(1.2); }

.like-btn svg {
    fill: none;
    stroke: var(--text);
    stroke-width: 2;
    transition: fill 0.2s, stroke 0.2s;
}

.like-btn.liked svg {
    fill: var(--heart);
    stroke: var(--heart);
}

.like-btn.animating {
    animation: heartPop 0.4s ease;
}

@keyframes heartPop {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.like-count {
    font-size: 14px;
    font-weight: 600;
}

/* === Post Body === */
.post-body {
    padding: 4px 14px 8px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.post-body-author {
    font-weight: 600;
    margin-right: 4px;
}

/* === Comments === */
.post-comments {
    padding: 0 14px 4px;
}

.view-all-comments {
    display: block;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.comment {
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.4;
    word-wrap: break-word;
}

.comment-author {
    font-weight: 600;
    margin-right: 4px;
}

.comment-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.comment-form {
    border-top: 1px solid var(--border-light);
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comment-name {
    border: none;
    padding: 4px 0;
    font-size: 13px;
    outline: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
}

.comment-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.comment-text {
    flex: 1;
    border: none;
    padding: 4px 0;
    font-size: 14px;
    outline: none;
    background: transparent;
}

.comment-submit {
    background: none;
    border: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

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

.all-comments-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 12px;
}

.comments-heading {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* === Loading === */
.load-more {
    text-align: center;
    padding: 20px;
}

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

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

/* === Admin === */
.admin-feed { padding-top: 20px; }

.admin-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.admin-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-form input[type="text"],
.admin-form input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    background: var(--bg);
}

.admin-form input:focus,
.admin-form textarea:focus {
    outline: none;
    border-color: var(--text);
}

.post-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    resize: vertical;
    min-height: 80px;
    background: var(--bg);
    line-height: 1.5;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area.dragover {
    border-color: var(--accent);
    background: rgba(0, 149, 246, 0.05);
}

.upload-placeholder {
    color: var(--text-secondary);
}

.upload-placeholder svg { margin: 0 auto 8px; color: var(--text-secondary); }
.upload-placeholder p { font-size: 14px; }
.upload-hint { font-size: 12px; margin-top: 2px; }

.upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.preview-item {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-thumb {
    width: 100%;
    height: 100%;
    background: #333;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    text-align: center;
    padding: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--text);
    color: white;
    border-color: var(--text);
}

.btn-primary:hover { background: #404040; }

.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fce4ec; }

.btn-small { padding: 6px 12px; font-size: 13px; }

/* Admin post list */
.admin-post-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.admin-post-item:last-child { border-bottom: none; }

.admin-post-preview {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg);
}

.admin-post-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-post-info { flex: 1; min-width: 0; }

.admin-post-body {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-post-stats {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.admin-post-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 14px;
}

/* Edit media */
.edit-media-list h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.edit-media-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-media-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.edit-media-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
}

.delete-check {
    font-size: 13px;
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-actions {
    display: flex;
    gap: 8px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-error { background: #fce4ec; color: #c62828; }

/* Mobile optimizations */
@media (max-width: 500px) {
    .admin-post-actions {
        flex-direction: column;
    }
    .admin-post-actions .btn-small {
        padding: 8px 10px;
    }
    .carousel-btn { opacity: 0.7; width: 26px; height: 26px; font-size: 16px; }
}

/* reCAPTCHA badge - hide it, we show our own notice */
.grecaptcha-badge { visibility: hidden; }
