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

* { 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/background.jpg') no-repeat center center fixed;
    background-size: cover;  */
    color: var(--text-color); font-size: 16px;
    /* background-color: mistyrose; */
    /* background-color: lavender;*/
    /* background-color: #fae6e6;
    background-color: #ebebeb;
    background-color: #eef2f6;*/
    background-color: #dde7f1;
    /* background-color: linen; */
}

.app-container { display: flex; height: 100vh; height: 100dvh; width: 100vw; padding: 20px; gap: 20px; position: relative; }
.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: 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: var(--glass-bg-hover); box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.5); }

.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; word-break: break-word;}

/* 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; }

/* FILTERS */
.feed-filters select { padding: 10px 20px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); background: rgba(255,255,255,0.5); font-size: 12px; outline: none; cursor: pointer; }
.feed-filters select:focus { background: white; }

/* FEED CONTAINER */
.chat-messages { flex: 1; position: relative; overflow: hidden; width: 100%; height: 100%; }

/* POST POSITIONING & ANIMATION */
.startfeed-post {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%; 
    display: flex; align-items: center; justify-content: center;
    padding: 20px; 
    will-change: transform, opacity;
    /* Wichtig: Standardmäßig unsichtbar oder im Flow, wird durch Klassen gesteuert */
}

/* Animations-Keyframes */
@keyframes slideInFromBottom { 0% { transform: translateY(100%); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes slideOutToTop { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-100%); opacity: 0; } }

@keyframes slideInFromTop { 0% { transform: translateY(-100%); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes slideOutToBottom { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(100%); opacity: 0; } }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Animations-Klassen */
.fade-in { animation: fadeIn 0.4s ease forwards; z-index: 10; }

.slide-in-bottom { animation: slideInFromBottom var(--anim-duration) cubic-bezier(0.22,0.9,0.36,1) forwards; z-index: 10; }
.slide-in-top { animation: slideInFromTop var(--anim-duration) cubic-bezier(0.22,0.9,0.36,1) forwards; z-index: 10; }

/* Exit-Klassen: WICHTIG pointer-events:none */
.slide-out-top { animation: slideOutToTop var(--anim-duration) cubic-bezier(0.22,0.9,0.36,1) forwards; z-index: 5; pointer-events: none; }
.slide-out-bottom { animation: slideOutToBottom var(--anim-duration) cubic-bezier(0.22,0.9,0.36,1) forwards; z-index: 5; pointer-events: none; }


.message-bubble { 
    background: var(--glass-bg-hover); padding: 0; border-radius: 22px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); width: 100%; max-width: 666px; 
    max-height: 100%; display: flex; flex-direction: column; 
    overflow: hidden; border: 1px solid rgba(255,255,255,0.5);
}

.startfeed-content-area { padding: 25px; flex: 1; overflow-y: auto; overscroll-behavior: contain; align-content: center; }

/* INPUT & UI */
.chat-input-area { padding: 0px 20px; background: transparent; display: flex; flex-direction: column; gap: 1px; z-index: 20; position: relative; }
.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); position: relative; }
.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); }

#uploadProgressContainer { display: none; position: absolute; bottom: 100%; left: 20px; right: 20px; margin-bottom: 5px; height: 30px; background: rgba(255,255,255,0.95); padding: 0 15px; align-items: center; font-size: 12px; color: var(--primary-color); border-radius: 15px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); z-index: 100; }
#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; }

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

.chat-link { color: var(--text-secondary); text-decoration: none; }

.content { font-size: 16px; line-height: 1.6; word-wrap: break-word; }
.message-media {
}

.message-media img,
.message-media video,
.message-media audio {
  height: auto;
  max-width: 592px;
  max-height: 595px;
  object-fit: contain;

  display: block;
  border-radius: 12px;
  margin-top: 10px;
  margin-left: auto;
  margin-right: auto;
}

/*.message-media img, .message-media video, .message-media audio {max-width: 592px; max-height: 598px; display: block; border-radius: 12px; margin-top: 10px; margin-left: auto; margin-right: auto;}*/


img {cursor: pointer;}
.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); }

.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-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: 18px; opacity: 0.8; }
.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%; backdrop-filter: blur(var(--blur-strength)); align-items: center; justify-content: center; }
.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; }
.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); } }
@keyframes fadeup { from { opacity:0; transform:translate(-50%, 20px); } to { opacity:1; transform:translate(-50%, 0); } }

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

