/* Library-specific styles */

/* Navigation */
.main-nav {
  display: flex;
  margin-top: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.nav-link {
  padding: 0.75rem 1.5rem;
  color: var(--secondary-color);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--primary-color);
}

.nav-link.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.tab-button {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  color: var(--secondary-color);
  cursor: pointer;
  transition: var(--transition);
}

.tab-button:hover {
  color: var(--primary-color);
}

.tab-button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* QR Code Preview */
.qr-preview-cell {
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.qr-preview-cell img {
  max-width: 100%;
  max-height: 100%;
}

/* Library Container */
.library-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  background-color: white;
  border-radius: 8px;
  box-shadow: var(--box-shadow);
  max-width: 1600px; /* Further increased max-width to avoid horizontal scrollbar */
  width: 95%; /* Ensure it takes up most of the available width */
  margin: 0 auto; /* Center the container */
}

/* Search Section */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-bar {
  display: flex;
  width: 100%;
}

.search-bar input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  font-size: 1rem;
}

.search-bar button {
  padding: 0.75rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  cursor: pointer;
}

.filter-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1rem;
  background-color: var(--light-color);
  border-radius: var(--border-radius);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary-color);
}

.filter-group select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background-color: var(--light-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn:hover {
  background-color: var(--border-color);
}

#my-utms-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
}

#my-utms-btn:hover {
  background-color: var(--primary-dark);
}

/* Results Section */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.results-header h2 {
  font-size: 1.25rem;
  color: var(--dark-color);
}

#result-count, #qrcode-count {
  color: var(--secondary-color);
  font-weight: normal;
}

.results-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.5rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  background-color: var(--primary-dark);
}

/* Results Table */
.results-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  min-width: 100%; /* Ensure container takes full width */
}

.results-table {
  width: 100%;
  min-width: 1200px; /* Set a minimum width to ensure all columns have enough space */
  border-collapse: collapse;
  table-layout: fixed; /* Use fixed layout for more predictable column widths */
}

/* Define specific column widths */
.results-table th:nth-child(1), 
.results-table td:nth-child(1) {
  width: 25%; /* URL column */
}

.results-table th:nth-child(2), 
.results-table td:nth-child(2) {
  width: 12%; /* Campaign column - reduced from 15% */
}

.results-table th:nth-child(3), 
.results-table td:nth-child(3) {
  width: 13%; /* Source/Medium column - reduced from 15% */
}

.results-table th:nth-child(4), 
.results-table td:nth-child(4) {
  width: 18%; /* Created column - increased from 15% */
  padding-right: 20px; /* Add extra padding to the right */
}

.results-table th:nth-child(5), 
.results-table td:nth-child(5) {
  width: 7%; /* Clicks column - decreased from 10% */
  text-align: center; /* Center align the clicks count */
}

.results-table th:nth-child(6), 
.results-table td:nth-child(6) {
  width: 12%; /* Tags column */
}

.results-table th:nth-child(7), 
.results-table td:nth-child(7) {
  width: 13%; /* Actions column */
}

/* QR Codes table column widths */
#qrcodes-tab .results-table th:nth-child(1),
#qrcodes-tab .results-table td:nth-child(1) {
  width: 20%; /* QR Code preview column */
}

#qrcodes-tab .results-table th:nth-child(2),
#qrcodes-tab .results-table td:nth-child(2) {
  width: 35%; /* URL column */
}

#qrcodes-tab .results-table th:nth-child(3),
#qrcodes-tab .results-table td:nth-child(3) {
  width: 20%; /* Created column */
}

#qrcodes-tab .results-table th:nth-child(4),
#qrcodes-tab .results-table td:nth-child(4) {
  width: 10%; /* Views column */
  text-align: center;
}

#qrcodes-tab .results-table th:nth-child(5),
#qrcodes-tab .results-table td:nth-child(5) {
  width: 15%; /* Actions column */
}

.results-table th,
.results-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.results-table th {
  background-color: var(--light-color);
  font-weight: 600;
  color: var(--secondary-color);
}

.results-table tr:last-child td {
  border-bottom: none;
}

.results-table tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.empty-state {
  text-align: center;
}

.empty-state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem;
  color: var(--secondary-color);
}

