/* Mobile-responsive overrides for cgit on git.webx11.duckdns.org */
/* Served after the original cgit.css */

/* Responsive viewport fix */
html { -webkit-text-size-adjust: 100%; }

/* Card layout for repo list on mobile */
@media (max-width: 640px) {
  /* Hide the repo list table headers on mobile */
  table.list tr.nohover { display: none; }

  /* Convert repo list table rows into cards */
  table.list tr {
    display: block;
    background: #1a1a2e;
    border: 1px solid #2d2d44;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.7rem;
    width: 100%;
    box-sizing: border-box;
  }

  table.list td {
    display: block;
    padding: 0.15rem 0;
    border: none;
    background: transparent;
    font-size: 0.85rem;
  }

  table.list td a { font-size: 1rem; font-weight: 600; color: #6366f1; }

  /* Hide the description on card view, show on hover if needed */
  table.list td:nth-child(2) {
    font-size: 0.78rem;
    color: #9ca3af;
    margin: 0.2rem 0 0.4rem 0;
  }

  /* Hide owner column on mobile */
  table.list td:nth-child(3) { display: none; }

  /* Idle time styling */
  table.list td:nth-child(4) {
    font-size: 0.7rem;
    color: #6b7280;
  }

  /* Links row - buttons side by side */
  table.list td:nth-child(5) {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  a.button {
    display: inline-block;
    background: #252542;
    border: 1px solid #374151;
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    color: #a5b4fc !important;
    text-decoration: none;
  }

  a.button:hover { background: #2d2d4a; color: #e0e0e0 !important; }

  /* Make header logo smaller */
  td.logo { display: none; }
  td.main { font-size: 1.2rem; padding: 0.3rem 0; }
  td.sub { font-size: 0.8rem; padding: 0.2rem 0; }

  /* Fix content area */
  div.content { padding: 0; overflow: visible; }

  /* Tab bar */
  table.tabs td { padding: 0.3rem 0.5rem; }
  table.tabs a { font-size: 0.8rem; }

  /* Search form */
  table.tabs form input[type="search"] {
    max-width: 120px;
    font-size: 0.78rem;
  }

  /* Commit log / tree view on mobile */
  #cgit table { font-size: 0.78rem; }

  /* Responsive table for commit listing */
  #cgit table.list td.commit-subject {
    white-space: normal;
    word-break: break-word;
  }

  /* Tree view - file listing */
  td.ls-mode { display: none; }
  td.ls-size { font-size: 0.7rem; color: #6b7280; }
  td a.ls-blob { font-size: 0.85rem; }

  /* Footer */
  div.footer { font-size: 0.65rem; padding: 0.5rem; }

  /* Diff view on mobile - force horizontal scroll */
  div.diff {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Make the whole page padding smaller */
  body { padding: 0.5rem; max-width: 100vw; overflow-x: hidden; }
  div#cgit { padding: 0.3rem; }

  /* Better touch targets */
  a, button, input[type="submit"] { min-height: 44px; display: inline-flex; align-items: center; }

  /* Commit message wrapping */
  td.commit-subject a { white-space: normal; word-break: break-word; }

  /* ============== SUMMARY PAGE OVERFLOW FIX ============== */

  /* Summary repo info table - cards should not overflow */
  div.content table.list {
    width: 100%;
    table-layout: fixed;
  }

  /* All cells in summary cards should wrap long text */
  div.content table.list td {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  /* Summary commit message links wrapping */
  div.content table.list td a {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Clone URL area */
  td a:has(+ br) {
    word-break: break-all;
    font-size: 0.72rem;
  }

  /* ============== DIFF VIEW FIXES ============== */

  /* Diff header row (file paths) */
  div.diff.header {
    font-size: 0.75rem;
    line-height: 1.4;
    padding: 0.4rem 0;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Diff code lines - allow horizontal scroll but not wrapping (breaks diffs) */
  div.diff pre {
    font-size: 0.7rem;
    line-height: 1.3;
    white-space: pre;
  }

  /* Diff add/remove markers */
  div.diff .add { color: #4ade80; }
  div.diff .del { color: #f87171; }
  div.diff .hunk { color: #818cf8; }

  /* ============== COMMIT DETAIL PAGE ============== */

  /* Commit message area */
  div.commit-msg {
    font-size: 0.85rem;
    padding: 0.5rem;
    word-break: break-word;
  }

  /* Commit metadata table */
  table.commit-info td {
    display: block;
    padding: 0.2rem 0;
    font-size: 0.8rem;
  }
  table.commit-info td:first-child {
    font-weight: 600;
    color: #818cf8;
    min-width: auto;
  }

  /* ============== BLOB / FILE VIEW ============== */

  /* Code content area */
  div#cgit table.blob td {
    display: table-cell;
    font-size: 0.7rem;
    line-height: 1.25;
    padding: 0.1rem 0.3rem;
  }

  /* Line numbers in blob view - thinner */
  td.linenumbers a, .linenumbers a {
    font-size: 0.65rem;
    color: #4b5563;
    padding-right: 0.5rem;
  }

  /* ============== STATS / GRAPH VIEW ============== */

  /* Commit graph table */
  table.grid td {
    font-size: 0.7rem;
    padding: 0.1rem 0.3rem;
  }

  /* ============== SEARCH RESULTS ============== */

  .search-results td {
    font-size: 0.78rem;
    word-break: break-word;
  }
}

/* Dark theme refinements */
body { background: #0d0d0d; }
#cgit { color: #e0e0e0; }
#cgit a { color: #818cf8; }
#cgit a:hover { color: #a5b4fc; }
#cgit table.tabs a.active { color: #6366f1; font-weight: 600; }
#cgit table.tabs a { color: #9ca3af; }
#cgit div.footer { color: #555; }
#cgit div.footer a { color: #6b7280; }
#cgit table.list td { color: #9ca3af; }
#cgit table.list th { color: #6b7280; }
#cgit .commit-subject a { color: #e0e0e0; font-weight: 500; }
#cgit .commit-msg { color: #d1d5db; }
