/* Table layout - required for fixed width columns */
table {
  table-layout: fixed;
  width: 100%;
  margin: 0;
  border-collapse: collapse; /* Ensure no gaps between cells */
}

/* Column widths for consistency */
table th.select-col, table td.select-cell { 
  width: 40px; 
  min-width: 40px;
  text-align: center; 
  vertical-align: middle;
  padding-left: var(--spacing-xs);
  padding-right: var(--spacing-xs);
}
table th.select-col input[type="checkbox"],
table td.select-cell input[type="checkbox"] {
  margin: 0;
  vertical-align: middle;
  position: relative;
  cursor: pointer;
  width: 16px;
  height: 16px;
}
/* Column widths by class name */
table th.name-cell, table td.name-cell { width: 60%; }
table th.date-col, table td.date-col { width: 25%; }
table th.size-col, table td.size-col { width: 15%; }

/* Backup nth-child selectors for non-multi-select mode */
table th:nth-child(1):not(.select-col), table td:nth-child(1):not(.select-cell) { width: 60%; }
table th:nth-child(2):not(.name-cell), table td:nth-child(2):not(.name-cell) { width: 25%; }
table th:nth-child(3):not(.date-col), table td:nth-child(3):not(.date-col) { width: 15%; }

/* Ensure all column headers have the same styling */
table th.date-col, table th.size-col {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

/* Make all table headers consistent */
table th {
  padding: 0.2rem var(--spacing-sm) 0.4rem; /* Balanced padding: less on top, more on bottom */
  text-align: left; /* Ensure left alignment */
  vertical-align: middle; /* Align vertically */
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 600; /* Make text bold */
  white-space: nowrap;
  cursor: pointer; /* Add cursor from original custom.css */
  background-color: var(--color-surface); /* Add background color */
}

/* Add a continuous border under the entire header row */
table thead {
  border-bottom: 1px solid var(--color-border); /* More subtle border */
}

table th:hover {
  color: var(--color-primary);
}

table td {
  padding: var(--spacing-sm) var(--spacing-sm); /* Add padding */
  vertical-align: middle; /* Align vertically */
  border-bottom: 1px solid var(--color-border-muted); /* Add border from original custom.css */
}

tr:hover td {
  background-color: var(--color-hover);
}

/* Remove underline from table links by default, only show on hover */
table a {
  text-decoration: none;
}

table a:hover {
  text-decoration: none;
}

/* Directory row styles */
.dir-row {
  cursor: pointer;
}

.dir-entry {
  display: flex;
  align-items: center;
  color: var(--color-primary-text, var(--color-primary));
}

.dir-row:hover .dir-entry {
  text-decoration: none;
}

/* Secondary column styles */
td:nth-child(2), td:nth-child(3) {
  white-space: nowrap;
  font-size: 0.95rem; /* Increased from 0.90rem to match header */
  color: var(--color-text-muted);
}

/* Icons for files/folders */
.icon {
  margin-right: 0.5rem;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* File entry with view icon */
.file-entry {
  display: flex;
  align-items: center;
}

.file-link {
  flex-grow: 1;
}

.view-icon, .link-icon {
  margin-left: 0.5rem;
  opacity: 0.5;
  transition: opacity 0.2s;
  color: var(--color-primary);
}

.view-icon:hover, .link-icon:hover {
  opacity: 1;
}

/* Header/Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background-color: var(--color-primary);
  color: var(--color-white);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--color-shadow);
  margin-bottom: var(--spacing-md);
  border-radius: var(--border-radius-md);
}

.path-parts {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  overflow: hidden;
  white-space: nowrap;
}

.path-parts a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  color: var(--color-white);
  opacity: 0.9;
  transition: opacity 0.2s;
}

.path-parts span {
  color: var(--color-white-muted);
}

.brand-name {
  font-weight: bold;
  color: var(--color-white);
  opacity: 1;
  padding-right: 0.5rem;
}

.brand-separator {
  color: var(--color-white-muted);
  padding: 0 0.5rem 0 0;
}

.path-parts a:hover {
  text-decoration: none;
  opacity: 1;
}

.path-parts svg {
  fill: var(--color-white) !important;
}

/* Logout button */
.logout-button a {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 0.3rem 0.6rem;
  background-color: var(--color-white-overlay);
  color: var(--color-white);
  border-radius: var(--border-radius-sm);
  text-decoration: none;
  transition: background-color 0.2s;
}

.logout-button a svg {
  fill: var(--color-white) !important;
}

.logout-button a:hover {
  background-color: var(--color-white-overlay-hover);
  text-decoration: none;
}

/* Footer */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 0.8rem;
  background-color: var(--color-surface);
  color: var(--color-text);
  z-index: 100;
  font-size: 0.85rem;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 -2px 10px var(--color-shadow);
  border-top: 1px solid var(--color-border);
}

.footer-content {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  color: var(--color-text-muted);
}

.footer-item {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.footer-icon {
  margin-right: 0.35rem;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  fill: var(--color-text-muted) !important;
}

.footer-dot {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  display: inline-block;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none !important;
  color: var(--color-primary-text, var(--color-primary));
  transition: opacity 0.2s;
  opacity: 0.9;
}

.footer-link:hover {
  text-decoration: none !important;
  opacity: 1;
}

/* Login box */
.centered-login-box {
  max-width: 400px;
  margin: 8rem auto 0;  /* Increased top margin for spacing */
  padding: 2rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);  /* Slightly stronger shadow */
  background-color: var(--color-surface);
}

/* Modal styles */
#modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-modal-backdrop);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

#modal-container:not(:empty) {
  display: flex !important;
}

