:root {
    --fb-blue: #1877F2;
    --fb-bg: #F0F2F5;
    --fb-white: #FFFFFF;
    --fb-text-primary: #050505;
    --fb-text-secondary: #65676B;
    --fb-border: #CED0D4;
    --fb-hover: #E4E6E9;
    --fb-danger: #E41E3F;
    --fb-danger-hover: #C91A37;
    --fb-danger-bg: #FFEBEB;
    --fb-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--fb-bg);
    color: var(--fb-text-primary);
    overflow-y: scroll;
}

/* NAVBAR */
.navbar {
    height: 56px;
    background-color: var(--fb-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fb-logo ion-icon {
    font-size: 40px;
    color: var(--fb-blue);
}

.search-bar {
    background-color: var(--fb-bg);
    border-radius: 50px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 40px;
}

.search-bar ion-icon {
    color: var(--fb-text-secondary);
    font-size: 18px;
}

.search-bar input {
    border: none;
    background: transparent;
    padding: 8px;
    outline: none;
    width: 200px;
}

.nav-center {
    display: flex;
    gap: 8px;
    height: 100%;
}

.nav-icon {
    width: 110px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 26px;
    color: var(--fb-text-secondary);
    border-bottom: 3px solid transparent;
    transition: background 0.2s;
    border-radius: 8px;
    margin: 4px 0;
}

.nav-icon:hover {
    background-color: var(--fb-hover);
}

.nav-icon.active {
    color: var(--fb-blue);
    border-bottom: 3px solid var(--fb-blue);
    border-radius: 0;
    margin: 0;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-btn img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--fb-hover);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
}

/* LAYOUT */
.container {
    display: flex;
    justify-content: space-between;
    padding-top: 76px; /* navbar height + margin */
    max-width: 1600px;
    margin: 0 auto;
}

/* SIDEBARS */
.left-sidebar, .right-sidebar {
    width: 25%;
    max-width: 360px;
    min-width: 280px;
    padding: 0 8px;
    position: sticky;
    top: 76px;
    height: calc(100vh - 76px);
}

.right-sidebar {
    display: none;
}
@media (min-width: 1100px) {
    .right-sidebar { display: block; }
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.sidebar-item:hover {
    background-color: var(--fb-hover);
}

.sidebar-item img {
    border-radius: 50%;
    width: 36px;
    height: 36px;
}

.sidebar-item ion-icon {
    font-size: 32px;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--fb-border);
    margin: 12px 16px;
}

.sidebar-title {
    padding: 0 16px;
    color: var(--fb-text-secondary);
    font-size: 17px;
    margin-bottom: 8px;
}

.lab-goals {
    padding-left: 16px;
    list-style: none;
    color: var(--fb-text-secondary);
    margin-top: 10px;
}
.lab-goals li {
    padding: 6px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background-color: var(--fb-danger);
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: auto;
}

/* FEED */
.feed {
    width: 50%;
    max-width: 680px;
    min-width: 500px;
    margin: 0 auto;
}

.card {
    background-color: var(--fb-white);
    border-radius: 8px;
    box-shadow: var(--fb-shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

/* CREATE POST */
.create-post {
    padding: 12px 16px 10px;
}

.create-post-top {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.create-post-top img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.create-post-top input {
    flex: 1;
    border-radius: 20px;
    background-color: var(--fb-bg);
    border: none;
    padding: 0 16px;
    font-size: 17px;
    outline: none;
    cursor: text;
}
.create-post-top input:hover {
    background-color: var(--fb-hover);
}

.create-post-bottom {
    display: flex;
    border-top: 1px solid var(--fb-border);
    padding-top: 8px;
}

.action-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--fb-text-secondary);
    font-weight: 600;
}
.action-btn:hover { background-color: var(--fb-hover); }
.action-btn ion-icon { font-size: 24px; }

.post-submit-container {
    padding-top: 10px;
    animation: fadeIn 0.3s;
}

.btn-primary {
    background-color: var(--fb-blue);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.btn-primary:hover { background-color: #166fe5; }
.full-width { width: 100%; }

/* POSTS */
.post {
    padding-top: 12px;
}

.lab-tag {
    font-size: 12px;
    font-weight: bold;
    padding: 4px 12px;
    display: inline-block;
    border-radius: 0 16px 16px 0;
    margin-bottom: 8px;
    text-transform: uppercase;
}
.lab-tag.bad { background-color: #FFEBEB; color: #E41E3F; }
.lab-tag.good { background-color: #E8F4FD; color: #1877F2; }
.lab-tag.recovery { background-color: #FFF3E0; color: #E65100; }

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    margin-bottom: 12px;
}

.post-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.post-info h4 {
    font-size: 15px;
    font-weight: 600;
}

.post-info span {
    font-size: 13px;
    color: var(--fb-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-content {
    font-size: 15px;
    padding: 0 16px 12px;
    line-height: 1.4;
}

/* Post Actions (Edit, Save, Delete) */
.post-actions {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    background-color: #F8F9FA;
    border-top: 1px solid var(--fb-border);
    border-bottom: 1px solid var(--fb-border);
}

/* Phase 1: Bad Design */
.bad-actions {
    display: flex;
    justify-content: flex-end; /* Group them to the right to make them closely packed */
    gap: 0; 
    background-color: #FDFDFD;
    padding: 12px 16px;
    border-top: 1px solid var(--fb-border);
    border-bottom: 1px solid var(--fb-border);
}
.btn-bad {
    padding: 6px 12px;
    border: 1px solid var(--fb-border);
    background-color: var(--fb-white);
    color: var(--fb-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 14px;
    cursor: pointer;
    margin-right: -1px; /* overlap borders */
}
.btn-bad:hover { background-color: var(--fb-hover); }

/* Phase 2: Good Design */
.good-actions {
    justify-content: space-between;
}
.safe-actions {
    display: flex;
    gap: 8px;
}
.btn-safe {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background-color: var(--fb-hover);
    color: var(--fb-text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.btn-safe:hover { background-color: #D8DADF; }

.btn-danger {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background-color: var(--fb-danger-bg);
    color: var(--fb-danger);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.btn-danger:hover { background-color: var(--fb-danger-hover); color: white; }

.post-footer {
    display: flex;
    padding: 4px 16px;
}

.footer-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    color: var(--fb-text-secondary);
    font-weight: 600;
    font-size: 15px;
    border-radius: 4px;
    cursor: pointer;
}
.footer-btn:hover { background-color: var(--fb-hover); }

/* TRASH VIEW */
.trash-header {
    padding: 16px;
    text-align: center;
}
.trash-header h2 { font-size: 20px; margin-bottom: 8px; }
.warning-text { color: var(--fb-danger); font-size: 14px; margin-bottom: 12px; }

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--fb-text-secondary);
}
.empty-state ion-icon { font-size: 48px; margin-bottom: 16px; }

.trashed-post {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: var(--fb-white);
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: var(--fb-shadow);
    border-left: 4px solid var(--fb-danger);
    animation: fadeIn 0.3s;
}

.trashed-post-info {
    flex: 1;
}

.trashed-post-text {
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--fb-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.trashed-post-date {
    font-size: 13px;
    color: var(--fb-danger);
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-restore {
    background-color: #45BD62;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}
.btn-restore:hover { background-color: #36A420; }

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(244, 244, 244, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--fb-white);
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 12px 28px 0 rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--fb-border);
}
.modal-header h2 { font-size: 20px; font-weight: 700; text-align: center; flex: 1; margin: 0; }
.close-modal {
    width: 36px; height: 36px; border-radius: 50%;
    background-color: var(--fb-hover);
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 20px; color: var(--fb-text-secondary);
}

.modal-body { padding: 16px; font-size: 15px; line-height: 1.4; color: var(--fb-text-secondary); }

.constraint-container {
    margin-top: 16px;
    background-color: var(--fb-bg);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--fb-border);
}

.constraint-container label { display: block; margin-bottom: 8px; color: var(--fb-text-primary); }

.constraint-container input {
    width: 100%; padding: 10px; border: 1px solid var(--fb-border);
    border-radius: 6px; font-size: 16px; outline: none;
}
.constraint-container input:focus { border-color: var(--fb-blue); }

.modal-footer {
    padding: 16px; border-top: 1px solid var(--fb-border);
    display: flex; justify-content: flex-end; gap: 8px;
}

.btn-danger-solid {
    background-color: var(--fb-danger); color: white; border: none;
    padding: 8px 32px; border-radius: 6px; font-weight: 600; cursor: pointer;
}
.btn-danger-solid.disabled { background-color: var(--fb-border); color: #888; cursor: not-allowed; }
.btn-danger-solid:not(.disabled):hover { background-color: var(--fb-danger-hover); }

/* TOAST */
.toast {
    position: fixed;
    bottom: 24px; left: 24px;
    background-color: #333; color: white;
    padding: 12px 16px; border-radius: 8px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000; transition: transform 0.3s, opacity 0.3s;
}
.toast.hidden { transform: translateY(100px); opacity: 0; pointer-events: none; }
.toast-icon { font-size: 20px; color: #45BD62; }

/* UTILITIES */
.hidden { display: none !important; }
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Image Preview Area */
.image-preview-container {
    position: relative;
    margin: 10px 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--fb-border);
}
.image-preview {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    background-color: #000;
    display: block;
}
.remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.remove-image-btn:hover { background: #fff; }

.post-image {
    width: 100%;
    margin-bottom: 8px;
}
.post-image img {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    display: block;
}

/* Post Inline Editing */
.edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid var(--fb-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}
.edit-textarea:focus {
    outline: none;
    border-color: var(--fb-blue);
    box-shadow: 0 0 0 2px #E8F4FD;
}

.splash-header {
    padding: 20px;
    text-align: center;
    background: #FFEBEB;
    border: 1px solid #E41E3F;
    margin-bottom: 16px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1100px) {
    .right-sidebar { display: none; }
    .feed { width: 65%; min-width: unset; }
    .left-sidebar { width: 35%; min-width: unset; }
}

@media (max-width: 768px) {
    .container { flex-direction: column; padding-top: 56px; }
    
    .mobile-hide { display: none !important; }
    .mobile-show { display: flex !important; }

    .left-sidebar { 
        width: 100%; 
        height: calc(100vh - 56px);
        position: fixed; 
        top: 56px;
        left: -100%;
        background-color: var(--fb-bg);
        z-index: 1000;
        padding: 16px; 
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    .left-sidebar.show {
        left: 0;
    }
    
    .feed { width: 100%; min-width: unset; max-width: 100%; padding: 0 8px; }
    .nav-center { display: none; } /* Simplify top nav */
    .nav-left { flex: 1; margin-right: 12px; }
    .search-bar { width: 100%; max-width: 100%; }
    .search-bar input { width: 100%; }
    
    /* Make Trash Bin Responsive */
    .trashed-post {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .trashed-post-text {
        white-space: normal;
        max-width: 100%;
        word-break: break-word;
    }
    .btn-restore {
        width: 100%;
    }
}

