/* -------------------------------------------------------------------------- */
/* Local Inter Font Setup                          */
/* -------------------------------------------------------------------------- */

/* 1. Variable Font (Modern Browsers - Best Performance) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/InterVariable.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/InterVariable-Italic.woff2') format('woff2');
}

/* 2. Static Fallbacks (For older browsers/tools that don't support Variable fonts) */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/Inter-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: italic; font-weight: 400; font-display: swap; src: url('/fonts/Inter-Italic.woff2') format('woff2'); }

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/Inter-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: italic; font-weight: 500; font-display: swap; src: url('/fonts/Inter-MediumItalic.woff2') format('woff2'); }

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/Inter-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: italic; font-weight: 600; font-display: swap; src: url('/fonts/Inter-SemiBoldItalic.woff2') format('woff2'); }

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/Inter-Bold.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: italic; font-weight: 700; font-display: swap; src: url('/fonts/Inter-BoldItalic.woff2') format('woff2'); }

/* -------------------------------------------------------------------------- */

:root {
    /* Defaults matching models.js defaults */
    --body-bg: #111827;
    --header-bg: #1f2937;
    --header-text: #f9fafb;
    --block-bg: #1f2937;
    --block-text: #d1d5db;
    
    /* Button Defaults */
    --btn-primary-bg: #2563eb;
    --btn-primary-text: #ffffff;
    --btn-success-bg: #16a34a;
    --btn-success-text: #ffffff;
    --btn-danger-bg: #dc2626;
    --btn-danger-text: #ffffff;
    --btn-warning-bg: #ca8a04;
    --btn-warning-text: #ffffff;
    --btn-secondary-bg: #4b5563;
    --btn-secondary-text: #ffffff;
    --btn-edit-post-bg: #4b5563; 
    --btn-edit-post-text: #ffffff;
    --btn-pm-bg: #4b5563; 
    --btn-pm-text: #ffffff;
    --btn-tag-bg: #4b5563; 
    --btn-tag-text: #ffffff;

    /* Admin/System Buttons */
    --btn-admin-bg: #ca8a04;
    --btn-admin-text: #ffffff;
    --btn-logout-bg: #dc2626;
    --btn-logout-text: #ffffff;
    --btn-edit-bg: #4b5563;
    --btn-edit-text: #ffffff;
    --btn-move-bg: #ca8a04;
    --btn-move-text: #ffffff;
    --btn-new-thread-bg: #16a34a;
    --btn-new-thread-text: #ffffff;
    --btn-back-bg: #4b5563;
    --btn-back-text: #ffffff;
    --btn-advanced-search-bg: #4b5563;
    --btn-advanced-search-text: #ffffff;
    --btn-file-input-bg: #0d9488;
    --btn-file-input-text: #ffffff;

    /* Inputs & UI */
    --input-bg: #111827;
    --input-filter-bg: #4b5563;
    --input-filter-text: #ffffff;
    --input-lang-bg: #1f2937; 
    --input-lang-text: #e5e7eb;
    --modal-bg: #1f2937;
    --modal-text: #e5e7eb;

    /* Topic List Colors */
    --topic-item-bg: #1f2937;          /* Default dark-gray/blue */
    --topic-title-text: #2dd4bf;       /* Default teal-400 */
    --topic-secondary-text: #9ca3af;   /* Default gray-400 */
    
    /* Topic Table Header (for old school design/admin) */
    --topic-header-bg: #111827;        /* Default dark background */
    --topic-header-text: #ffffff;

    /* Content Areas */
    --thread-bg: #374151;
    --thread-text: #e5e7eb;
    --thread-title-text: #2dd4bf;
    --thread-secondary-text: #9ca3af;
    --post-bg: #374151;     /* BAZINGA REMOVE?*/
    --post-text: #e5e7eb;   /* BAZINGA REMOVE?*/
    --reply-bg: #374151;
    --reply-item-bg: #111827;
    --active-topic-bg: #115e59;
    --active-topic-text: #ffffff;

    --post-sidebar-bg: #1f2937; /* Left: User Info */
    --post-header-bg: #1f2937;  /* Upper: Date/Edit */
    --post-content-bg: #374151; /* Middle: The text */
    --post-footer-bg: #1f2937;  /* Lower: Report/Like */

    /* Text Highlights */
    --site-title-text: #f9fafb;
    --topics-header-text: #f9fafb;
    --threads-header-text: #f9fafb;
    --right-block-header-text: #f9fafb;
    --post-username-text: #2dd4bf;
    --post-user-title-text: #facc15;

    /* Background Images Defaults */
    --page-bg-image: none;
    --page-bg-size: cover;
    --page-bg-repeat: no-repeat;
    --page-bg-position: center center;

    --left-block-bg-image: none;
    --left-block-bg-size: cover;
    --left-block-bg-repeat: no-repeat;
    --left-block-bg-position: center center;

    --middle-block-bg-image: none;
    --middle-block-bg-size: cover;
    --middle-block-bg-repeat: no-repeat;
    --middle-block-bg-position: center center;

    --right-block-bg-image: none;
    --right-block-bg-size: cover;
    --right-block-bg-repeat: no-repeat;
    --right-block-bg-position: center center;

    --banner-bg-image: none;
    --banner-bg-size: cover;
    --banner-bg-repeat: no-repeat;
    --banner-bg-position: center center;

    --footer-bg-image: none;
    --footer-bg-size: cover;
    --footer-bg-repeat: no-repeat;
    --footer-bg-position: center center;
}

