/**
 * S3 Storage Browser Styles
 * A clean, responsive design for browsing S3 files
 */

/* Base Styles & CSS Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f4f4f9;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout Components */
.app-header {
  background-color: #144267;
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-content {
  flex: 1;
  width: 90%;
  max-width: 800px;
  margin: 1rem auto;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-footer {
  background-color: #f0f0f0;
  text-align: center;
  padding: 1rem;
  margin-top: auto;
  font-size: 0.8rem;
  color: #666;
}

/* Navigation */
.navigation .home-link {
  color: white;
  text-decoration: none;
  font-weight: bold;
}

.navigation .home-link:hover {
  text-decoration: underline;
}

/* Current Path Display */
.current-path {
  font-size: 1rem; /* Adjusted for better fit with breadcrumbs */
  font-weight: normal;
  text-align: center;
  flex-grow: 1;
  word-break: break-all;
  margin: 0 1rem;
  display: flex; /* Use flex to align breadcrumb items */
  align-items: center; /* Vertically align items */
  justify-content: center; /* Center breadcrumbs if space allows */
  flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.breadcrumb-segment {
  color: white;
  text-decoration: none;
  padding: 0.25em 0.5em;
  border-radius: 4px;
  transition: background-color 0.2s ease-in-out;
}

.breadcrumb-segment:hover {
  background-color: rgba(255, 255, 255, 0.2);
  text-decoration: none; /* Keep no underline on hover */
}

.breadcrumb-separator {
  margin: 0 0.4em;
  color: rgba(255, 255, 255, 0.7); /* Lighter color for separator */
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
}

#search-form {
  display: flex;
  align-items: center;
}

#search-form input {
  padding: 0.5rem;
  border: none;
  border-radius: 4px 0 0 4px;
  min-width: 200px;
}

.search-button {
  background: white;
  border: none;
  padding: 0.5rem;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.search-button:hover {
  background-color: #e6e6e6;
}

/* Auth Buttons */
.auth-section {
  display: flex;
  gap: 0.5rem;
}

.auth-button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

.auth-button.login {
  background-color: #ffffff;
  color: #0078d7;
}

.auth-button.login:hover {
  background-color: #f0f0f0;
}

.auth-button.logout {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.auth-button.logout:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* File List */
.file-list {
  list-style: none;
  padding: 0;
}

.file-list li {
  margin: 0.5rem 0;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
  transition: background 0.3s;
  display: flex; /* Added for flex layout of items within li */
  align-items: center; /* Vertically align items */
}

.file-list li:hover {
  background: #e6f7ff;
}

.file-list a {
  text-decoration: none;
  color: #0078d7;
  /* display: block; */ /* Removed, flex will handle layout */
  margin-left: 10px; /* Add some space between checkbox and link */
  flex-grow: 1; /* Allow link to take remaining space */
}

.file-list a:hover {
  text-decoration: underline;
}

/* Styles for the button-like checkbox */
.file-select-checkbox-label {
  display: inline-flex; /* Align custom checkbox with text */
  align-items: center;
  margin-right: 10px; /* Space between checkbox and file name */
  cursor: pointer;
  position: relative; /* For positioning the visual checkbox */
  padding-left: 25px; /* Make space for the custom checkbox */
  min-height: 20px; /* Ensure label is clickable */
}

.file-select-checkbox {
  display: none; /* Hide the actual checkbox */
}

.checkbox-visual {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 16px;
  width: 16px;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 3px;
  transition: background-color 0.2s, border-color 0.2s;
}

.file-select-checkbox:checked + .checkbox-visual {
  background-color: #007bff;
  border-color: #007bff;
}

.checkbox-visual::after {
  content: "";
  position: absolute;
  display: none;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.file-select-checkbox:checked + .checkbox-visual::after {
  display: block;
}

/* General App Button Style */
.app-button {
  background-color: #007bff; /* Default blue for primary actions */
  color: white;
  border: none;
  padding: 8px 15px; /* Consistent padding */
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  display: inline-flex; /* Helps with vertical alignment of content */
  align-items: center; /* Vertically align content (like text and icons) */
  justify-content: center; /* Horizontally align content */
  min-height: 36px; /* Ensure a minimum height */
  box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.app-button:hover {
  opacity: 0.9;
}

.app-button-cancel {
  background-color: #6c757d; /* Secondary/cancel grey */
}

.app-button-cancel:hover {
  background-color: #5a6268;
}

/* Specific styles for action buttons if needed, or rely on .app-button */
#move-files-button {
  background-color: #007bff; /* Blue for primary "Move" action */
  color: white;
}

#move-files-button:hover {
  background-color: #0056b3;
}

#select-all-button {
  background-color: #6c757d; /* Grey for "Select All" */
  color: white;
  /* removed margin-right, flexbox justify-content will handle spacing */
  min-width: 120px; /* Set a fixed minimum width for Select All/Deselect All */
  text-align: center; /* Ensure text is centered if it's shorter than min-width */
}

#action-buttons-container {
  margin-bottom: 15px;
  display: flex; /* Use flex to help align items */
  align-items: center; /* Align items vertically */
  justify-content: space-between; /* Pushes Select All to left, Move to New to right */
}

/* Loading Indicator */
.loading-indicator {
  text-align: center;
  padding: 1rem;
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left: 4px solid #0078d7;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 0 auto 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Load More Button */
.load-more-button {
  display: block;
  margin: 1rem auto;
  padding: 0.5rem 1rem;
  background-color: #0078d7;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

.load-more-button:hover {
  background-color: #005bb5;
}

/* Grey Layer (Overlay) */
#grey-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
}

/* File Viewer Modal */
.file-viewer-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1010;
  display: none;
  align-items: center;
  justify-content: center;
}

.file-viewer-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.file-viewer-header {
  background: #0078d7;
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.file-viewer-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin: 0;
  word-break: break-all;
}

.file-viewer-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.file-viewer-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-height: 400px;
  background: #f5f5f5;
}

