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

:root {
    --bg: #0f0f0f;
    --card: #1a1a1a;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #a855f7;
    --accent-hover: #9333ea;
    --danger: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px 80px;
}

/* Header */
.header {
    position: relative;
    margin-bottom: 24px;
}

.cover {
    position: relative;
    width: 100%;
    height: 220px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 0 0 20px 20px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70%;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    pointer-events: none;
}

.header-info {
    position: relative;
    z-index: 2;
    padding: 20px;
    width: 100%;
}

.header-info h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.header-info p {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Admin Panel */
.admin-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.admin-bar h3 {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--accent);
}

/* Tags */
.tags-wrapper {
    margin-bottom: 20px;
    padding: 0 4px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.tags-container.collapsed {
    max-height: 88px; /* ~2 rows */
}

.tags-container.expanded {
    max-height: 2000px;
}

.tags-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tags-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tags-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.7rem;
}

.tags-wrapper.expanded .tags-toggle-icon {
    transform: rotate(180deg);
}

.tags-wrapper.expanded .tags-toggle-text::after {
    content: '';
}

.tag {
    display: inline-block;
    padding: 6px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    user-select: none;
}

.tag:hover, .tag.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tag-count {
    opacity: 0.6;
    font-size: 0.75rem;
}

/* Posts */
.post {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 16px;
    overflow: hidden;
}

.post-media {
    position: relative;
    background: #000;
}

.post-media img, .post-media video {
    width: 100%;
    display: block;
    max-height: 500px;
    object-fit: contain;
}

/* Video container with thumbnail */
.video-container {
    position: relative;
    cursor: pointer;
    background: #000;
}

.video-thumb {
    width: 100%;
    display: block;
    max-height: 500px;
    object-fit: contain;
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.video-container.playing video {
    opacity: 1;
}

.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background: rgba(168, 85, 247, 0.9);
    border-radius: 50%;
    z-index: 2;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    padding-left: 5px;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.video-container:hover .video-play-btn {
    transform: translate(-50%, -50%) scale(1.1);
    background: rgba(147, 51, 234, 0.95);
}

.video-container.playing .video-play-btn {
    opacity: 0;
    pointer-events: none;
}

/* Media Overlay */
.media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.media-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.media-number {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.8), rgba(236, 72, 153, 0.8));
    font-weight: 700;
}

.media-duration {
    background: rgba(0, 0, 0, 0.65);
}

.media-price {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.8), rgba(16, 185, 129, 0.8));
}

.video-container.playing ~ .media-overlay {
    opacity: 0;
    transition: opacity 0.3s;
}

.post-media:hover .media-overlay {
    background: linear-gradient(transparent 30%, rgba(0,0,0,0.8));
}

.post-content {
    padding: 16px;
}

.post-text {
    font-size: 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Links in text */
.post-text a,
.header-info a {
    color: #60a5fa;
    text-decoration: none;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.1), rgba(59, 130, 246, 0.1));
    padding: 1px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border-bottom: none;
}

.post-text a:hover,
.header-info a:hover {
    color: #93c5fd;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.25), rgba(59, 130, 246, 0.25));
}

/* Telegram links */
.tg-link {
    color: #c084fc !important;
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.15), rgba(168, 85, 247, 0.15)) !important;
    font-weight: 500;
}

.tg-link:hover {
    color: #d8b4fe !important;
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.3), rgba(168, 85, 247, 0.3)) !important;
}

.post-text[contenteditable="true"] {
    outline: none;
    border: 1px dashed var(--accent);
    padding: 8px;
    border-radius: 8px;
    min-height: 50px;
}

.post-tags {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.post-tags .tag {
    font-size: 0.8rem;
    padding: 4px 10px;
}

.post-tags-edit {
    margin-top: 8px;
}

.post-tags-edit input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

/* Admin Controls */
.post-admin {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

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

.form-group input[type="file"] {
    padding: 8px;
}

/* New Post Form */
.new-post-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.new-post-form h3 {
    margin-bottom: 16px;
    font-size: 1rem;
}

/* Settings Form */
.settings-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-form h3 {
    margin-bottom: 16px;
    font-size: 1rem;
}

/* Topics Manager */
.topics-manager {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.topics-manager h3 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.topics-manager .help-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.topic-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.topic-form input {
    flex: 1;
    min-width: 150px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.existing-tags {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
}

.existing-tags strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mini-tag {
    padding: 4px 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.mini-tag:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

.topic-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    gap: 12px;
}

.topic-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.topic-name {
    font-weight: 600;
    color: var(--accent);
}

.topic-tags-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.topic-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.topic-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Editable header */
.header-info h1[contenteditable="true"],
.header-info p[contenteditable="true"] {
    outline: none;
    border: 1px dashed var(--accent);
    padding: 4px 8px;
    border-radius: 6px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h2 {
    margin-bottom: 8px;
    color: var(--text);
}

/* Logout */
.logout-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

/* Media delete btn */
.media-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 0 8px 80px;
    }
    .cover {
        height: 180px;
    }
    .header-info h1 {
        font-size: 1.3rem;
    }
    .header-info p {
        font-size: 0.85rem;
    }
}

/* Loading overlay */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
    font-size: 1.2rem;
}

.loading.active {
    display: flex;
}

/* Telegram links */
a.tg-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 1px solid transparent;
}

a.tg-link:hover {
    color: #c084fc;
    border-bottom-color: var(--accent);
}

.header-info a.tg-link {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.header-info a.tg-link:hover {
    color: var(--accent);
}

/* 18+ Modal */
.age-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.age-modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    text-align: center;
}

.age-modal-content h2 {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--danger);
}

.age-modal-content p {
    margin-bottom: 24px;
    color: var(--text-muted);
    line-height: 1.5;
}

.age-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.age-modal-buttons .btn {
    min-width: 120px;
}

/* Infinite scroll loader */
.load-more-trigger {
    display: flex;
    justify-content: center;
    padding: 30px 0;
}

.load-more-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Post fade-in animation */
.post.fade-in {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
