/* ═══════════════════════════════════════════════
   ABORN POWERS — media.css
   Media Library styles
   ═══════════════════════════════════════════════ */

/* ── Media Modal Overlay ── */
#media-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: stretch;
  justify-content: center;
}
#media-modal.open {
  display: flex;
}

/* ── Media Modal Shell ── */
.media-shell {
  background: #F7F7F5;
  width: 100%;
  max-width: 1100px;
  margin: 24px auto;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  max-height: calc(100vh - 48px);
}

/* ── Media Header ── */
.media-header {
  background: #1E1E1E;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}
.media-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.media-header-title {
  font-size: 13px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.01em;
}
.media-header-context {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.08);
  padding: 3px 8px;
  border-radius: 12px;
}
.media-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.media-close-btn {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.media-close-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* ── Media Body (3-column layout) ── */
.media-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Left Sidebar ── */
.media-sidebar {
  width: 180px;
  min-width: 180px;
  background: white;
  border-right: 1px solid #E2E2DE;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.media-sidebar-section {
  padding: 14px 0 8px;
}
.media-sidebar-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #bbb;
  padding: 0 14px 6px;
}
.media-cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: all 0.12s;
  border-radius: 0;
}
.media-cat-btn:hover {
  background: #F7F7F5;
  color: #1E1E1E;
}
.media-cat-btn.active {
  background: #FFFBEA;
  color: #1E1E1E;
  font-weight: 600;
}
.media-cat-btn.active .media-cat-icon {
  color: #E8B800;
}
.media-cat-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.media-cat-count {
  margin-left: auto;
  font-size: 10px;
  color: #bbb;
  background: #F0F0EE;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
}