.file-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-viewer-text {
  padding: 1rem;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.4;
  background: white;
  width: 100%;
  height: 100%;
  overflow: auto;
}

.file-viewer-unsupported {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.file-viewer-unsupported h3 {
  margin-bottom: 1rem;
  color: #333;
}

/* Navigation Arrows */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 50px;
  height: 80px;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
  z-index: 1020;
}

.nav-arrow:hover {
  background: rgba(0, 0, 0, 0.7);
}

.nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-arrow.prev {
  left: 20px;
  border-radius: 0 8px 8px 0;
}

.nav-arrow.next {
  right: 20px;
  border-radius: 8px 0 0 8px;
}

/* Control Buttons */
.viewer-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
  font-size: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.viewer-btn:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.viewer-btn.delete {
  background: rgba(220, 53, 69, 0.8);
}

.viewer-btn.delete:hover {
  background: rgba(220, 53, 69, 1);
}

.viewer-btn.delete:focus {
  outline: none;
  background: rgba(220, 53, 69, 1);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

/* Loading spinner for viewer */
.viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #666;
}

.viewer-loading .spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 1rem;
}

/* Delete Confirmation Dialog */
.delete-confirmation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1030;
  display: none;
  align-items: center;
  justify-content: center;
}

.delete-confirmation-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.delete-confirmation-content h3 {
  color: #dc3545;
  margin-bottom: 1rem;
}

.delete-confirmation-content p {
  margin-bottom: 1.5rem;
  color: #666;
}

.delete-confirmation-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.delete-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.delete-btn:hover {
  background: #c82333;
}

.delete-btn:focus {
  outline: none;
  background: #c82333;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.4);
}

.cancel-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.cancel-btn:hover {
  background: #5a6268;
}

.cancel-btn:focus {
  outline: none;
  background: #5a6268;
  box-shadow: 0 0 0 3px rgba(108, 117, 125, 0.4);
}

/* Keyboard hints styling */
kbd {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  color: #495057;
  display: inline-block;
  font-family: 'Courier New', monospace;
  font-size: 0.8em;
  font-weight: bold;
  line-height: 1;
  padding: 2px 4px;
  white-space: nowrap;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .navigation {
    display: flex;
    justify-content: space-between;
  }

  .search-bar {
    margin-top: 0.5rem;
    width: 100%;
  }

  #search-form {
    width: 100%;
  }

  #search-form input {
    flex-grow: 1;
    min-width: auto;
  }

  .auth-section {
    margin-top: 0.5rem;
    justify-content: center;
  }

  .app-content {
    width: 95%;
  }
}
