/* Index page styles */

* {
  box-sizing: border-box;
}

/* iOS viewport height fix */
:root {
  --vh: 1vh;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

body {
  background: var(--bg-primary, #1a1a1a);
  color: var(--text-primary, #e0e0e0);
  min-height: calc(var(--vh, 1vh) * 100);
  padding: 10px;
  padding-top: calc(10px + var(--safe-area-top));
  padding-bottom: calc(10px + var(--safe-area-bottom));
  margin: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  /* Prevent iOS bounce scroll */
  overscroll-behavior: none;
}



.container {
  padding: 0;
  max-width: 640px;
}

.main-card {
  background: var(--sidebar-bg, rgba(10, 10, 10, 0.98));
  color: var(--text-primary, #e0e0e0);
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
  padding: 12px;
  margin-bottom: 10px;
}

/* Info card specific styles */
.main-card.alert-info {
  position: relative;
  background: var(--sidebar-bg, rgba(10, 10, 10, 0.98));
  border-left: 4px solid var(--heading-color, #4fc3f7);
  padding-right: 40px;
}

.main-card.alert-info h6 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--heading-color, #4fc3f7);
}

.main-card.alert-info h6 i {
  margin-right: 6px;
}

.main-card.alert-info .info-close-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 18px;
  color: var(--text-primary, #e0e0e0);
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.main-card.alert-info .info-close-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Remove borders from buttons in main card */
.main-card .btn {
  border: none !important;
  box-shadow: none !important;
}

#beian-card {
  width: 150px;
  bottom: 0px;
  text-align: center;
  color: var(--border-color);
  font-size: 12px;
  z-index: -1;
  margin: 0 auto;
}

/* Compact upload section */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.upload-row .form-control {
  flex: 1;
  font-size: 14px;
  padding: 6px 10px;
}

.upload-row .btn {
  white-space: nowrap;
  padding: 6px 12px;
  font-size: 13px;
}

/* Book item styling */
.book-item {
  background: var(--bg-secondary, rgba(26, 26, 26, 0.95));
  color: var(--text-primary, #e0e0e0);
  padding: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
}

.book-header h5 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--heading-color, #4fc3f7);
}

/* Tree view folder icon */
.tree-folder-icon {
  color: var(--btn-hover-color, var(--heading-color));
  font-size: 1.1em;
  transition: transform 0.2s ease;
}

/* Tree structure styling */
.book-stories {
  position: relative;
  margin-left: 12px;
}

.tree-children {
  position: relative;
}

/* Story item in tree */
.story-item {
  position: relative;
  padding: 7px 8px 7px 24px;
  background: transparent;
  border-bottom: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* Last read story - highlight with sidebar-bg color */
.story-item.last-read-story {
  background-color: var(--sidebar-bg, rgba(10, 10, 10, 0.98));
  border-left: 3px solid var(--heading-color, #4fc3f7);
  font-weight: 500;
}

.story-item:hover {
  background-color: var(--btn-hover-bg, rgba(79, 195, 247, 0.1));
}

.story-item:active {
  background-color: var(--btn-active-bg, rgba(79, 195, 247, 0.2));
}

/* Story link wrapper */
.story-link-wrapper {
  flex: 1;
}

.story-item .story-title {
  color: var(--btn-hover-color, var(--heading-color));
  font-size: 0.9em;
  line-height: 1.4;
}

.story-item:hover .story-title {
  color: var(--heading-color);
}

.story-item .text-muted {
  font-size: 0.85em;
  white-space: nowrap;
}

/* Button styling - small buttons without borders */
.btn-link {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
  text-decoration: none !important;
}

.btn-link:hover {
  text-decoration: underline !important;
}

.btn-link.text-danger:hover {
  color: #ff6b6b !important;
}

.btn-link.text-primary:hover {
  color: var(--heading-color, #4fc3f7) !important;
}

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
}

.section-header h6 {
  margin: 0;
  font-size: 14px;
  color: var(--header-text-color, #e0e0e0);
}

/* Empty and loading states */
.empty-state,
.loading-state {
  text-align: center;
  padding: 30px 15px;
  color: var(--text-secondary, #e0e0e0);
  opacity: 0.7;
}

.empty-state i,
.loading-state i {
  font-size: 2rem;
  margin-bottom: 10px;
  display: block;
}

.empty-state p,
.loading-state p {
  margin: 0;
  font-size: 13px;
}

/* Pagination */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}

.pagination-controls .btn {
  padding: 6px 12px;
  font-size: 12px;
}

.page-info {
  font-size: 12px;
  color: var(--text-primary, #e0e0e0);
}

/* Form controls */
.form-control {
  background: var(--bg-primary, #1a1a1a);
  color: var(--text-primary, #e0e0e0);
  border: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
}

.form-control:focus {
  background: var(--bg-primary, #1a1a1a);
  color: var(--text-primary, #e0e0e0);
  border-color: var(--heading-color, #4fc3f7);
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
}

.form-control::placeholder {
  color: var(--text-secondary, #e0e0e0);
  opacity: 0.4;
}

/* Modal */
.modal-content {
  background: var(--sidebar-bg, rgba(10, 10, 10, 0.98));
  color: var(--text-primary, #e0e0e0);
  border: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
}

.modal-header,
.modal-footer {
  border-color: var(--border-color, rgba(224, 224, 224, 0.1));
}

.btn-close {
  filter: invert(1);
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  text-align: center;
  color: var(--text-primary, #e0e0e0);
}

.loading-spinner p {
  margin-top: 10px;
  font-size: 14px;
}

/* Minimum touch target sizes (44x38px Apple HIG) */
.btn {
  min-height: 38px;
  min-width: 38px;
}

.btn-sm {
  min-height: 35px;
  min-width: 35px;
}

@media (max-width: 576px) {
  body {
    padding: 8px;
    padding-left: calc(8px + var(--safe-area-left));
    padding-right: calc(8px + var(--safe-area-right));
  }

  .main-card {
    padding: 10px;
    border-radius: 10px;
  }

  .book-item {
    padding: 10px;
    border-bottom: 1px solid var(--border-color, rgba(224, 224, 224, 0.1));
  }

  .book-header h5 {
    font-size: 15px;
  }

  .btn-link {
    /* Minimum touch target */
    min-width: 38px;
    min-height: 38px;
    padding: 10px !important;
    font-size: 12px !important;
  }

  .upload-row {
    flex-wrap: wrap;
  }

  .upload-row .form-control {
    width: 100%;
    min-height: 38px;
    font-size: 16px;
  }

  .upload-row .btn {
    flex: 1;
    min-height: 38px;
  }
}
