/* ==========================================================================
   SKBWORLD - MOBILE-FIRST & RESPONSIVE DESIGN RULES
   ========================================================================== */

/* 1. Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.mobile-nav-items {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  width: 25%;
  height: 100%;
}

.mobile-nav-btn.active, .mobile-nav-btn:hover {
  color: var(--primary);
}

.mobile-nav-icon {
  font-size: 1.25rem;
}

/* 2. Tablet & Medium Screen Breakpoints (max-width: 1024px) */
@media (max-width: 1024px) {
  .search-shortcut-badge {
    display: none !important;
  }

  .post-card {
    grid-template-columns: 1fr;
  }

  .post-author-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    flex-direction: row;
    text-align: left;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    flex-wrap: nowrap;
  }

  .author-details-wrap {
    align-items: flex-start;
    flex: 1;
    min-width: 0;
  }

  .author-avatar-lg {
    margin-bottom: 0;
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .author-info-list {
    display: none;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    margin-top: 10px;
    width: 100%;
    min-width: 0;
  }

  .admin-sidebar {
    position: static;
    margin-bottom: 0;
    padding: 8px 10px;
    border-radius: var(--radius-xl);
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-xs);
  }

  .admin-sidebar-header {
    display: none;
  }

  .admin-nav-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    gap: 8px;
    padding: 2px 2px 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) transparent;
  }

  .admin-nav-list::-webkit-scrollbar {
    height: 4px;
    display: block;
  }

  .admin-nav-list::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
  }

  .admin-nav-btn {
    white-space: nowrap;
    padding: 0.5rem 0.95rem;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
  }

  .admin-nav-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  }

  .admin-main {
    padding: 16px;
    border-radius: var(--radius-xl);
    min-height: auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}