.file-modal {
  background-color: var(--color-background);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--color-modal-shadow);
  width: 85%;
  max-width: 1300px;
  height: 80vh; /* Make it taller */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--color-text);
  margin: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-border-muted);
}

.modal-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.close-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  text-decoration: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: background-color 0.2s, color 0.2s;
}

.close-modal:hover {
  background-color: var(--color-border-muted);
  color: var(--color-primary);
}

.modal-content {
  padding: 0.5rem;
  overflow: auto;
  flex-grow: 1;
  display: flex;
  justify-content: center;
  max-height: calc(95vh - 3rem);
  position: relative;
}

pre {
  margin: 0;
  padding: var(--spacing-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: monospace;
  width: 100%;
  overflow: auto;
}

.loading-spinner {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 3px solid var(--color-border-muted);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 1s ease-in-out infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -25px;
  margin-left: -25px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.text-preview {
  width: 100%;
  height: 100%;
  border: none;
}

.unsupported-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
  color: var(--color-text-muted);
  font-size: 1.1rem;
  text-align: center;
}

.unsupported-file a {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-primary);
  border-radius: var(--border-radius-sm);
  color: var(--color-primary);
  text-decoration: none;
  transition: all 0.2s;
}

.unsupported-file a:hover {
  background-color: var(--color-primary);
  color: white;
}

/* Login form styling */
.centered-login-box h3 {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.centered-login-box input[type="password"] {
  margin-bottom: var(--spacing-md);
  width: 100%;
  min-width: 100%;
  box-sizing: border-box;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  main.container {
    padding: var(--spacing-sm);
  }
  
  .file-modal {
    width: 95%;
  }
  
  /* Improved mobile layout for breadcrumbs and logout */
  .breadcrumbs {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "path logout";
    padding: 0.6rem 0.8rem;
    border-radius: var(--border-radius-sm);
    align-items: center;
  }
  
  .path-parts {
    grid-area: path;
    max-width: calc(100% - 80px);
    overflow-x: auto;
    white-space: nowrap;
    padding-right: 0.5rem;
  }
  
  .logout-button {
    grid-area: logout;
    margin: 0;
  }
  
  .logout-button a {
    padding: 0.3rem 0.5rem;
    white-space: nowrap;
  }
  
  table {
    font-size: 0.9rem;
  }
  
  /* Prevent text overflow in table cells */
  table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Add more spacing between columns */
  table th, table td {
    padding: var(--spacing-xs) var(--spacing-sm);
  }
  
  /* Adjust login box on mobile */
  .centered-login-box {
    margin-top: 4rem;
    padding: 1.5rem;
  }
  
  /* Path parts should wrap on mobile */
  .path-parts {
    overflow: auto;
    max-width: 100%;
    padding-bottom: var(--spacing-xs);
  }
  
  /* Adjust padding for main container to accommodate sticky header */
  body {
    padding-top: 1rem;
  }
}

/* Table styling for better dark theme contrast */
[data-theme="dark"] table th {
  color: var(--color-text);
  background-color: var(--color-surface);
}

[data-theme="dark"] table thead {
  border-bottom: 1px solid var(--color-border);
}

[data-theme="dark"] table th:hover {
  color: var(--color-primary-text, var(--color-primary));
}

[data-theme="dark"] td:nth-child(2), 
[data-theme="dark"] td:nth-child(3) {
  color: var(--color-text-muted);
}

[data-theme="dark"] svg {
  fill: var(--color-text);
}

[data-theme="dark"] .footer-icon {
  fill: var(--color-text-muted) !important;
}

[data-theme="dark"] .footer-link svg {
  fill: var(--color-text-muted) !important;
}

[data-theme="dark"] .view-icon svg,
[data-theme="dark"] .link-icon svg {
  fill: var(--color-primary-text, var(--color-primary));
}

[data-theme="dark"] article {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

[data-theme="dark"] input[type="checkbox"] {
  accent-color: #888; /* Muted color for dark theme checkboxes */
}


.logout-icon {
  vertical-align: middle;
  margin-right: 0.25rem;
}

/* Multi-file selection styles */
.actions-container {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-lg);
  margin-left: auto;
}

.selection-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  height: 30px;
}

#selection-status form {
  display: inline-flex; 
  margin: 0;
  vertical-align: middle;
}

.selected-count {
  color: var(--color-white);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.download-selected-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  padding: 0.3rem 0.6rem;
  background-color: var(--color-white-overlay);
  color: var(--color-white);
  border: 1px solid var(--color-white-overlay);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.2s;
  white-space: nowrap;
  text-align: center;
  margin-left: 0.5rem;
}

.download-selected-btn:hover {
  background-color: var(--color-white-overlay-hover);
}

.download-selected-btn svg {
  fill: var(--color-white) !important;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Breadcrumbs layout */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background-color: var(--color-primary);
  color: var(--color-white);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--color-shadow);
  margin-bottom: var(--spacing-md);
  border-radius: var(--border-radius-md);
}

/* Responsive adjustments for selection elements */
@media (max-width: 768px) {
  .breadcrumbs {
    flex-direction: column;
    align-items: flex-start;
    row-gap: var(--spacing-sm);
  }
  
  .path-parts {
    width: 100%;
    overflow: auto;
    margin-bottom: var(--spacing-xs);
  }
  
  .actions-container {
    width: 100%;
    margin-top: var(--spacing-sm);
    display: flex;
    justify-content: space-between;
  }
  
  .selection-status {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }
  
  .download-selected-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  
  .selected-count {
    font-size: 0.8rem;
  }
}