/* Applying variables to the layout */
body {
    font-family: "Inter", sans-serif;
    background-color: var(--body-bg);
    background-image: var(--page-bg-image);
    background-size: var(--page-bg-size);
    background-repeat: var(--page-bg-repeat);
    background-position: var(--page-bg-position);
    background-attachment: fixed;
    color: var(--block-text);
}
.left-block {
    background-color: var(--left-block-bg);
    background-image: var(--left-block-bg-image);
    background-size: var(--left-block-bg-size);
    background-repeat: var(--left-block-bg-repeat);
    background-position: var(--left-block-bg-position);
}

.middle-block {
    background-color: var(--middle-block-bg);
    background-image: var(--middle-block-bg-image);
    background-size: var(--middle-block-bg-size);
    background-repeat: var(--middle-block-bg-repeat);
    background-position: var(--middle-block-bg-position);
}

.right-block {
    background-color: var(--right-block-bg);
    background-image: var(--right-block-bg-image);
    background-size: var(--right-block-bg-size);
    background-repeat: var(--right-block-bg-repeat);
    background-position: var(--right-block-bg-position);
}

#banner-container { 
    background-image: var(--banner-bg-image);
    background-size: var(--banner-bg-size);
    background-repeat: var(--banner-bg-repeat);
    background-position: var(--banner-bg-position);
}

#ad-slot-footer { 
    background-image: var(--footer-bg-image);
    background-size: var(--footer-bg-size);
    background-repeat: var(--footer-bg-repeat);
    background-position: var(--footer-bg-position);
}

.left-block > *, .middle-block > *, .right-block > * {
    position: relative; 
    z-index: 1;
}

.header-block {
    background-color: var(--header-bg);
    color: var(--header-text);
}

.content-block {
    background-color: var(--block-bg);
}

.text-color {
    color: var(--block-text);
}

.thread-item {
    background-color: var(--thread-bg);
    color: var(--thread-text);
}
.thread-title { 
    color: var(--thread-title-text); 
}

.thread-secondary { 
    color: var(--thread-secondary-text); 
}

.your-image-class {
  -webkit-mask-image: linear-gradient(to right, transparent 0%, transparent 60%, black 100%);
  mask-image: linear-gradient(to right, transparent 0%, transparent 60%, black 100%);
}

.netflix-overlay {
  /* For Thread images - Takes up the first 60% of the container */
  width: 60%; 
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  
  /* The Magic: Fade from opaque black (left) to transparent (right) */
  /*background: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);*/
  background: linear-gradient(
  to right, 
  rgba(0,0,0,0.9) 0%,   /* Starts 90% black */
  rgba(0,0,0,0.6) 40%,  /* Stays fairly dark until 40% width */
  rgba(0,0,0,0) 100%    /* Fades to nothing at the end */
);

  /* IMPORTANT: Allows clicks to pass through to the item underneath */
  pointer-events: none; 
}