.empty-state-message i {
  font-size: 2rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Table Actions */
.table-actions {
  display: flex;
  flex-wrap: wrap; /* Allow buttons to wrap to next line if needed */
  gap: 0.5rem;
}

.table-action-btn {
  padding: 0.25rem 0.5rem;
  background-color: var(--light-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap; /* Prevent button text from wrapping */
}

.table-action-btn:hover {
  background-color: var(--border-color);
}

.table-action-btn.delete-btn {
  background-color: #f8d7da; /* Light red background */
  border-color: #f5c6cb;
  color: #721c24; /* Dark red text */
}

.table-action-btn.delete-btn:hover {
  background-color: #f5c6cb; /* Slightly darker red on hover */
}

/* Tags Display */
.tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background-color: var(--light-color);
  border-radius: 1rem;
  font-size: 0.8rem;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Warning Message */
.edit-warning {
  background-color: #fff3cd;
  color: #856404;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  border-left: 4px solid #ffc107;
}

.edit-warning i {
  color: #ffc107;
  font-size: 1.1rem;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  box-shadow: var(--box-shadow);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--primary-color);
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--secondary-color);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.modal-footer button {
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.modal-footer .primary-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
}

.modal-footer .primary-btn:hover {
  background-color: var(--primary-dark);
}

#duplicate-utm-btn {
  background-color: var(--light-color);
  border: 1px solid var(--border-color);
}

#duplicate-utm-btn:hover {
  background-color: var(--border-color);
}

#close-modal-btn {
  background-color: white;
  border: 1px solid var(--border-color);
}

/* UTM Details */
.utm-details-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.utm-details-section h3 {
  font-size: 1rem;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.detail-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary-color);
}

.detail-value {
  display: flex;
}

.detail-value input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  font-size: 0.9rem;
}

.detail-value .copy-btn,
.detail-value .qr-btn {
  padding: 0.5rem;
  background-color: var(--light-color);
  border: 1px solid var(--border-color);
  border-left: none;
  cursor: pointer;
}

.detail-value .copy-btn {
  border-radius: 0;
}

.detail-value .qr-btn {
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.detail-group input[readonly] {
  background-color: var(--light-color);
}

/* Tags */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tag-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--light-color);
  border-radius: 1rem;
  font-size: 0.8rem;
}

.tag-item .remove-tag {
  background: none;
  border: none;
  color: var(--secondary-color);
  cursor: pointer;
  font-size: 0.8rem;
}

.add-tag-container {
  display: flex;
  gap: 0.5rem;
}

.add-tag-container input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
}

.add-tag-container button {
  padding: 0.5rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Notes */
#detail-notes {
  width: 100%;
  height: 100px;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  resize: vertical;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--secondary-color);
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .filter-section {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Creator cell and avatar styles */
.creator-cell {
  display: flex;
  flex-direction: column;
}

.creator-info {
  display: flex;
  flex-direction: column;
}

.creator-date {
  font-size: 0.8rem;
  color: var(--secondary-color);
}

.creator-name {
  display: flex;
  align-items: center;
  font-weight: 500;
}

.avatar-container {
  display: inline-flex;
  margin-right: 4px; /* Reduced from 8px to 4px */
}

.user-avatar {
  border-radius: 50%;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Analytics Section Styles */
.view-analytics-btn {
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.view-analytics-btn:hover {
  background-color: var(--primary-dark);
}

.analytics-section {
  background-color: var(--light-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  position: relative;
}

.analytics-section h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-analytics-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--secondary-color);
}

.analytics-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.analytics-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  color: var(--secondary-color);
  cursor: pointer;
  transition: var(--transition);
}

.analytics-tab:hover {
  color: var(--primary-color);
}

.analytics-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.analytics-tab-content {
  display: none;
}

.analytics-tab-content.active {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.analytics-chart-container {
  flex: 1;
  min-width: 300px;
  background-color: white;
  border-radius: var(--border-radius);
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.analytics-chart-container h4 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--secondary-color);
}

.analytics-chart {
  height: 200px;
  position: relative;
}

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--secondary-color);
  font-size: 0.9rem;
}

.loading-spinner i {
  margin-right: 0.5rem;
}

/* Simple bar chart styles */
.simple-bar-chart {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0.5rem;
}

.chart-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-label {
  width: 100px;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-container {
  flex: 1;
  height: 20px;
  background-color: var(--light-color);
  border-radius: 10px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 10px;
}

.chart-value {
  width: 40px;
  font-size: 0.8rem;
  text-align: right;
}

/* No data message */
.no-data-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--secondary-color);
  font-size: 0.9rem;
}

.no-data-message i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}
