/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f5f5f5;
}

/* === Site Description === */
.site-description {
  background: #16213e;
  color: #fff;
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  opacity: 0.85;
}

.site-description h1 {
  font-size: inherit;
  font-weight: normal;
  line-height: inherit;
}

/* === Layout === */
.site-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem;
}

/* === Header === */
.site-header {
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1rem;
}

.header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1600px;
  margin: 0 auto;
}

.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}

.nav-brand:hover {
  opacity: 0.9;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-links > a {
  color: #fff;
  opacity: 0.85;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-links > a:hover {
  opacity: 1;
}

.nav-github {
  display: inline-flex;
  align-items: center;
  color: #fff;
  opacity: 0.85;
}

.nav-github:hover {
  opacity: 1;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  background: transparent;
  border: none;
  color: #fff;
  opacity: 0.85;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0;
  font-family: inherit;
}

.nav-dropdown-toggle:hover {
  opacity: 1;
}

.nav-dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 140px;
  display: none;
  z-index: 10;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: #1a1a2e;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-dropdown-menu a:hover {
  background: #f0f0f0;
}

/* === Search Block === */
.search-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.search-row input:focus {
  outline: none;
  border-color: #4361ee;
  box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.search-row button {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.search-row button:hover {
  background: #3a56d4;
}

/* === Date Row === */
.date-row {
  display: flex;
  gap: 0.5rem;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-field label {
  font-size: 0.85rem;
  color: #555;
  white-space: nowrap;
}

.date-field input {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 140px;
  cursor: pointer;
}

.date-field input:focus {
  outline: none;
  border-color: #4361ee;
  box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

/* === Active Filters === */
#active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

#active-filters:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem 0.25rem 0.7rem;
  font-size: 0.85rem;
  background: #4361ee;
  color: #fff;
  border-radius: 16px;
  white-space: nowrap;
}

.filter-chip .chip-label {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-chip .chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.85rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.filter-chip .chip-remove:hover {
  background: rgba(255, 255, 255, 0.45);
}

/* === Toolbar === */
.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.toolbar button {
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.toolbar button:hover {
  background: #e8e8e8;
}

#btn-edit {
  background: #4361ee;
  color: #fff;
  border-color: #4361ee;
}

#btn-edit:hover {
  background: #3a56d4;
}

#btn-save {
  background: #2ecc71;
  color: #fff;
  border-color: #2ecc71;
}

#btn-save:hover {
  background: #27ae60;
}

#btn-add {
  background: #4361ee;
  color: #fff;
  border-color: #4361ee;
}

#btn-add:hover {
  background: #3a56d4;
}

#btn-cancel {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

#btn-cancel:hover {
  background: #c0392b;
}

/* === Table === */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ddd;
}

thead {
  background: #1a1a2e;
  color: #fff;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

th {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  background: #2a2a4e;
}

th.sortable::after {
  content: "";
}

th.sortable.sort-asc::after {
  content: " \25B2";
}

th.sortable.sort-desc::after {
  content: " \25BC";
}

tbody tr:nth-child(even) {
  background: #f9f9fb;
}

tbody tr:hover {
  background: #eef1ff;
}

td a {
  color: #4361ee;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

/* === Image Column === */
.col-image {
  width: 150px;
  min-width: 150px;
  padding: 0.3rem;
}

.row-thumb {
  display: block;
  width: 150px;
  height: 60px;
  object-fit: cover;
  border-radius: 3px;
}

/* === Description Column === */
td:nth-child(5) {
  max-width: 585px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  line-height: 1.4;
  position: relative;
  cursor: default;
}

td:nth-child(5)[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 100;
  background: #1a1a2e;
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 500px;
  white-space: normal;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

/* === Tag Pills === */
a.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin: 0.1rem 0.15rem;
  font-size: 0.78rem;
  background: #e8ecff;
  color: #4361ee;
  border-radius: 12px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

a.tag:hover {
  background: #d0d8ff;
  text-decoration: none;
}

/* === Inline Edit Inputs === */
td input[type="text"] {
  width: 100%;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
  border: 1px solid #ccc;
  border-radius: 3px;
}

td select {
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
  border: 1px solid #ccc;
  border-radius: 3px;
}

/* === Action Buttons in Table === */
.row-actions {
  display: flex;
  gap: 0.3rem;
  white-space: nowrap;
}

.row-actions button {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
}

.row-actions button:hover {
  background: #e8e8e8;
}

.row-actions .btn-delete {
  color: #e74c3c;
  border-color: #e74c3c;
}

.row-actions .btn-delete:hover {
  background: #fde8e6;
}

.row-actions .btn-row-save {
  color: #2ecc71;
  border-color: #2ecc71;
}

.row-actions .btn-row-save:hover {
  background: #e6f9ee;
}

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  min-width: 2rem;
  text-align: center;
}

.pagination button:hover {
  background: #e8ecff;
}

.pagination button.active {
  background: #4361ee;
  color: #fff;
  border-color: #4361ee;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.pagination .pg-size {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  margin-right: auto;
}

/* === Utility === */
.hidden {
  display: none !important;
}

/* === Responsive === */
@media (max-width: 600px) {
  .header-nav {
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .search-row {
    flex-direction: column;
  }

  .date-row {
    flex-direction: column;
  }

  .date-field input {
    width: 100%;
    flex: 1;
  }

  .toolbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .col-image {
    width: 80px;
    min-width: 80px;
  }

  .row-thumb {
    width: 80px;
    height: 32px;
  }
}