.post-item {
    background-color: var(--post-bg);
    color: var(--post-text);
}

.site-title-color {
    color: var(--site-title-text);
}

.topics-header-color {
    color: var(--topics-header-text);
}

.topic-item-bg { background-color: var(--topic-item-bg); }
.topic-title { color: var(--topic-title-text); }
.topic-secondary { color: var(--topic-secondary-text); }
.topic-header-bg { background-color: var(--topic-header-bg); }
.topic-header-text { color: var(--topic-header-text); }

.threads-header-color {
    color: var(--threads-header-text);
}

.right-block-header-color {
    color: var(--right-block-header-text);
}

.reply-area {
    background-color: var(--reply-bg);
}

.post-username {
    color: var(--post-username-text);
}

.post-user-title {
    color: var(--post-user-title-text);
}

.modal-content-area {
    background-color: var(--modal-bg);
    color: var(--modal-text);
}

.active-topic {
    background-color: var(--active-topic-bg);
    color: var(--active-topic-text);
}

.themed-input:not(.lang-input),
#search-input,
.admin-table select,
#admin-panel-content input[type="search"],
#admin-panel-content select:not(.lang-input),
#inbox-list-container input[type="search"],
#inbox-list-container select {
    background-color: var(--input-filter-bg); 
    color: var(--input-filter-text);
    border: 1px solid #374151; 
}

.themed-input:not(.lang-input):focus,
#search-input:focus,
#admin-panel-content input[type="search"]:focus,
#admin-panel-content select:not(.lang-input):focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--btn-primary-bg); 
    border-color: var(--btn-primary-bg);
}
.lang-input {
    background-color: var(--input-lang-bg);
    color: var(--input-lang-text);
    border: 1px solid #374151;
}
.lang-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--btn-primary-bg);
    border-color: var(--btn-primary-bg);
}
/* Modal Windows */
.modal-content-area input[type="text"],
.modal-content-area input[type="email"],
.modal-content-area input[type="password"],
.modal-content-area input[type="url"],
.modal-content-area input[type="search"],
.modal-content-area input[type="number"],
.modal-content-area input[type="date"],
.modal-content-area input[type="datetime-local"],
.modal-content-area textarea,
.modal-content-area select {
    background-color: var(--input-bg);
    color: var(--modal-text);
    color-scheme: dark;
}

#reply-form textarea {
    background-color: var(--reply-item-bg);
}

