/* Database Table Component - Notion-style */

.database-container {
  width: 100%;
  margin: 1rem 0;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  overflow: hidden;
}

.database-controls {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(196, 149, 106, 0.2);
  flex-wrap: wrap;
}

.database-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.database-filter label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.database-filter select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(196, 149, 106, 0.3);
  color: #f0f0f0;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  min-width: 120px;
  cursor: pointer;
}

.database-filter select:focus {
  outline: none;
  border-color: #c4956a;
  box-shadow: 0 0 0 2px rgba(196, 149, 106, 0.1);
}

.database-table-wrapper {
  overflow-x: auto;
  max-height: 70vh;
  position: relative;
}

.database-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.database-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(20, 20, 20, 0.98);
}

.database-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #c4956a;
  background: rgba(196, 149, 106, 0.1);
  border-bottom: 2px solid rgba(196, 149, 106, 0.3);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.2s;
  position: relative;
}

.database-table th:hover {
  background: rgba(196, 149, 106, 0.15);
}

.database-table th.sorted-asc::after,
.database-table th.sorted-desc::after {
  content: '';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.database-table th.sorted-asc::after {
  border-bottom: 6px solid #c4956a;
}

.database-table th.sorted-desc::after {
  border-top: 6px solid #c4956a;
}

.database-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s;
}

.database-table tbody tr:hover {
  background: rgba(196, 149, 106, 0.05);
}

.database-table td {
  padding: 0.75rem 1rem;
  color: rgba(255, 255, 255, 0.85);
  vertical-align: top;
}

.database-cell {
  min-height: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.database-cell:hover {
  background: rgba(255, 255, 255, 0.05);
}

.database-cell-editing {
  background: rgba(196, 149, 106, 0.1);
  border: 1px solid #c4956a;
  padding: 0.25rem 0.5rem;
}

.database-cell-input {
  width: 100%;
  background: transparent;
  border: none;
  color: #f0f0f0;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.database-cell-textarea {
  width: 100%;
  min-height: 4rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #c4956a;
  color: #f0f0f0;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.5rem;
  border-radius: 4px;
  resize: vertical;
}

.database-cell-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(196, 149, 106, 0.3);
  color: #f0f0f0;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

.database-cell-number {
  width: 100%;
  background: transparent;
  border: none;
  color: #f0f0f0;
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
}

/* Property type badges */
.db-status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.db-status-reading {
  background: rgba(156, 175, 136, 0.2);
  color: #9caf88;
}

.db-status-to-read {
  background: rgba(168, 196, 216, 0.2);
  color: #a8c4d8;
}

.db-status-done {
  background: rgba(196, 149, 106, 0.2);
  color: #c4956a;
}

/* Rating stars */
.db-rating {
  display: inline-flex;
  gap: 0.2rem;
  color: #c4956a;
}

.db-rating-empty {
  opacity: 0.3;
}

/* Phase badges */
.db-phase {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

/* Long text preview */
.db-text-preview {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-text-full {
  max-width: 400px;
  line-height: 1.5;
}

/* Add button */
.database-add-row {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(196, 149, 106, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

.database-add-row:hover {
  background: rgba(196, 149, 106, 0.05);
  color: #c4956a;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .database-controls {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .database-filter {
    width: 100%;
  }
  
  .database-filter select {
    flex: 1;
  }
  
  .database-table th,
  .database-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .db-text-preview {
    max-width: 150px;
  }
}

/* Loading state */
.database-loading {
  text-align: center;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

/* Empty state */
.database-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255, 255, 255, 0.5);
}

.database-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Modal for long text editing */
.database-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.database-modal-content {
  background: #1a1a1a;
  border: 1px solid #c4956a;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.database-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.database-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #c4956a;
}

.database-modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.database-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f0f0f0;
}

.database-modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

.database-modal-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.database-modal-btn-primary {
  background: #c4956a;
  color: #1a1a1a;
}

.database-modal-btn-primary:hover {
  background: #d4a57a;
}

.database-modal-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #f0f0f0;
}

.database-modal-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}
