/* responsive.css */

/* Mobile view (phones, 600px and down) */
@media screen and (max-width: 600px) {
  * {
    box-sizing: border-box !important;
  }

  body {
    padding: 10px !important;
    font-size: 14px !important;
    width: 100% !important;
    margin: 0 !important;
  }

  .MainPartContainer {
    width: 100% !important;
    min-width: 0 !important;
    padding: 5px !important;
  }

  .loginpagecontainer {
    width: 95% !important;
    max-width: none !important;
  }

  /* Index page specific adjustments */
  .functionbar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
  }

  .functionbar a {
    font-size: 14px !important;
    padding: 5px 10px !important;
    background-color: #444;
    border-radius: 4px;
    margin: 5px !important; /* Increased gap for better touch and visibility */
  }

  .title-container {
    flex-direction: column !important;
    height: auto !important;
    align-items: flex-start !important;
    padding: 10px !important;
  }

  .title-container h1,
  .title-container h3 {
    font-size: 1.2rem !important;
    margin-bottom: 5px !important;
  }

  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
  }

  .message-container {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    padding: 12px 10px !important;
    gap: 0;
    margin-bottom: 10px !important; /* Added gap between memo/article cards */
    border: 1px solid #555 !important; /* Ensure border is visible for definition */
  }

  .id-column {
    flex: 0 0 35px !important;
    width: auto !important;
    margin-bottom: 0 !important;
    font-size: 0.8rem !important;
    color: #888;
    text-align: left !important;
    order: 0;
  }

  .title-column {
    flex: 1 1 0% !important;
    width: auto !important;
    margin-bottom: 0 !important;
    text-align: left !important;
    word-break: break-word;
    padding-right: 5px;
    order: 1;
  }

  .icon-column {
    flex: 0 0 auto !important;
    width: auto !important;
    margin-bottom: 0 !important;
    margin-left: 8px !important;
    display: flex !important;
    align-items: center !important;
    order: 2;
  }

  .time-column {
    flex: 0 0 100% !important;
    width: 100% !important;
    margin-top: 5px !important;
    margin-bottom: 0 !important;
    font-size: 0.8rem !important;
    color: #999; /* Slightly brighter for readability */
    text-align: left !important;
    order: 3;
  }

  .category-column {
    flex: 0 0 100% !important;
    width: 100% !important;
    margin-top: 3px !important;
    font-size: 0.8rem !important;
    order: 4;
  }

  /* Improved icon touch targets for mobile */
  .icon {
    max-width: 24px !important;
    max-height: 24px !important;
    padding: 2px;
  }

  .icon-column a {
    display: flex !important;
    padding: 8px !important; /* Larger hit area */
    margin: -8px !important; /* Offset padding to keep layout tight */
  }

  /* Forms and Inputs */
  input[type="text"],
  input[type="password"],
  input[type="date"],
  input[type="file"],
  textarea,
  select {
    width: 100% !important;
    margin-bottom: 10px !important;
    box-sizing: border-box;
  }

  /* Specific Manage page input adjustments */
  input[name="title"],
  input[name="created_at"],
  input[name="tags"],
  input[type="submit"] {
    width: 100% !important;
  }

  .textInputContainerSub {
    flex-direction: column !important;
  }

  .InputTextArea {
    min-height: 100px !important;
  }

  .submitTextButton {
    width: 100% !important;
    margin-top: 10px !important;
  }

  /* Article content images */
  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Table responsive */
  table {
    display: block !important;
    width: 100% !important;
    background-color: transparent !important;
    border: none !important;
  }

  thead,
  tbody,
  th,
  td {
    display: block !important;
  }

  tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* Hide the header row */
  tr:first-child:has(th) {
    display: none !important;
  }

  tr {
    display: block !important;
    background-color: #444;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #555 !important;
    margin-bottom: 0 !important;
  }

  td {
    border: none !important;
    padding: 4px 0 !important;
    position: relative;
    text-align: left !important;
  }

  /* Specifically for files.html structure */
  /* First cell is filename */
  td:nth-of-type(1) {
    font-weight: bold;
    font-size: 1rem;
    color: #b3e3ff;
    padding-bottom: 8px !important;
    word-break: break-all;
    line-height: 1.3;
  }

  /* Labels for other cells using pseudo-elements */
  td:nth-of-type(2):before {
    content: "Time: ";
    color: #888;
    font-size: 0.8rem;
  }
  td:nth-of-type(3):before {
    content: "Size: ";
    color: #888;
    font-size: 0.8rem;
  }

  td:nth-of-type(2),
  td:nth-of-type(3) {
    font-size: 0.85rem;
    color: #bbb;
  }

  /* Operation column icons */
  td:nth-of-type(4) {
    display: flex !important;
    justify-content: flex-end;
    margin-top: 8px;
    border-top: 1px solid #555 !important;
    padding-top: 8px !important;
  }

  .iconContainerInFiles {
    display: flex !important;
    gap: 15px;
    width: 100%;
    justify-content: flex-end; /* Align icons to the right like in other pages */
  }

  .iconContainerInFiles .icon-column {
    margin: 0 !important;
  }
}