/* File input button */
.themed-file-input::file-selector-button {
    background-color: var(--btn-file-input-bg);
    color: var(--btn-file-input-text);
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.themed-file-input::file-selector-button:hover {
    opacity: 0.9;
}

/* Button styles */
.btn {
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: opacity 0.2s;
    border: none;
    cursor: pointer;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary { background-color: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-success { background-color: var(--btn-success-bg); color: var(--btn-success-text); }
.btn-danger { background-color: var(--btn-danger-bg); color: var(--btn-danger-text); }
.btn-warning { background-color: var(--btn-warning-bg); color: var(--btn-warning-text); }
.btn-secondary { background-color: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-file-input { background-color: var(--btn-file-input-bg); color: var(--btn-file-input-text); }
.btn-edit { background-color: var(--btn-edit-bg); color: var(--btn-edit-text); }
.btn-move { background-color: var(--btn-move-bg); color: var(--btn-move-text); }
.btn-new-thread { background-color: var(--btn-new-thread-bg); color: var(--btn-new-thread-text); }
.btn-back { background-color: var(--btn-back-bg); color: var(--btn-back-text); }
.btn-admin { background-color: var(--btn-admin-bg); color: var(--btn-admin-text); }
.btn-logout { background-color: var(--btn-logout-bg); color: var(--btn-logout-text); }
.btn-advanced-search { background-color: var(--btn-advanced-search-bg); color: var(--btn-advanced-search-text); }
.btn-edit-post { background-color: var(--btn-edit-post-bg); color: var(--btn-edit-post-text);}
.btn-pm { background-color: var(--btn-pm-bg); color: var(--btn-pm-text); }
.btn-tag { background-color: var(--btn-tag-bg); color: var(--btn-tag-text); }

/* Fixed Tag Class using Variables */
.tag-badge-custom {
    /* Fallbacks are Indigo (default theme) */
    background-color: var(--tag-item-bg, rgba(49, 46, 129, 0.5)); 
    color: var(--tag-item-text, #c7d2fe);
    border: 1px solid var(--tag-item-border, rgba(99, 102, 241, 0.3));
    
    /* Fixed layout styles */
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem; /* px-2 py-0.5 */
    border-radius: 0.25rem;    /* rounded */
    font-size: 10px;
    font-weight: 500;
    margin-bottom: 0.25rem;    /* mb-1 */
    cursor: pointer;
    transition: all 0.2s;
}

.tag-badge-custom:hover {
    opacity: 0.8;
}

.themed-input {
    background-color: var(--btn-advanced-search-bg);
    color: var(--btn-advanced-search-text);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a202c; }
::-webkit-scrollbar-thumb { background: #4a5568; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #718096; }

.admin-table th, .admin-table td { padding: 0.75rem; text-align: left; }
.line-clamp-2 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.post-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
#site-banner {
    width: 100%;
    height: 100%;
    object-fit: fill;
    border-radius: 0.5rem;
}
#emoji-picker {
    position: absolute;
    display: none;
    z-index: 100;
    background-color: var(--modal-bg, #1F2937);
    border: 1px solid var(--input-filter-bg, #4B5563);
    border-radius: 0.5rem;
    width: 320px;
    height: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    color: var(--modal-text, #E5E7EB);
    flex-direction: column;
    overflow: hidden;
}

#emoji-search-bar {
    width: calc(100% - 1rem);
    margin: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--input-filter-bg, #4B5563);
    border-radius: 0.25rem;
    background-color: var(--input-bg, #111827);
    color: var(--modal-text, #E5E7EB);
}

#emoji-grid {
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 0 0.5rem 0.5rem 0.5rem;
}

.emoji-item {
    cursor: pointer;
    font-size: 1.5rem;
    text-align: center;
    border-radius: 0.25rem;
    padding: 2px;
    transition: background-color 0.1s;
}

.emoji-item:hover {
    background-color: var(--input-filter-bg, #4B5563);
}
.latest-post-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    cursor: pointer;
}
.latest-post-item:hover {
    background-color: var(--thread-bg, #374151);
}
.latest-post-snippet {
    font-size: 0.875rem;
    color: var(--block-text, #d1d5db);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* --- THEME ENGINE LAYOUTS --- */

/* 1. Modern Sidebar (GitLab Style) */
body.layout-modern-sidebar #main-layout {
    /* No Grid needed, standard flex/block behavior is fine since left col is hidden */
    display: flex; 
    gap: 1rem;
}

body.layout-modern-sidebar #left-column {
    display: none !important; /* Force hide the sidebar */
}

body.layout-modern-sidebar .directory-row:hover {
    background-color: var(--thread-bg);
    transform: translateX(4px);
    transition: transform 0.1s ease-in-out, background-color 0.2s;
}

/* 2. Card Grid (LTT Style) */
body.layout-card-grid #topics-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* 2. Card Grid (LTT Style) */
body.layout-card-grid #topics-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
body.layout-card-grid .topic-card {
    background-color: var(--block-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
}
body.layout-card-grid .topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border-color: var(--btn-primary-bg);
}
body.layout-card-grid .topic-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--btn-primary-bg);
}

body.layout-old-school #breadcrumb-container {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid #374151;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Modern/Card: cleaner look */
body.layout-modern-sidebar #breadcrumb-container,
body.layout-card-grid #breadcrumb-container {
    padding-left: 0.5rem;
}

/* 3. Old School (Table Layout) */
body.layout-old-school .topics-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--block-bg);
}
body.layout-old-school .topics-table th {
    background-color: rgba(0,0,0,0.3);
    padding: 12px;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #9ca3af;
    font-weight: 600;
}
body.layout-old-school .topics-table td {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
body.layout-old-school .topics-table tr:hover td {
    background-color: rgba(255,255,255,0.02);
}

/* Only apply when the body class is present */
body.posts-layout-card .post-item {
    /* Reset basic borders if needed */
    border: 1px solid rgba(255, 255, 255, 0.05);
    
    /* The 3D "Raised" Look */
    background: linear-gradient(145deg, var(--post-bg), rgba(0,0,0,0.2)); 
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.5), /* Deep shadow */
        0 3px 6px rgba(0, 0, 0, 0.3),   /* Close shadow */
        inset 0 1px 0 rgba(255, 255, 255, 0.1); /* Top highlight */
    
    /* "Chunky" bottom border to give depth */
    border-bottom: 4px solid rgba(0, 0, 0, 0.3);
    
    /* Spacing */
    margin-bottom: 2rem; /* More space between cards */
    border-radius: 0.75rem; /* Rounder corners */
    transform: perspective(1000px) rotateX(0deg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Hover Effect for 3D Cards */
body.posts-layout-card .post-item:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 15px 25px rgba(0, 0, 0, 0.6), 
        0 5px 10px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-bottom-color: var(--post-card-border-color); /* Highlight bottom edge on hover */
}

/* Adjust internal post sections for the card look */
body.posts-layout-card .post-item > div {
    /* Ensure the inner flex container respects the rounded corners */
    border-radius: 0.75rem; 
    overflow: hidden;
}

/* Remove default dividers if they clash with the card look */
body.posts-layout-card .post-sidebar-bg, 
body.posts-layout-card .post-header-bg, 
body.posts-layout-card .post-footer-bg {
    border-color: rgba(255,255,255,0.05); /* Subtler internal borders */
}

body.threads-layout-card .thread-item {
    /* 3D "Raised" Look */
    background: linear-gradient(160deg, var(--thread-bg), #111827) !important;
    
    /* Override Tailwind borders/shadows */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-bottom: 6px solid rgba(0, 0, 0, 0.4) !important;
    border-color: var(--thread-card-border-color) !important; /* Customizable Color */

    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.5), 
        0 4px 6px -2px rgba(0, 0, 0, 0.3) !important;

    /* Spacing and Shape */
    margin-bottom: 1.5rem !important;
    border-radius: 1rem !important;
    
    /* Animation */
    transform: translateY(0);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover Effect */
body.threads-layout-card .thread-item:hover {
    transform: translateY(2px);
    border-bottom-width: 2px !important;
    box-shadow: 
        0 5px 10px -3px rgba(0, 0, 0, 0.5) !important;
    /* Optional: Brighten border on hover */
    filter: brightness(1.1); 
}

/* Ensure internal grids/flex layouts respect the curve */
body.threads-layout-card .thread-item > div {
    border-radius: 1rem;
}

/* Topic 3D Card Style */
body.topics-style-3d .topic-item,      /* Classic */
body.topics-style-3d .directory-row,   /* Modern Sidebar */
body.topics-style-3d .topic-card {     /* Card Grid */
    background: linear-gradient(160deg, var(--topic-item-bg), #111827) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-bottom: 6px solid rgba(0, 0, 0, 0.4) !important;
    border-color: var(--topic-card-border-color) !important; /* Custom Color */
    
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.5), 
        0 4px 6px -2px rgba(0, 0, 0, 0.3) !important;
        
    transform: translateY(0);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Ensure spacing for the shadow/transform */
    margin-bottom: 1rem; 
}

/* 2. Specific Fixes per Layout */

/* Modern Sidebar: Needs rounded corners */
body.topics-style-3d .directory-row {
    border-radius: 0.75rem !important;
    margin-bottom: 0.75rem !important; /* Add gap between rows */
}

/* Card Grid: Already has spacing, just needs to pop */
body.topics-style-3d .topic-card {
    border-radius: 1rem !important;
}

/* Classic: Needs rounded corners */
body.topics-style-3d .topic-item {
    border-radius: 0.75rem !important;
}

/* 3. Old School (Table Rows) - Tricky because tables don't do margins well */
body.topics-style-3d .topics-table tr.topic-item-bg td {
    /* Apply gradient to cells instead of row */
    background: linear-gradient(160deg, var(--topic-item-bg), #111827) !important;
    border-bottom: 4px solid var(--topic-card-border-color) !important;
}
/* Lift effect doesn't work well on table rows, so we use brightness */
body.topics-style-3d .topics-table tr.topic-item-bg:hover td {
    filter: brightness(1.1);
}

/* 4. Universal Hover Effect (Except Table) */
body.topics-style-3d .topic-item:hover,
body.topics-style-3d .directory-row:hover,
body.topics-style-3d .topic-card:hover {
    transform: translateY(2px);
    border-bottom-width: 2px !important;
    box-shadow: 0 5px 10px -3px rgba(0, 0, 0, 0.5) !important;
    filter: brightness(1.1);
}

/* CHAT Window Sidebar */
/* --- CHAT WINDOW UPDATES --- */

#chat-bubble {
    position: fixed;
    right: 0;        /* Completely to the right edge */
    top: 80%;        /* Default vertical position */
    width: 50px;     /* Smaller width */
    height: 50px;    /* Smaller height */
    
    background-color: var(--chat-bubble-color);
    color: var(--btn-primary-text);
    
    /* Rounded on left, flat on right to attach to edge */
    border-top-left-radius: 50%;
    border-bottom-left-radius: 50%;
    border-top-right-radius: 0; 
    border-bottom-right-radius: 0;
    
    box-shadow: -2px 4px 12px rgba(0,0,0,0.5); /* Shadow shifts to left */
    z-index: 10000;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

#chat-bubble:active {
    cursor: grabbing;
}

/* The main window container */
#chat-window {
    position: fixed;
    left: 90px;
    width: 350px;
    height: 500px;
    background-color: var(--modal-bg);
    color: var(--modal-text);
    border: 1px solid var(--input-filter-bg);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 9998;
    
    /* CHANGE THIS: from 'hidden' to 'visible' so the popup isn't cut off */
    overflow: visible; 
    
    display: none;
    flex-direction: column;
}

#chat-header {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

/* Screen Containers (for switching views) */
.chat-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.chat-screen.hidden {
    display: none;
}

/* Conversation List Items */
.chat-convo-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--block-bg);
    cursor: pointer;
    background-color: var(--modal-bg);
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-convo-item:hover {
    background-color: var(--input-filter-bg);
}

.chat-convo-item.active {
    background-color: var(--input-filter-bg);
    border-left: 3px solid var(--btn-primary-bg);
}

.chat-convo-title {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--modal-text);
}

.chat-convo-preview {
    font-size: 0.75rem;
    color: var(--block-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Unread Badge in List */
.chat-list-badge {
    background-color: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: bold;
}

/* Back Button in Header */
#chat-back-btn {
    margin-right: 0.5rem;
    cursor: pointer;
    color: var(--block-text);
}
#chat-back-btn:hover {
    color: white;
}
/* --- CHAT USER SELECTOR --- */
.chat-user-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.chat-user-option:hover {
    background-color: var(--input-filter-bg); /* Or a lighter gray */
}

/* Hide checkbox but keep functionality, or style it nicely */
.chat-user-checkbox {
    accent-color: var(--btn-primary-bg);
    cursor: pointer;
}

.chat-user-label {
    font-size: 0.75rem; /* text-xs */
    color: var(--block-text);
    user-select: none;
    flex-grow: 1;
}

/* Highlight selected row */
.chat-user-option.selected {
    background-color: rgba(37, 99, 235, 0.2); /* Subtle blue tint */
}

/* --- CHAT DROP-UP STYLES --- */

/* The Dropdown Container */
#chat-recipient-dropdown {
    /* Shadow for depth */
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.3), 0 -2px 4px -1px rgba(0, 0, 0, 0.15);
}

