/* ============================================
   COMMON ADMIN STYLES
   Shared across all admin pages
   ============================================ */

/* Messages */
.message {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  display: none;
}

.message.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.message.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.message.info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.message.warning {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.admin-message-wrapper {
  pointer-events: none;
  z-index: 3000;
}

.admin-message {
  position: fixed;
  pointer-events: auto;
  display: none;
  max-width: 600px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

#admin-message-top {
  top: 120px;
  right: 30px;
  left: auto;
  transform: none;
  width: auto;
  min-width: 260px;
  max-width: 360px;
  z-index: 4000;
}

#admin-message-bottom {
  bottom: 30px;
  right: 30px;
  max-width: 320px;
}

@media (max-width: 640px) {
  #admin-message-top {
    top: 96px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    min-width: unset;
    max-width: unset;
  }
}

/* Buttons */
.btn {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
}

.btn:visited,
.btn:active,
.btn:focus {
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #ccc;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.35);
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #5a6268;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-edit {
  background-color: #0ea5a5;
  color: white;
}

.btn-edit:hover:not(:disabled) {
  background-color: #0b7f81;
}

.btn-delete,
.btn-danger {
  background-color: #dc2626;
  color: white;
}

.btn-delete:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
}

.btn-save {
  background-color: #28a745;
  color: white;
}

.btn-save:hover:not(:disabled) {
  background-color: #218838;
}

.btn-cancel {
  background-color: #6c757d;
  color: white;
}

.btn-cancel:hover:not(:disabled) {
  background-color: #5a6268;
}

.btn-restore {
  background-color: #d97706;
  color: white;
}

.btn-restore:hover:not(:disabled) {
  background-color: #b45309;
}

.btn-play {
  background-color: #28a745;
  color: white;
}

.btn-play:hover:not(:disabled) {
  background-color: #218838;
}

/* AI Processing Button */
.btn-ai {
  background-color: #8b5cf6;
  color: white;
}

.btn-ai:hover:not(:disabled) {
  background-color: #7c3aed;
}

.btn-ai--processing {
  background-color: #a78bfa;
  cursor: wait;
}

.btn-ai--completed {
  background-color: #22c55e;
}

.btn-ai--completed:hover:not(:disabled) {
  background-color: #16a34a;
}

.btn-ai--failed {
  background-color: #ef4444;
}

.btn-ai--failed:hover:not(:disabled) {
  background-color: #dc2626;
}

.btn-page {
  padding: 0.5rem 1rem;
  background-color: #0066cc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-page:hover:not(:disabled) {
  background-color: #0052a3;
}

.btn-page:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* Page nav buttons */
.page-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-nav .login-link {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: white;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.2);
}

.page-nav .login-link:hover {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  color: white;
}

.page-nav .login-link:focus-visible {
  outline: 3px solid #c7d2fe;
  outline-offset: 2px;
}

/* Loading Indicator */
.loading {
  text-align: center;
  padding: 3rem;
  color: #666;
  font-size: 1.1rem;
}

/* Filters */
.filters {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
}

.filter-group input,
.filter-group select {
  padding: 0.6rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.filter-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.filter-stats {
  display: flex;
  align-items: center;
  color: #666;
  font-size: 0.9rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.data-table,
.files-table,
.options-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background-color: white;
}

.data-table thead,
.files-table thead,
.options-table thead {
  background-color: #f8f9fa;
}

.data-table th,
.files-table th,
.options-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

.data-table td,
.files-table td,
.options-table td {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.data-table tbody tr:hover,
.files-table tbody tr:hover,
.options-table tbody tr:hover {
  background-color: #f8f9fa;
}

.data-table .number {
  text-align: right;
  font-weight: 600;
  color: #667eea;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #999;
}

/* Table Section */
.table-section {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.table-section h3 {
  margin: 0 0 1rem 0;
  color: #333;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-active {
  background-color: #d4edda;
  color: #155724;
}

.badge-inactive {
  background-color: #f8d7da;
  color: #721c24;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #333;
}

.form-group label .required {
  color: #e74c3c;
  margin-left: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Confirmation Dialog */
.confirm-dialog {
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
}

.confirm-dialog.show {
  display: flex;
}

.confirm-content {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.confirm-content h3 {
  margin: 0 0 1rem 0;
  color: #2c3e50;
}

.confirm-content p {
  margin: 0 0 1.5rem 0;
  color: #666;
}

.confirm-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
}

#page-info {
  color: #666;
  font-size: 0.9rem;
}

/* Actions Cell */
.actions-cell {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ============================================
   MEDIA GROUP STYLES
   For expand/collapse grouped files
   ============================================ */

/* Expand/collapse toggle icon */
.expand-icon {
  display: inline-block;
  width: 1.2rem;
  cursor: pointer;
  user-select: none;
  color: #667eea;
  font-size: 0.8rem;
  margin-right: 0.3rem;
  transition: transform 0.2s;
}

.expand-icon:hover {
  color: #4a5fc1;
}

/* Placeholder for alignment when no expand icon */
.expand-icon-placeholder {
  display: inline-block;
  width: 1.5rem;
}

/* Group row (primary file) */
.group-row.has-multiple {
  background-color: #fafbff;
}

.group-row.has-multiple:hover {
  background-color: #f0f3ff;
}

/* Media type icons container */
.media-icons {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Secondary row (grouped child files) */
.secondary-row {
  background-color: #f9f9f9;
  border-left: 3px solid #667eea;
}

.secondary-row:hover {
  background-color: #f0f3ff;
}

.secondary-row td.indented {
  padding-left: 2.5rem;
}

/* Media type badge for secondary rows */
.media-type-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background-color: #e8ecff;
  color: #4a5fc1;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-right: 0.5rem;
  white-space: nowrap;
}

/* Row inactive state */
.row-inactive {
  opacity: 0.6;
}

.row-inactive td {
  color: #888;
}

/* ============================================
   LINK DIALOG STYLES
   For linking files together
   ============================================ */

.link-dialog-content {
  background-color: white;
  padding: 1.5rem;
  border-radius: 8px;
  width: 90%;
  max-width: 550px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.link-dialog-content h3 {
  margin: 0 0 1rem 0;
  color: #2c3e50;
}

.link-source-file {
  background-color: #f0f3ff;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border-left: 3px solid #667eea;
}

.link-search-container {
  margin-bottom: 1rem;
}

.link-search-container input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.link-search-container input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.link-files-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.link-file-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.15s;
}

.link-file-item:last-child {
  border-bottom: none;
}

.link-file-item:hover {
  background-color: #f8f9fa;
}

.link-file-item.selected {
  background-color: #e8ecff;
}

.link-file-item input[type="checkbox"] {
  margin-right: 0.75rem;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.link-file-info {
  flex: 1;
  min-width: 0;
}

.link-file-name {
  display: block;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-file-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
}

.link-file-note {
  padding: 0.5rem;
  text-align: center;
  color: #888;
  font-size: 0.85rem;
  background-color: #f8f9fa;
}

.link-primary-select {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background-color: #fff8e6;
  border-radius: 6px;
  border: 1px solid #ffe08a;
}

.link-primary-select label {
  display: block;
  margin-bottom: 0.5rem;
  color: #856404;
}

.link-primary-select select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}