.uploading-active textarea, .uploading-active button { opacity: 0.5; pointer-events: none; }
.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; }
.sidebar .page-list + div { padding-bottom: 30px; }

h3{
    word-break: break-word;
}



/* --- RIGHT SIDEBAR (Chat P2P) --- */
.chat-sidebar {
    width: 25%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: transform 0.3s ease;
    overflow: hidden;

    
    padding-left: 10px;
    padding-right: 10px;
    display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; 
}
.chat-sidebar iframe {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-s);
    border: none;
    display: block;
}


/* Button to toggle right chat on mobile */
.chat-toggle-btn {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* MOBILE FADE TRANSITION */
@media (max-width: 1400px) {

    /* Rechte Sidebar (Chat) */
    .chat-sidebar {
        position: absolute; right: 0; top: 0; width: 100%; height: 100dvh;
        transform: translateX(100%); z-index: 30;
    }

    /* States */
    /* Navi offen */
    .app-container.nav-active .sidebar { transform: translateX(0); opacity: 1; pointer-events: auto; }
    .app-container.nav-active .chat-area { display: none; }
    
    /* Chat offen */
    .app-container.right-chat-active .chat-sidebar { transform: translateX(0); }
    /* Wenn Chat offen ist, evtl. Main Area ausblenden oder überlagern */
    .app-container.right-chat-active .chat-area { opacity: 0.3; pointer-events: none; }
    
    .chat-sidebar {
        position: absolute;
        right: 0;
        top: 0;
        transform: translateX(100%);
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    }
    .chat-toggle-btn { display: block; }
    
    /* Wenn Chat aktiv ist (per JS Klasse) */
    .app-container.right-chat-active .chat-sidebar {
        transform: translateX(0);
    }

}

/* MOBILE FADE TRANSITION */
@media (max-width: 900px) {
    .app-container { padding: 0; gap: 0; }
    .sidebar, .chat-area { border-radius: 0; border: none; position: absolute; top: 0; left: 0; width: 100%; height: 100dvh; transition: opacity 0.3s ease; }
    .back-button { display: block; z-index: 25; }
    .sidebar { opacity: 1; z-index: 20; pointer-events: auto; }
    .chat-area { opacity: 0; z-index: 10; pointer-events: none; }
    .app-container.chat-active .sidebar { opacity: 0; z-index: 10; pointer-events: none; }
    .app-container.chat-active .chat-area { opacity: 1; z-index: 20; pointer-events: auto; }
    /* .chat-header-info { display: none;}*/
    
    .startfeed-content-area{padding: 20px;}
    .startfeed-post {padding: 10px;}
    
    .message-media img, .message-media video, .message-media audio {width: 100%;}
    .chat-sidebar {
        position: absolute;
        right: 0;
        top: 0;
        transform: translateX(100%);
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    }
    .chat-toggle-btn { display: block; }
    
    /* Wenn Chat aktiv ist (per JS Klasse) */
    .app-container.right-chat-active .chat-sidebar {
        transform: translateX(0);
    }


}

@media (max-width: 540px) {
    .avatar { display: none;}
    .chat-header-info { display: none;}
    .feed-filters select {padding: 10px 5px;}
    .page-item { justify-content: center;}
}

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



/* Menü Button für Legal Links */
.menu-btn {
  background: none; border: none; cursor: pointer; color: var(--text-sub);
  font-size: 1.2rem; padding: 4px;
}

/* Overlay Menu */
#menu-overlay {
  position: absolute; top: 80px; right: 10px;
  background: white; border: 1px solid #ddd;
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none; flex-direction: column; z-index: 100;
}
#menu-overlay a {
  padding: 12px 20px; text-decoration: none; color: #333; font-size: 0.9rem;
  border-bottom: 1px solid #eee;
}
#menu-overlay a:last-child { border-bottom: none; }
#lightbox {
       display: flex;
       position: fixed;
       z-index: 3000;
       left: 0;
       top: 0;
       width: 100vw;
       height: 100vh;
       backdrop-filter: blur(var(--blur-strength));
       align-items: center;
       justify-content: center;
       cursor: pointer;
}       
#lightboxImg {       
         width: 100%;
         height: 100%;
         max-width: 95vw;
         max-height: 95vh;
         object-fit: contain;
}
