/* Collections Manager Styles */

.collections-manager {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
}

.collections-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid #1e293b;
  background: #0f172a;
}

.collections-header-left h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: #f1f5f9;
  display: flex;
  align-items: center;
}

.collections-subtitle {
  margin: 4px 0 0 0;
  font-size: 14px;
  color: #94a3b8;
}

.collections-header-actions {
  display: flex;
  gap: 12px;
}

/* Tabs */
.collections-tabs {
  display: flex;
  gap: 4px;
  padding: 0 32px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

.collections-tab {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.collections-tab:hover {
  color: #e2e8f0;
  background: #1e293b;
}

.collections-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

/* Content */
.collections-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* Loading */
.collections-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #1e293b;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty State */
.collections-empty {
  text-align: center;
  padding: 80px 20px;
  max-width: 500px;
  margin: 0 auto;
}

.collections-empty-icon {
  font-size: 80px;
  margin-bottom: 24px;
  opacity: 0.5;
}

.collections-empty h3 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #f1f5f9;
}

.collections-empty p {
  font-size: 16px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0 0 32px 0;
}

/* Collections Grid */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.collection-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  transition: all 0.2s;
}

.collection-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.collection-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.collection-card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #f1f5f9;
  font-family: monospace;
}

.collection-card-actions {
  display: flex;
  gap: 8px;
}

.collection-card-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  padding: 16px 0;
  border-top: 1px solid #334155;
  border-bottom: 1px solid #334155;
}

.collection-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.collection-stat-label {
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.collection-stat-value {
  font-size: 24px;
  font-weight: 600;
  color: #f1f5f9;
}

.collection-card-footer {
  display: flex;
  justify-content: flex-end;
}

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 8px 0;
}

.template-card {
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.template-card:hover {
  border-color: #3b82f6;
  background: #293548;
}

.template-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.template-card h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: #f1f5f9;
}

.template-card p {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.5;
}

.template-fields-preview {
  font-size: 12px;
  color: #64748b;
  padding: 8px;
  background: #0f172a;
  border-radius: 6px;
}

/* Collection Config */
.collection-config {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Fields List */
.fields-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fields-empty {
  padding: 32px;
  text-align: center;
  background: #1e293b;
  border: 2px dashed #334155;
  border-radius: 8px;
  color: #94a3b8;
}

/* Field Editor */
.field-editor {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
}

.field-editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.field-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #334155;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  flex-shrink: 0;
}

.field-name-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 14px;
  font-family: monospace;
}

.field-name-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.field-type-select {
  padding: 8px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 14px;
  cursor: pointer;
}

.field-type-select:focus {
  outline: none;
  border-color: #3b82f6;
}

.field-required-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}

.field-required-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.field-options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #334155;
}

/* Data View */
.collection-data-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.collection-data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Collection Filters */
.collection-filters {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group.filter-search {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.filter-label {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}

.btn-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  background: #334155;
  color: #94a3b8;
  border-radius: 4px;
}

.btn-clear:hover {
  background: #475569;
  color: #e2e8f0;
}

.filter-results {
  font-size: 13px;
  color: #64748b;
  padding: 8px 0 0 0;
}

.collection-data-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
}

.collection-data-empty {
  text-align: center;
  padding: 80px 20px;
  max-width: 500px;
  margin: 0 auto;
}

.collection-data-empty-icon {
  font-size: 80px;
  margin-bottom: 24px;
  opacity: 0.5;
}

.collection-data-empty h3 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #f1f5f9;
}

.collection-data-empty p {
  font-size: 16px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0 0 32px 0;
}

/* Data Table */
.data-table-container {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: #0f172a;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #334155;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.data-table th.sortable:hover {
  background: #1e293b;
  color: #e2e8f0;
}

.data-table th.sorted {
  color: #3b82f6;
}

.data-table tbody tr {
  border-bottom: 1px solid #334155;
  transition: background 0.2s;
}

.data-table tbody tr:hover {
  background: #293548;
}

.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: #e2e8f0;
}

.data-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-cell-id {
  font-family: monospace;
  color: #94a3b8;
  font-size: 12px;
}

.data-cell-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Data Form */
.data-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: #e2e8f0;
}

.form-input,
.form-input-sm {
  padding: 10px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

.form-input:focus,
.form-input-sm:focus {
  outline: none;
  border-color: #3b82f6;
}

.form-input::placeholder {
  color: #64748b;
}

textarea.form-input {
  resize: vertical;
  font-family: inherit;
}

.form-hint {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #e2e8f0;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-icon,
.btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #334155;
  color: #e2e8f0;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
}

.btn-icon:hover {
  background: #334155;
  color: #e2e8f0;
}

.btn-icon.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content.modal-lg {
  max-width: 900px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #1e293b;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #f1f5f9;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #1e293b;
  color: #e2e8f0;
}

.modal-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 24px;
  border-top: 1px solid #1e293b;
}

/* Responsive */
@media (max-width: 768px) {
  .collections-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .collections-grid {
    grid-template-columns: 1fr;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .field-editor-header {
    flex-wrap: wrap;
  }

  .data-table-container {
    overflow-x: auto;
  }
}