/* ── Main Area ── */
.media-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top Controls ── */
.media-controls {
  background: white;
  border-bottom: 1px solid #E2E2DE;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.media-search-wrap {
  flex: 1;
  position: relative;
}
.media-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #bbb;
  pointer-events: none;
}
.media-search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid #E2E2DE;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: 'Inter', sans-serif;
  background: #F7F7F5;
  outline: none;
  color: #1E1E1E;
  transition: border-color 0.15s;
}
.media-search-input:focus {
  border-color: #E8B800;
  background: white;
}
.media-sort-select {
  padding: 7px 10px;
  border: 1px solid #E2E2DE;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  background: #F7F7F5;
  color: #555;
  cursor: pointer;
  outline: none;
}
.media-upload-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #E8B800;
  color: #1E1E1E;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: 'Inter', sans-serif;
}
.media-upload-btn:hover { background: #d4a700; }

/* ── Upload Drop Zone (shown when no files or dragging) ── */
.media-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(232,184,0,0.08);
  border: 3px dashed #E8B800;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.media-drop-overlay.visible { opacity: 1; }
.media-drop-overlay svg { margin-bottom: 10px; color: #E8B800; }
.media-drop-overlay p { font-size: 14px; font-weight: 600; color: #1E1E1E; }

/* ── Grid ── */
.media-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  position: relative;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

/* ── File Card ── */
.media-card {
  background: white;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.media-card:hover {
  border-color: #E8B800;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.media-card.selected {
  border-color: #E8B800;
  box-shadow: 0 0 0 3px rgba(232,184,0,0.25);
}
.media-card-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  background: #F0F0EE;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.media-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-card-thumb .media-doc-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #999;
}
.media-card-thumb .media-doc-icon svg { color: #E8B800; }
.media-card-thumb .media-doc-ext {
  font-size: 10px;
  font-weight: 800;
  color: #E8B800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #1E1E1E;
  padding: 2px 5px;
  border-radius: 3px;
}

/* Selected checkmark overlay */
.media-card-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: #E8B800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.media-card.selected .media-card-check { opacity: 1; }

/* Action overlay on hover */
.media-card-actions {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.media-card:hover .media-card-actions { opacity: 1; }
.media-action-btn {
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.65);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  padding: 0;
}
.media-action-btn:hover { background: rgba(0,0,0,0.85); }
.media-action-btn.danger:hover { background: #c0392b; }

.media-card-info {
  padding: 7px 8px;
  border-top: 1px solid #F0F0EE;
}
.media-card-name {
  font-size: 11px;
  font-weight: 500;
  color: #1E1E1E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.media-card-meta {
  font-size: 10px;
  color: #aaa;
}

/* ── Empty State ── */
.media-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #bbb;
  text-align: center;
  gap: 10px;
}
.media-empty p { font-size: 13px; line-height: 1.6; }
.media-empty strong { color: #888; }

/* ── Upload Progress ── */
.media-upload-progress {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  padding: 14px 16px;
  z-index: 500;
  display: none;
}
.media-upload-progress.visible { display: block; }
.media-upload-progress-title {
  font-size: 12px;
  font-weight: 600;
  color: #1E1E1E;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.media-progress-bar-wrap {
  background: #F0F0EE;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}
.media-progress-bar {
  height: 100%;
  background: #E8B800;
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}
.media-progress-status {
  font-size: 10.5px;
  color: #888;
}

/* ── Detail Panel ── */
.media-detail {
  width: 220px;
  min-width: 220px;
  background: white;
  border-left: 1px solid #E2E2DE;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.media-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ccc;
  padding: 20px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  gap: 8px;
}
.media-detail-preview {
  background: #F0F0EE;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.media-detail-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.media-detail-body {
  padding: 14px;
  flex: 1;
}
.media-detail-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #1E1E1E;
  word-break: break-word;
  margin-bottom: 10px;
  line-height: 1.4;
}
.media-detail-field {
  margin-bottom: 10px;
}
.media-detail-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #bbb;
  margin-bottom: 3px;
}
.media-detail-value {
  font-size: 11.5px;
  color: #555;
}
.media-detail-input {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid #E2E2DE;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: 'Inter', sans-serif;
  color: #1E1E1E;
  outline: none;
  background: #F7F7F5;
}
.media-detail-input:focus {
  border-color: #E8B800;
  background: white;
}
.media-detail-select {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid #E2E2DE;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: 'Inter', sans-serif;
  color: #1E1E1E;
  background: #F7F7F5;
  outline: none;
}
.media-detail-footer {
  padding: 12px 14px;
  border-top: 1px solid #E2E2DE;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.media-detail-insert-btn {
  width: 100%;
  padding: 9px;
  background: #1E1E1E;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.media-detail-insert-btn:hover { background: #000; }
.media-detail-insert-btn:disabled { background: #ccc; cursor: not-allowed; }
.media-detail-action-row {
  display: flex;
  gap: 5px;
}
.media-detail-action-btn {
  flex: 1;
  padding: 6px;
  background: #F7F7F5;
  border: 1px solid #E2E2DE;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.media-detail-action-btn:hover { background: #E2E2DE; color: #1E1E1E; }
.media-detail-action-btn.danger { color: #c0392b; }
.media-detail-action-btn.danger:hover { background: #fdecea; border-color: #f5c6c2; }

/* ── Footer ── */
.media-footer {
  background: white;
  border-top: 1px solid #E2E2DE;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.media-footer-info {
  font-size: 11px;
  color: #aaa;
}
.media-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.media-insert-selected-btn {
  padding: 8px 16px;
  background: #E8B800;
  color: #1E1E1E;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s;
  display: none;
  align-items: center;
  gap: 6px;
}
.media-insert-selected-btn.visible {
  display: flex;
}
.media-insert-selected-btn:hover { background: #d4a700; }

/* ── Upload Source Picker (replaces direct upload zones) ── */
.upload-source-picker {
  border: 2px dashed #E2E2DE;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.upload-source-row {
  display: flex;
}
.upload-source-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: #F7F7F5;
  font-size: 11px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.upload-source-btn:first-child {
  border-right: 1px solid #E2E2DE;
}
.upload-source-btn:hover {
  background: #FFFBEA;
  color: #1E1E1E;
}
.upload-source-btn svg { color: #E8B800; }

/* ── Loading spinner ── */
.media-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.media-spinner-icon {
  width: 28px;
  height: 28px;
  border: 3px solid #E2E2DE;
  border-top-color: #E8B800;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Rename inline input ── */
.media-rename-form {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}
.media-rename-input {
  flex: 1;
  padding: 5px 7px;
  border: 1px solid #E8B800;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
}
.media-rename-save {
  padding: 5px 8px;
  background: #E8B800;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: #1E1E1E;
}

/* ── Tags ── */
.media-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.media-tag {
  background: #F0F0EE;
  color: #555;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}
.media-tag-remove {
  margin-left: 3px;
  cursor: pointer;
  color: #aaa;
}
.media-tag-remove:hover { color: #c0392b; }

/* ── Sidebar upload source integration ── */
.media-lib-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid #E2E2DE;
  border-radius: 5px;
  background: #F7F7F5;
  font-size: 11px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  width: 100%;
  font-family: 'Inter', sans-serif;
  transition: all 0.12s;
  margin-top: 6px;
}
.media-lib-trigger:hover {
  background: #FFFBEA;
  border-color: #E8B800;
  color: #1E1E1E;
}
.media-lib-trigger svg { color: #E8B800; }