/* 3. Mobile Screens (max-width: 768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: 70px; /* Space for sticky bottom navigation */
  }

  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Header & Navigation */
  .site-header {
    height: 56px;
  }

  .header-inner {
    height: 56px;
    gap: 8px;
    padding: 0 2px;
  }

  .site-header .header-search {
    display: none;
  }

  .brand-logo {
    font-size: 1.1rem;
    gap: 6px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }

  .brand-tag {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .btn-admin-nav {
    display: none;
  }

  .points-pill {
    font-size: 0.76rem;
    padding: 3px 8px;
    gap: 4px;
    border-radius: var(--radius-full);
  }

  .user-display-name {
    display: none;
  }

  .user-avatar-btn {
    padding: 2px;
    background: transparent;
    border: none;
  }

  .avatar-circle {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
  }

  .btn-signin-nav {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
  }

  .top-marquee-bar {
    font-size: 0.76rem;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .top-marquee-bar::-webkit-scrollbar, .marquee-track::-webkit-scrollbar {
    display: none;
  }

  .marquee-badge {
    font-size: 0.64rem;
    padding: 2px 6px;
  }

  .mobile-bottom-nav {
    display: block;
  }

  /* Breadcrumbs */
  .breadcrumbs-bar {
    padding: 8px 0;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .breadcrumbs-bar::-webkit-scrollbar {
    display: none;
  }

  .breadcrumb-list {
    flex-wrap: nowrap;
    gap: 6px;
    font-size: 0.8rem;
  }

  /* Category Sections & Rows (Fixes Mobile Screenshot Issues) */
  .category-section {
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
  }

  .category-header {
    padding: 10px 14px;
    gap: 6px;
  }

  .category-header-title {
    font-size: 0.95rem;
    min-width: 0;
  }

  .category-header-badges {
    margin-left: auto;
    gap: 4px;
  }

  .category-header-badges .badge {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  .category-row {
    padding: 12px 14px;
    gap: 10px;
  }

  .category-icon-box {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
    margin-right: 0;
  }

  .category-main-title {
    font-size: 0.92rem;
    gap: 6px;
  }

  .category-desc {
    font-size: 0.8rem;
    line-height: 1.35;
    margin-top: 2px;
  }

  .category-stats {
    display: none;
  }

  /* Threads List & Toolbar */
  .threads-toolbar {
    padding: 10px 14px;
    gap: 8px;
  }

  .thread-filters {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-btn {
    font-size: 0.78rem;
    padding: 3px 8px;
  }

  div.thread-row {
    padding: 12px 14px;
    gap: 10px;
  }

  /* Latest Firmware & Diagnostic Packs / Threads Table Mobile Stack (No Horizontal Scroll) */
  .threads-table-container {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--radius-lg);
    margin-top: 10px;
    box-sizing: border-box !important;
  }

  table.threads-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate;
  }

  table.threads-table thead {
    display: none !important;
  }

  table.threads-table tbody {
    display: block !important;
    width: 100% !important;
  }

  table.threads-table tr.threads-table-tr {
    display: block !important;
    width: 100% !important;
    padding: 13px 14px !important;
    border-bottom: 1px solid var(--border-light) !important;
    box-sizing: border-box !important;
    background: var(--bg-card);
    transition: background var(--transition-fast);
  }

  table.threads-table tr.threads-table-tr:last-child {
    border-bottom: none !important;
  }

  table.threads-table tr.threads-table-tr:active,
  table.threads-table tr.threads-table-tr:hover {
    background: #f8fafc;
  }

  table.threads-table tr.pinned-thread {
    background: #fffdf5 !important;
    border-left: 3.5px solid var(--warning) !important;
  }

  table.threads-table tr.pinned-thread td:first-child {
    border-left: none !important;
  }

  table.threads-table td.thread-title-col {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-sizing: border-box !important;
  }

  table.threads-table td.col-category,
  table.threads-table td.col-author,
  table.threads-table td.col-views,
  table.threads-table td.col-replies,
  table.threads-table td.col-date,
  table.threads-table td:nth-child(n+2) {
    display: none !important;
  }

  .thread-title-wrap {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .thread-title-wrap .thread-link-title {
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .thread-mobile-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    margin-top: 8px !important;
    font-size: 0.74rem !important;
    width: 100% !important;
  }

  .thread-mobile-meta .cat-link-tag {
    font-size: 0.72rem !important;
    padding: 2px 8px !important;
    max-width: 180px !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
  }

  .thread-mobile-meta-item {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    color: var(--text-muted) !important;
    font-size: 0.72rem !important;
    font-weight: 500 !important;
  }

  .thread-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.78rem;
    margin-right: 0;
  }

  .thread-title {
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .thread-meta {
    font-size: 0.74rem;
    gap: 4px;
    margin-top: 3px;
  }

  .thread-stats-badge {
    display: none;
  }

  /* Thread Details View */
  .thread-detail-header {
    padding: 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
  }

  .thread-main-title {
    font-size: 1.2rem;
    line-height: 1.35;
  }

  .post-main-body {
    padding: 16px;
  }

  .post-text-content {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .post-text-content pre {
    padding: 12px;
    font-size: 0.78rem;
  }

  .post-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Attachment Download Cards */
  .attachments-box {
    padding: 14px;
    border-radius: var(--radius-lg);
    margin-top: 16px;
  }

  .attachments-box-title {
    font-size: 0.92rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .attachment-card {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    gap: 12px;
  }

  .file-type-icon {
    width: 38px;
    height: 38px;
    font-size: 0.8rem;
  }

  .file-name {
    font-size: 0.88rem;
  }

  .attachment-action-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-light, #e2e8f0);
  }

  .attachment-points-pill {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: left;
  }

  .attachment-points-value {
    font-weight: 800;
    color: #d97706;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .attachment-points-label {
    font-size: 0.72rem;
    color: #b45309;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
  }

  .attachment-card .btn {
    width: auto;
    min-width: 120px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 8px;
    white-space: nowrap;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Profile Layout */
  .profile-layout-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .profile-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 16px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 14px;
    border-radius: var(--radius-lg);
  }

  /* Admin Main Panel & Sections */
  .admin-main {
    padding: 14px;
    border-radius: var(--radius-xl);
  }

  .admin-section-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .admin-section-header > * {
    width: 100%;
  }

  .admin-section-header .btn, 
  .admin-section-header .badge {
    align-self: flex-start;
    width: auto;
  }

  .admin-heading {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  .admin-subheading {
    font-size: 0.78rem;
    margin-top: 2px;
  }

  /* Stats Grid */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 12px;
    gap: 10px;
  }

  .stat-icon-wrapper {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .stat-num {
    font-size: 1.15rem;
  }

  .stat-title {
    font-size: 0.74rem;
  }

  /* Branding & Maintenance Grids */
  .branding-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .branding-card {
    padding: 14px !important;
    border-radius: var(--radius-lg) !important;
  }

  .branding-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .branding-card-header .badge {
    align-self: flex-start;
  }

  .logo-preview-box {
    padding: 14px;
    min-height: 70px;
  }

  .favicon-preview-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
  }

  /* Slide Items in Hero Carousel Manager */
  .slide-item-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px !important;
  }

  .slide-thumbnail {
    width: 100% !important;
    height: 120px !important;
  }

  .slide-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 44px 44px 1fr 44px !important;
    gap: 6px !important;
  }

  .slide-actions .btn {
    padding: 6px 4px !important;
    font-size: 0.8rem !important;
    text-align: center;
    justify-content: center;
  }

  /* Admin Tables & Cells */
  .admin-table th, .admin-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .admin-table td .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  /* Modals & Toasts */
  #toast-container {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: none;
  }

  .modal-box {
    width: calc(100% - 20px) !important;
    max-width: 520px !important;
    margin: 10px auto !important;
    max-height: 92vh !important;
    border-radius: var(--radius-xl) !important;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-footer .btn {
    flex: 1;
  }

  .branding-card div[style*="grid-template-columns: 1fr 1fr"],
  .modal-body div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
}

/* 4. Extra Small Phones (max-width: 480px) */
@media (max-width: 480px) {
  .brand-logo span:not(.brand-tag) {
    font-size: 1.02rem;
  }

  .points-pill {
    padding: 2px 6px;
    font-size: 0.72rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-nav-btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
  }

  .emoji-picker-popover {
    width: 285px;
    max-width: calc(100vw - 32px);
    left: auto;
    right: 0;
  }

  .branding-card div[style*="display: flex; gap: 10px"],
  .branding-card div[style*="display: flex; gap: 8px"] {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .branding-card div[style*="display: flex; gap: 10px"] .btn,
  .branding-card div[style*="display: flex; gap: 8px"] .btn {
    width: 100% !important;
  }

  /* Search Page Mobile Rules */
  .search-hero-card {
    padding: 16px;
  }

  .search-input-box-wrapper {
    flex-direction: column;
  }

  .search-submit-btn {
    width: 100%;
    justify-content: center;
  }

  .search-card-body {
    flex-direction: column;
    gap: 12px;
  }

  .search-thread-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.82rem;
  }

  .search-card-stats-col {
    border-left: none;
    border-top: 1px solid var(--border-light);
    padding-left: 0;
    padding-top: 10px;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .search-results-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .search-sort-group {
    width: 100%;
    justify-content: space-between;
  }

  .search-sort-select {
    flex: 1;
  }

  /* Revamped Auth Modal Mobile Rules */
  .auth-revamped-box {
    max-width: 95vw !important;
    margin: 10px auto !important;
  }

  .auth-split-grid {
    grid-template-columns: 1fr !important;
  }

  .auth-brand-sidebar {
    display: none !important;
  }

  .auth-form-panel {
    padding: 24px 18px !important;
  }

  .auth-form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
}

