/* Responsive fixes for all pages */
@media (max-width: 700px) {
  .main-container, .admin-section, form[method="post"], .thread-table-container, .admin-container {
    max-width: 98vw !important;
    padding: 10px 2vw !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 auto !important;
  }
  textarea, input, select, button {
    font-size: 1em !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  h2, h1 {
    font-size: 1.15em !important;
  }
  table {
    font-size: 0.98em !important;
    width: 100% !important;
    display: block;
    overflow-x: auto;
  }
  th, td {
    white-space: normal !important;
    padding: 6px 4px !important;
  }
  .thread-table, .thread-table-container {
    width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
  }
  .header, .header-userinfo {
    flex-direction: column !important;
    align-items: flex-start !important;
    font-size: 1em !important;
    padding: 8px 2vw !important;
  }
  .site-title, .header-userinfo {
    word-break: break-word !important;
    font-size: 1em !important;
  }
}
/* More aggressive mobile fixes for iPhone and small screens */
@media (max-width: 900px) {
  body, .main-container {
    padding: 0 2vw !important;
    font-size: 1.04em !important;
  }
  .header, .main-container, .thread-header, .thread-table-container, .thread-form-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
  /* Board and thread tables: force horizontal scroll if needed */
  .thread-table-container, .board-table-container {
    width: 100vw !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  table, .thread-table {
    width: 100% !important;
    min-width: 700px !important;
    max-width: 100vw !important;
    font-size: 0.98em !important;
    box-sizing: border-box !important;
    border-collapse: separate !important;
  }
  .thread-table th, .thread-table td, th, td {
    padding: 10px 6px !important;
    font-size: 0.98em !important;
    word-break: break-word !important;
    min-width: 120px !important;
  }
  /* Keep user/message columns side-by-side on most mobile screens */
  .thread-row {
    display: table-row !important;
    margin-bottom: 12px !important;
    border-bottom: 1px solid #eee !important;
  }
  .thread-user-cell, .thread-message-cell {
    display: table-cell !important;
    width: 50% !important;
    min-width: 120px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    vertical-align: top !important;
  }
  .pagination {
    font-size: 1em !important;
    padding: 0 2vw !important;
  }
}

@media (max-width: 700px) {
  table, .thread-table {
    min-width: 520px !important;
  }
  .thread-table th, .thread-table td, th, td {
    font-size: 0.97em !important;
    padding: 8px 4px !important;
  }
}

@media (max-width: 600px) {
  .thread-table-container, .board-table-container {
    min-width: 0 !important;
    width: 100vw !important;
    overflow-x: auto !important;
  }
  table, .thread-table {
    min-width: 340px !important;
    font-size: 0.96em !important;
  }
  .thread-table th, .thread-table td, th, td {
    font-size: 0.96em !important;
    padding: 6px 2px !important;
  }
}

@media (max-width: 480px) {
  body, .main-container {
    font-size: 0.95em !important;
  }
  .thread-header, .thread-form-container {
    padding: 8px 1vw !important;
  }
  .thread-table th, .thread-table td, th, td {
    padding: 5px 1px !important;
    font-size: 0.95em !important;
  }
  .thread-row {
    margin-bottom: 6px !important;
  }
  .thread-user-cell, .thread-message-cell {
    min-width: 100px !important;
  }
}
@media (max-width: 900px) {
    .main-container, .thread-header, .thread-table-container, .thread-form-container {
        padding-left: 2vw !important;
        padding-right: 2vw !important;
    }
}
@media (max-width: 700px) {
    .main-container, .thread-header, .thread-table-container, .thread-form-container {
        padding-left: 1vw !important;
        padding-right: 1vw !important;
    }
    .thread-header h2 {
        font-size: 1.05em !important;
    }
    .thread-table th, .thread-table td {
        padding: 4px 2px !important;
    }
    .thread-avatar img {
        width: 48px !important;
        height: 48px !important;
    }
    .thread-form-container, .login-form-container {
        max-width: 98vw !important;
        padding: 10px 2vw !important;
    }
}
@media (max-width: 600px) {
    .main-container {
        padding: 0 !important;
        width: 100vw !important;
        min-width: 0 !important;
    }
    .thread-header, .thread-table-container, .thread-form-container, .login-form-container {
        padding: 4px 1vw 4px 1vw !important;
        max-width: 100vw !important;
    }
    .thread-header {
        font-size: 0.97em;
    }
    .thread-table-container {
        overflow-x: auto;
    }
    .thread-table {
        min-width: 340px;
        width: 100%;
        font-size: 0.93em;
    }
    .thread-user-cell, .thread-message-cell {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
        min-width: 0 !important;
        max-width: 100vw !important;
    }
    .thread-row {
        display: block;
        margin-bottom: 12px;
        border-bottom: 1px solid #eee;
    }
    .thread-edit-btn-row-bottom, .react-btns-row {
        text-align: right;
    }
    .pagination {
        font-size: 0.97em;
    }
    .thread-avatar img {
        width: 36px !important;
        height: 36px !important;
    }
    .thread-username {
        min-width: 0 !important;
        max-width: 100% !important;
        font-size: 0.98em !important;
    }
    .thread-form textarea, .thread-form input[type="text"], .login-form-container input[type="text"], .login-form-container input[type="password"] {
        width: 100% !important;
        font-size: 1em;
    }
    .form-actions button, .thread-edit-btn-row-bottom button {
        width: 100%;
        min-width: 0;
        margin-top: 6px;
    }
    .header, .admin-header {
        padding: 10px 2vw !important;
        font-size: 1em !important;
    }
    .site-title {
        font-size: 1.1em !important;
    }
}