/* User Items in List */
.chat-user-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.chat-user-option:hover {
    background-color: var(--input-filter-bg);
}

/* Selected State */
.chat-user-option.selected {
    background-color: rgba(13, 148, 136, 0.2); /* Teal tint */
}

.chat-user-checkbox {
    accent-color: var(--btn-primary-bg);
    cursor: pointer;
}

.chat-user-label {
    font-size: 0.75rem; 
    color: var(--block-text);
    user-select: none;
    flex-grow: 1;
}

/* Trigger Label Active State */
.has-selection {
    color: var(--modal-text) !important;
    font-weight: 600;
}

/* Ensure the layout transitions smoothly */
#left-container, #right-container, #middle-column {
    transition: all 0.3s ease-in-out;
}

/* Sidebar Animations */
.sidebar-collapsed {
    width: 1.5rem !important;        /* Fixed small width for the 'dock' */
    min-width: 1.5rem !important;
    max-width: 1.5rem !important;
    
    background-color: #1f2937;       /* Match your header/block theme color */
    border-radius: 0.5rem;
    
    padding: 0 !important;
    margin: 0 !important;
    opacity: 1 !important;           /* Keep the strip visible */
    pointer-events: auto;            /* Allow clicking the button */
    overflow: visible !important;    /* Allow toggle button to hang outside */
    z-index: 40;
}
/* Hide the INNER content (the aside) when the parent is collapsed */
.sidebar-collapsed > aside {
    opacity: 0;
    pointer-events: none;
    display: none; /* Remove from flow so it doesn't force width */
}

/* Rotate the toggle buttons when collapsed */
.rotate-180 {
    transform: rotate(180deg);
}

/* --- Threaded View Styles --- */

#threaded-posts-root {
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    will-change: transform;
    width: 100%;
    --thread-post-width: calc(100% - 40px); /* JS updates this */
}

/* Post Card Sizing */
#threaded-posts-root .post-item {
    box-sizing: border-box;
    width: var(--thread-post-width) !important;
    min-width: var(--thread-post-width) !important;
    max-width: var(--thread-post-width) !important;
    flex-shrink: 0;
    margin-right: -1000px; /* Allow overflow */
    
    /* Default spacing: This separates the post from its own children */
    margin-bottom: 0.5rem !important;
}

/* --- NODE WRAPPER --- */
.thread-node {
    position: relative;
    /* This margin creates space betwen siblings (Post A and Post B) */
    /* The line does NOT exist here, so this space is safe/empty */
    padding-bottom: 0.75rem; 
}

/* --- THE TREE LINES --- */

/* The container for nested replies */
.thread-children {
    position: relative;
    margin-left: 24px;  /* Indentation */
    padding-left: 0;
    display: flex;
    flex-direction: column;
    /* No padding-bottom here! We want the height to snap to content. */
}

/* The Line itself */
.thread-children::before {
    content: '';
    position: absolute;
    top: 0;
    
    /* CRITICAL: Stop the line exactly where the last toggle button sits.
       If we let it go to 'bottom: 0', it might touch the next group. */
    bottom: 20px; 
    
    left: -12px;
    width: 2px;
    background-color: rgba(75, 85, 99, 0.3);
    z-index: 0;
}

.thread-children:hover::before {
    background-color: var(--btn-primary-bg);
}

/* --- CLEANUP SPACING FOR LAST CHILD --- */

/* Remove the padding from the wrapper of the LAST child in a branch.
   This ensures the container (.thread-children) shrinks to fit exactly. */
.thread-children > .thread-node:last-child {
    padding-bottom: 0 !important;
}

/* Remove margin from the actual post card of the LAST child */
.thread-children > .thread-node:last-child > .relative > div > .post-item {
    margin-bottom: 0 !important;
}

/* --- TOGGLES --- */

/* Toggle Button - Centered on the line */
.thread-node > .relative > button {
    position: absolute;
    left: -22px; /* Center on the -12px line */
    top: 0.5rem; /* Align with top of card */
    width: 20px;
    height: 20px;
    z-index: 10;
    background-color: var(--block-bg); /* Mask line behind circle */
    border: 1px solid rgba(75, 85, 99, 0.5);
    line-height: 1;
    padding-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.thread-node > .relative > button:hover {
    border-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}