: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: var(--glass-shadow); transition: transform 0.2s ease, background 0.2s; }


.glass-panel {
    /* Ein sehr feiner innerer Schatten oben simuliert eine Lichtreflexion */
    box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.3), var(--glass-shadow);
}

/* 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 */
.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); }
.back-button { display:none; margin-right: 15px; font-size: 24px; color: var(--primary-color); background: none; border: none; cursor: pointer; padding: 10px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; scroll-behavior: smooth; }

.message-bubble { background: rgba(255, 255, 255, 0.95); padding: 14px 20px; border-radius: 22px; border-bottom-left-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); max-width: 768px; width: 100%; margin-bottom: 15px; font-size: 16px; line-height: 1.5; word-wrap: break-word; position: relative; }
.message-bubble.highlighted { animation: highlightPulse 2s ease-out; }
@keyframes highlightPulse { 0% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.7); } 100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0); } }

.message-meta { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(0,0,0,0.05); color: var(--text-secondary); }
.message-time { font-size: 12px; }

/* INPUT */
.chat-input-area { padding: 20px; background: transparent; display: flex; flex-direction: column; gap: 10px; }
.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); }

/* SYSTEM PAGE */
.system-page-content { background: rgba(255,255,255,0.9); padding: 40px; border-radius: 20px; max-width: 800px; margin: 0 auto; line-height: 1.6; }
.system-page-content h1, .system-page-content h2 { margin-top: 20px; margin-bottom: 10px; }
.system-page-content a, .chat-link { color: var(--primary-color); text-decoration: none; }

/* MISC */
.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 Hintergrund 
.modal {
    display: none; 
    position: fixed; 
    z-index: 9999; 
    left: 0; top: 0; 
    width: 100%; height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(5px);
    align-items: center; 
    justify-content: center;
}
*/
/* Modal Inhalt 
.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: var(--radius-l);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--glass-shadow);
}
*/

.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; }

.message-media img, .message-media video, .message-media audio { width: 100%; display: block; border-radius: 12px; margin-top: 10px;}
.admin-only { display: none !important; }
.logged-in .admin-only { display: inline-block !important; }
.logged-in .message-actions { display: flex !important; }
.message-actions { display: none; gap: 5px; }
.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); }
.file-preview { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0; }
.preview-item { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; background: #eee; }
.preview-item img, .preview-item video { width: 100%; height: 100%; object-fit: cover; }
.preview-remove { position: absolute; top: 0; right: 0; background: rgba(0,0,0,0.5); color: white; width: 20px; height: 20px; text-align: center; line-height: 20px; font-size: 12px; cursor: pointer; }

/* VIDEO FIXES */
.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; }
.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.1); color: #333; border: none; padding: 10px 20px; border-radius: 12px; cursor: pointer; font-weight: 600; margin-left: 5px; }
.btn-danger { background: #ff3b30; color: white; border: none; border-radius: 12px; cursor: pointer; }


#messageContainer {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Verhindert, dass der Browser versucht, die Scrollposition 
       beim Laden neuer Inhalte "intelligent" zu raten */
    overflow-anchor: none; 
    scroll-behavior: auto; /* Deaktiviere 'smooth', um exakte Landungen zu garantieren */
    align-items: center;
}

/* --- UPLOAD STATUS & PROGRESS --- */
.input-area {
    position: relative; /* Wichtig für die Positionierung des Balkens */
}

#uploadProgressContainer {
    display: none; /* Standardmäßig unsichtbar */
    position: absolute;
    top: -25px;
    left: 0;
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 12px;
    color: var(--primary-color);
    border-top: 1px solid #ccc;
    box-sizing: border-box;
}

#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;
}

/* Deaktiviertes Eingabefeld während Upload */
.uploading-active textarea, 
.uploading-active button,
.uploading-active .file-btn {
    opacity: 0.5;
    pointer-events: none; /* Verhindert Klicks */
    cursor: wait;
}


.msg-img, .msg-vid {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 5px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.preview-thumb {
    width: 50px; height: 50px; 
    border-radius: 8px; 
    background: #ddd; 
    display: inline-block; 
    overflow: hidden; 
    margin-right: 5px;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }

.highlight-post {
    animation: pulseHighlight 2s ease-out;
    border: 2px solid #007AFF;
}
@keyframes pulseHighlight {
    0% { background-color: rgba(0, 122, 255, 0.3); }
    100% { background-color: transparent; }
}

.loader-spinner {
    width: 24px;
    height: 24px;
    margin: 15px auto;
    border: 2px solid rgba(0, 0, 0, 0.05); /* Fast unsichtbarer Ring */
    border-top: 2px solid var(--primary-color); /* Apple Blau */
    border-radius: 50%;
    /* Sanftere Animation */
    animation: apple-spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    /* Glassmorphism Effekt */
    backdrop-filter: blur(5px);
    filter: drop-shadow(0 0 2px rgba(0, 122, 255, 0.2));
}

@keyframes apple-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.h3-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}

/* START: Integrierter Liquid Glass Feed */
.startfeed-post {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; /* Zentriert das Panel wie in der Seitenansicht */
    overflow: hidden;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
    /* Ein weicher Mesh-Hintergrund-Effekt für den Feed-Hintergrund */
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1) 0%, transparent 80%);
}



/* Der Bereich für den eigentlichen Inhalt (Text/Bilder) */
.startfeed-content-area {
    flex: 1;
    /* overflow-y: auto; */
    padding: 25px;
}

.startfeed-bottombarBK {
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    border-radius: 14px;
}

.startfeed-page-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: var(--radius-m);
    transition: background 0.3s ease;
}

.startfeed-page-badge:hover {
    background: rgba(255, 255, 255, 0.3);
}

.startfeed-page-badge .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 2px solid #fff;
}

/* Scroll-Indikator für das Apple-Feeling */
.startfeed-hint {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.4);
    padding: 4px 12px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    z-index: 10;
}

.startfeed-bubble {
    width: 100%;
    max-width: 550px;
    height: 80vh !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
}
/* END */



/* MOBILE RESPONSIVE FIX */
@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); }
    .app-container.chat-active .sidebar { display: none; } 
    .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; }
