/* ===================================
   FORUM DISPLAY HEADER
   =================================== */

.forumdisplay-wrapper {
  background: var(--block-med);
  border: 1px solid var(--block-lighter);
  border-radius: 4px;
  overflow: hidden;
}

.forumdisplay-header {
  background: var(--block-dark);
  padding: 12px 15px;
  border-bottom: 1px solid var(--block-lighter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.forumdisplay-header .header-left {
  flex: 1;
}

.forumdisplay-header .header-left strong {
  font-family: var(--font-header);
  font-size: 1.2em;
  color: var(--accent1);
}

.forumdisplay-header .header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.forumdisplay-header .col-modcheck {
  margin: 0;
}

/* ===================================
   FORUM DISPLAY WRAPPER
   =================================== */

.forumdisplay-wrapper {
  background: var(--block-med);
  border: 1px solid var(--block-lighter);
  border-radius: 4px;
  overflow: hidden;
}

.forumdisplay-header {
  background: var(--block-dark);
  padding: 12px 15px;
  border-bottom: 1px solid var(--block-lighter);
}

.forumdisplay-columns {
  display: flex;
  align-items: center;
  background: var(--block-dark);
  padding: 10px 15px;
  border-bottom: 2px solid var(--accent3);
  gap: 12px;
}

.forumdisplay-columns .col-thread {
  flex: 1 1 auto;
}

.forumdisplay-columns .col-replies,
.forumdisplay-columns .col-views {
  flex: 0 0 80px;
  text-align: center;
}

.forumdisplay-columns .col-rating {
  flex: 0 0 80px;
  text-align: center;
}

.forumdisplay-columns .col-lastpost {
  flex: 0 0 200px;
  text-align: right;
}

.forumdisplay-columns .col-modcheck {
  flex: 0 0 40px;
  text-align: center;
}

/* ===================================
   SEPARATORS & SORT
   =================================== */

.announcements-separator,
.threads-separator {
  background: var(--block-dark);
  color: var(--accent1);
  padding: 10px 15px;
  font-family: var(--font-header);
  font-weight: var(--weight-reg);
  border-bottom: 2px solid var(--accent3);
}

.threads-separator {
  color: var(--text-color);
  font-weight: bold;
  border-top: 1px solid var(--block-lighter);
  border-bottom: 1px solid var(--block-lighter);
}

.forumdisplay-sort {
  background: var(--block-dark);
  padding: 12px 15px;
  text-align: right;
  border-top: 2px solid var(--accent3);
}

/* ===================================
   ANNOUNCEMENT ROWS
   =================================== */

.announcement-row {
  display: flex;
  align-items: center;
  background: var(--block-light);
  border-bottom: 1px solid var(--block-lighter);
  padding: 12px 8px;
  gap: 12px;
}

.announcement-row .cell-status {
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.announcement-row .cell-main {
  flex: 1 1 auto;
  min-width: 0;
}

.announcement-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.announcement-title-line a {
  font-family: var(--font-header);
  font-size: 1.1em;
  color: var(--accent1);
  text-decoration: none;
}

.announcement-title-line a:hover {
  color: var(--accent2);
}

.announcement-meta {
  color: var(--text-color-muted);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.announcement-date {
  color: var(--text-color-muted);
}

.announcement-row .cell-modbit {
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.announcement-row .cell-rating {
  flex: 0 0 80px;
  text-align: center;
}

/* ===================================
   TOPIC/THREAD ROWS
   =================================== */

.topic-row {
  display: flex !important;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1200px;
  min-height: 200px;
  background: var(--block-med);
  margin: 0 auto 20px auto;
  overflow: hidden;
  position: relative;
}

.trow1, .trow2 {
  background: var(--block-med) !important;
  border: none !important;
}

/* Hide original table cells we don't need in card view */
.cell-status, 
.cell-icon, 
.cell-replies, 
.cell-views, 
.cell-rating {
  display: none !important;
}

/* ===================================
   THREAD MAIN CONTENT
   =================================== */

.cell-main {
  flex: 1;
  padding: 20px 30px !important;
  display: flex !important;
  flex-direction: column;
  justify-content: space-between;
  color: var(--text-color) !important;
  border: none !important;
  background: transparent !important;
  order: 1;
}

.thread-content-wrapper {
  display: flex;
  flex-direction: column;
}

/* Starter avatar styling */
.thread-starter-avatar {
  float: left;
  margin-right: 15px;
  margin-bottom: 10px;
}

.thread-starter-avatar .avatarep_fd {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50%;
  overflow: hidden;
  display: block !important;
  line-height: 0 !important;
}

.thread-starter-avatar .avatarep_fd img {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
}

/* Thread title */
.thread-title-line {
  border-bottom: 1px solid var(--accent1);
  padding-bottom: 10px;
  margin-bottom: 15px;
  font-size: 24px;
  font-weight: 300;
  color: var(--text-color);
}

.thread-title-line a {
  color: var(--accent1) !important;
  text-decoration: none;
}

.thread-title-line a:hover {
  color: var(--text-color) !important;
}

/* Thread meta (author, date) */
.thread-meta {
  font-size: 11px;
  margin-top: auto;
}

.thread-meta .author a,
.thread-meta .thread_start_datetime {
  color: var(--accent1) !important;
}

/* Inline stats */
.thread-stats-inline {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 20px;
}

.thread-stats-inline a {
  color: var(--accent1) !important;
  text-decoration: none;
}

.stat-views span {
  color: var(--accent1) !important;
}

/* ===================================
   LAST POST CELL
   =================================== */

.cell-lastpost {
  width: 300px !important;
  min-height: 200px;
  background: var(--block-dark) !important;
  border: none !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  order: 3;
  position: relative !important;
}

.lastpost-avatar-large {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.lastpost-avatar-large .avatarep_fd {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  line-height: 0 !important;
}

.lastpost-avatar-large .avatarep_fd a,
.lastpost-avatar-large .avatarep_fd img {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

.lastpost-avatar-large img {
  object-fit: cover !important;
  border-radius: 0 !important;
  object-position: center top !important;
}

/* Hide username after avatar */
.lastpost-avatar-large + .lastpost + a,
.cell-lastpost > a:not([href*="javascript"]) {
  display: none !important;
}

/* Last post info overlay */
.cell-lastpost .lastpost {
  position: absolute !important;
  bottom: 0px;
  right: 0px;
  padding: 10px;
  font-size: 11px;
  z-index: 10;
  text-align: right;
  width: 100%;
  color: var(--text-color) !important;
  background: rgba(25, 33, 46, 0.25);
  backdrop-filter: blur(12px) brightness(1.2);
  -webkit-backdrop-filter: blur(12px) brightness(1.2);
}

.cell-lastpost .lastpost a {
  color: var(--accent1) !important;
}

/* ===================================
   MODERATION CHECKBOX
   =================================== */

.cell-modbit {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin-left: auto;
}

.cell-modbit input {
  width: 18px;
  height: 18px;
}

/* ===================================
   ALTERNATE ROW STYLES
   =================================== */

tr.inline_row:nth-child(even) {
  flex-direction: row-reverse;
}

tr.inline_row:nth-child(even) .lastpost {
  text-align: left;
}


/* ===================================
   THREAD SEPARATOR
   =================================== */

.trow_sep {
  background: var(--block-dark);
  color: var(--accent1);
  padding: 10px 15px;
  font-family: var(--font-header);
  font-weight: var(--weight-reg);
  border-bottom: 2px solid var(--accent3);
}


/* ===================================
   TABLET LANDSCAPE (992px - 1199px)
   =================================== */

@media (max-width: 1199px) {
  .topic-row,
  tr.inline_row {
    max-width: 100%;
    margin: 0 10px 20px 10px;
  }
  
  .cell-main {
    padding: 20px 25px !important;
  }
  
  .cell-lastpost {
    width: 250px !important;
  }
  
  .thread-title-line {
    font-size: 22px;
  }
}

/* ===================================
   TABLET PORTRAIT (768px - 991px)
   =================================== */

@media (max-width: 991px) {
  .topic-row,
  tr.inline_row {
    min-height: 180px;
    margin: 0 10px 15px 10px;
  }
  
  .cell-main {
    padding: 15px 20px !important;
  }
  
  .cell-lastpost {
    width: 220px !important;
    min-height: 180px;
  }
  
  .thread-title-line {
    font-size: 20px;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }
  
  .thread-meta {
    font-size: 10px;
  }
  
  .thread-stats-inline {
    font-size: 10px;
    gap: 15px;
  }
  
  .cell-lastpost .lastpost {
    font-size: 10px;
    padding: 8px 12px;
  }
}

/* ===================================
   MOBILE LANDSCAPE (576px - 767px)
   =================================== */

@media (max-width: 767px) {
  .topic-row,
  tr.inline_row,
  .topic-row:nth-child(even),
  tr.inline_row:nth-child(even) {
    flex-direction: column-reverse !important;
    min-height: auto;
    margin: 0 5px 15px 5px;
  }
  
  .cell-main {
    padding: 15px !important;
    order: 2;
  }
  
  .cell-lastpost {
    width: 100% !important;
    height: 200px;
    min-height: 200px;
    order: 1;
  }
  
  .thread-title-line {
    font-size: 18px;
    text-align: left !important;
    border-bottom: 1px solid var(--accent1);
  }
  
  .thread-meta {
    text-align: left !important;
    font-size: 10px;
  }
  
  .thread-stats-inline {
    justify-content: flex-start !important;
    margin-top: 10px;
    padding-top: 8px;
  }
  
  .cell-lastpost .lastpost {
    text-align: center !important;
    font-size: 10px;
    padding: 8px 10px;
  }
  
  .cell-modbit {
    position: absolute !important;
    top: 210px;
    right: 15px !important;
    left: auto !important;
    bottom: auto;
  }
  
  .thread-starter-avatar {
    margin-right: 10px;
  }
  
  .thread-starter-avatar .avatarep_fd,
  .thread-starter-avatar .avatarep_fd a,
  .thread-starter-avatar .avatarep_fd img {
    width: 35px !important;
    height: 35px !important;
  }
}



/* ===================================
   MOBILE PORTRAIT (376px - 575px)
   =================================== */

@media (max-width: 575px) {
  .topic-row,
  tr.inline_row,
  .topic-row:nth-child(even),
  tr.inline_row:nth-child(even) {
    margin: 0 0 10px 0;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  
  .cell-main {
    padding: 12px !important;
  }
  
  .cell-lastpost {
    height: 180px;
    min-height: 180px;
  }
  
  .thread-title-line {
    font-size: 16px;
    padding-bottom: 8px;
    margin-bottom: 10px;
  }
  
  .thread-meta {
    font-size: 9px;
  }
  
  .thread-stats-inline {
    flex-direction: column;
    gap: 5px;
    font-size: 9px;
    margin-top: 8px;
    padding-top: 8px;
  }
  
  .cell-lastpost .lastpost {
    font-size: 9px;
    padding: 6px 8px;
  }
  
  .cell-modbit {
    top: 190px;
    right: 10px !important;
  }
  
  .thread-starter-avatar .avatarep_fd,
  .thread-starter-avatar .avatarep_fd a,
  .thread-starter-avatar .avatarep_fd img {
    width: 32px !important;
    height: 32px !important;
  }
}

/* ===================================
   EXTRA SMALL MOBILE (max 375px)
   =================================== */

@media (max-width: 375px) {
  .cell-main {
    padding: 10px !important;
  }
  
  .cell-lastpost {
    height: 150px;
    min-height: 150px;
  }
  
  .thread-title-line {
    font-size: 14px;
    line-height: 1.4;
  }
  
  .thread-meta {
    font-size: 9px;
    line-height: 1.4;
  }
  
  .thread-stats-inline {
    font-size: 9px;
  }
  
  .cell-lastpost .lastpost {
    font-size: 8px;
    padding: 5px;
    line-height: 1.3;
  }
  
  .cell-modbit {
    top: 160px;
  }
  
  .cell-modbit input[type="checkbox"] {
    width: 16px;
    height: 16px;
  }
  
  .thread-starter-avatar {
    display: none;
  }
}

/* ===================================
   LANDSCAPE ORIENTATION FIXES
   =================================== */

@media (max-height: 500px) and (orientation: landscape) {
  .topic-row,
  tr.inline_row {
    min-height: 150px;
  }
  
  .cell-lastpost {
    height: 150px !important;
    min-height: 150px;
  }
  
  .cell-main {
    padding: 10px 15px !important;
  }
  
  .thread-title-line {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  .thread-stats-inline {
    margin-top: 8px;
    padding-top: 8px;
  }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
  .topic-row,
  tr.inline_row {
    page-break-inside: avoid;
    border: 1px solid #000;
    margin-bottom: 10px;
  }
  
  .cell-lastpost {
    display: none !important;
  }
  
  .cell-modbit {
    display: none !important;
  }
  
  .thread-stats-inline {
    border-top: 1px solid #000;
  }
}

/* ===================================
   ACCESSIBILITY IMPROVEMENTS
   =================================== */

.thread-title-line a:focus,
.thread-stats-inline a:focus,
.cell-lastpost .lastpost a:focus {
  outline: 2px solid var(--accent1);
  outline-offset: 2px;
}

.cell-modbit input[type="checkbox"]:focus {
  outline: 2px solid var(--accent1);
  outline-offset: 2px;
}

@media (prefers-contrast: high) {
  .topic-row,
  tr.inline_row {
    border: 2px solid var(--accent1);
  }
  
  .thread-title-line {
    border-bottom-width: 2px;
  }
  
  .cell-lastpost .lastpost {
    background: rgba(0, 0, 0, 0.95);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}