:root {
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-bg-hover: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    --primary-color: #007AFF;
    --primary-gradient: linear-gradient(135deg, #007AFF, #0056b3);
    --text-color: #000000;
    --text-secondary: rgba(60, 60, 67, 0.6);
    --blur-strength: 40px;
    --radius-l: 28px;
    --radius-m: 18px;
    --radius-s: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }

body, html { height: 100%; width: 100%; overflow: hidden; }
body {
    background: url('img/photo-1618005182384-a83a8bd57fbe.jpeg') no-repeat center center fixed;
    background-size: cover; color: var(--text-color); font-size: 16px;
}

.app-container { display: flex; height: 100vh; width: 100vw; padding: 20px; gap: 20px; }
.glass-panel { background: var(--glass-bg); backdrop-filter: blur(var(--blur-strength)); -webkit-backdrop-filter: blur(var(--blur-strength)); border: 1px solid var(--glass-border); border-radius: var(--radius-l); box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.3), var(--glass-shadow); transition: transform 0.2s ease, background 0.2s; }

/* SIDEBAR */
.sidebar { width: 350px; display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.sidebar-header { padding: 24px; display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h3 { font-weight: 700; font-size: 22px; }

.search-bar { padding: 0 20px 15px 20px; }
.search-bar input { width: 100%; padding: 12px 16px; border-radius: var(--radius-s); border: none; background: rgba(118, 118, 128, 0.12); font-size: 16px; transition: background 0.2s; }
.search-bar input:focus { outline: none; background: rgba(255,255,255,0.5); }

.page-list { flex: 1; overflow-y: auto; padding: 10px 15px; }
.page-item { display: flex; padding: 14px; cursor: pointer; border-radius: var(--radius-m); margin-bottom: 8px; align-items: center; transition: all 0.2s; }
.page-item:hover { background-color: rgba(255,255,255,0.4); }
.page-item.active { background-color: rgba(255,255,255,0.8); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

.avatar { width: 50px; height: 50px; border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; margin-right: 15px; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.page-name { font-weight: 600; font-size: 17px; }

/* CHAT AREA */
.chat-area { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.chat-header { height: 80px; padding: 0 24px; display: flex; align-items: center; background: rgba(255,255,255,0.4); border-bottom: 1px solid rgba(0,0,0,0.05); z-index: 20; }
.back-button { display:none; margin-right: 15px; font-size: 24px; color: var(--primary-color); background: none; border: none; cursor: pointer; padding: 10px; }

/* FEED CONTAINER - SCROLL SNAP SETUP */
.chat-messages { 
    flex: 1; 
    overflow-y: scroll; /* Wichtig: Scroll */
    scroll-snap-type: y mandatory; /* Das magische CSS für Snap */
    scroll-behavior: smooth;
    display: flex; 
    flex-direction: column; 
    padding: 0; /* Kein Padding am Container, Padding kommt in den Post */
    position: relative;
}

/* FEED ITEM */
.startfeed-post {
    width: 100%;
    height: 100%; /* Nimmt immer volle Höhe des sichtbaren Bereichs */
    min-height: 100%;
    flex-shrink: 0;
    scroll-snap-align: start; /* Rastet am Anfang ein */
    scroll-snap-stop: always; /* Zwingt zum Anhalten */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px; /* Abstand zum Rand */
    position: relative;
}

/* BUBBLE STYLE */
.message-bubble { 
    background: rgba(255, 255, 255, 0.9); 
    padding: 0; 
    border-radius: 22px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    width: 100%; 
    max-width: 600px; 
    
    /* WICHTIG FÜR LANGE TEXTE: */
    max-height: 100%; 
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    border: 1px solid rgba(255,255,255,0.5);
}

/* CONTENT SCROLL INNERHALB DER BUBBLE */
.startfeed-content-area {
    padding: 25px;
    overflow-y: auto; 
    flex: 1;
    
    /* ÄNDERUNG: 'contain' zu 'auto' geändert (oder Zeile ganz löschen).
       Das erlaubt dem Browser, den äußeren Feed zu scrollen, 
       wenn das Ende des inneren Textes erreicht ist. */
    overscroll-behavior: auto; 
}

/* INPUT */
.chat-input-area { padding: 20px; background: transparent; display: flex; flex-direction: column; gap: 10px; z-index: 20; }
.input-wrapper { display: flex; gap: 12px; align-items: flex-end; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 26px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.5); }
.chat-input-area textarea { flex: 1; padding: 8px; border: none; background: transparent; outline: none; resize: none; max-height: 150px; min-height: 24px; font-size: 16px; font-family: inherit; }
.send-btn { background: var(--primary-color); color: white; border: none; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0, 122, 255, 0.3); }

/* CONTENT STYLES */
.message-meta { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(0,0,0,0.05); color: var(--text-secondary); }
.message-time { font-size: 12px; }
.content { font-size: 16px; line-height: 1.6; word-wrap: break-word; }
.chat-link { color: var(--primary-color); text-decoration: none; }

/* MEDIA */
.message-media img, .message-media video, .message-media audio { width: 100%; display: block; border-radius: 12px; margin-top: 10px;}
.video-preview-container { position: relative; border-radius: 12px; overflow: hidden; cursor: pointer; margin-top: 10px; }
.play-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.5); color: white; width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; pointer-events: none; backdrop-filter: blur(4px); }
.video-thumb { width: 100%; display: block; filter: brightness(0.9); }

/* BOTTOM BAR IN BUBBLE */
.startfeed-bottombar {
    height: 60px;
    background: rgba(245, 245, 247, 0.5);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}
.startfeed-page-badge { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: #333; text-decoration: none; }
.avatar-small { width: 28px; height: 28px; border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; font-size: 12px; }

/* ADMIN & MODALS */
.admin-only { display: none !important; }
.logged-in .admin-only { display: inline-block !important; }
.message-actions { display: none; gap: 5px; }
.logged-in .message-actions { display: flex !important; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 5px; font-size: 16px; opacity: 0.7; }
.btn-icon:hover { opacity: 1; color: var(--primary-color); }

.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.3); backdrop-filter: blur(10px); }
.modal-content { background: rgba(255,255,255,0.9); backdrop-filter: blur(30px); margin: auto; padding: 30px; border-radius: 30px; width: 90%; max-width: 380px; box-shadow: 0 25px 50px rgba(0,0,0,0.2); text-align: center; }
/* .modal-content { position: absolute; top: 50%; transform: translateY(-50%); }*/
.share-grid { display: flex; gap: 15px; justify-content: center; margin: 20px 0; }
.share-btn { width: 50px; height: 50px; border-radius: 14px; border: none; cursor: pointer; font-size: 24px; color: white; display: flex; align-items: center; justify-content: center; }
.share-btn.whatsapp { background: #25D366; } .share-btn.telegram { background: #0088cc; } .share-btn.copy { background: #8e8e93; }

.loader-spinner { width: 24px; height: 24px; border: 2px solid rgba(0,0,0,0.1); border-top: 2px solid var(--primary-color); border-radius: 50%; animation: spin 0.8s linear infinite; margin: auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* VIDEO IFRAME */
.video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 12px; margin-top: 10px; background: black; }
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.video-placeholder { margin-top: 8px; padding: 15px; background: rgba(0,0,0,0.03); border-radius: 12px; border: 1px dashed rgba(0,0,0,0.1); text-align: center; }

/* UPLOAD */
.uploading-active textarea, .uploading-active button { opacity: 0.5; pointer-events: none; }
#uploadProgressContainer { display: none; position: absolute; top: -25px; left: 0; width: 100%; height: 20px; background: rgba(255,255,255,0.9); padding: 0 10px; align-items: center; font-size: 12px; color: var(--primary-color); border-top: 1px solid #ccc; }
#uploadProgressBar { flex-grow: 1; height: 6px; background: #e0e0e0; border-radius: 3px; margin-left: 10px; overflow: hidden; }
#uploadProgressFill { width: 0%; height: 100%; background: var(--primary-color); transition: width 0.2s linear; }
.file-preview { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0; }
.preview-item { width: 40px; height: 40px; background: #eee; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.btn-primary { background: var(--primary-color); color: white; border: none; padding: 10px 20px; border-radius: 12px; cursor: pointer; font-weight: 600; }
.btn-secondary { background: rgba(0,0,0,0.05); color: #333; border: none; padding: 10px 20px; border-radius: 12px; cursor: pointer; font-weight: 600; margin-left: 5px; }
.h3-link { color: inherit; text-decoration: none; }

/* MOBILE */
@media (max-width: 768px) {
    .app-container { padding: 0; gap: 0; }
    .sidebar, .chat-area { border-radius: 0; border: none; width: 100%; }
    .chat-area { position: fixed; top: 0; left: 0; height: 100%; z-index: 50; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1); }
    .app-container.chat-active .chat-area { transform: translateX(0); }
    .back-button { display: block; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }
