/* Images Admin Page Styles */

/* Filters Bar */
.filters-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  background: white;
  padding: 1rem;
  border-radius: var(--radius-lg);
}

.filter-tabs {
  display: flex;
  gap: 0.5rem;
}

.filter-tab {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.filter-tab:hover {
  background: var(--color-bg-alt);
}

.filter-tab.active {
  background: var(--color-primary);
  color: white;
}

/* AI処理状況インジケーター */
.ai-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: #8b5cf6;
}

.ai-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: ai-spin 1s linear infinite;
}

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

.ai-status-text {
  font-weight: 500;
}

/* 画像カードのAI処理中表示 */
.image-card.ai-processing {
  position: relative;
}

.image-card.ai-processing::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(139, 92, 246, 0.15);
  border: 2px solid #8b5cf6;
  border-radius: inherit;
  pointer-events: none;
  animation: ai-pulse 2s ease-in-out infinite;
}

.image-card .ai-processing-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #8b5cf6;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  z-index: 10;
}

.image-card .ai-processing-badge .mini-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: ai-spin 1s linear infinite;
}

@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* テーブル行のAI処理中表示 */
.images-table tr.ai-processing {
  background: rgba(139, 92, 246, 0.08) !important;
}

.images-table tr.ai-processing td:first-child {
  position: relative;
}

.images-table tr.ai-processing td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #8b5cf6;
}

.batch-generate-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  margin-left: 0.5rem;
}

.batch-generate-btn:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.batch-generate-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.batch-generate-btn svg {
  width: 16px;
  height: 16px;
}

.batch-generate-btn svg.spin {
  animation: spin 1s linear infinite;
}

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

/* View Toggle Buttons */
.view-toggle {
  display: flex;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-text-light);
  cursor: pointer;
  border-radius: calc(var(--radius-md) - 2px);
  transition: all 0.2s;
}

.view-btn:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.5);
}

.view-btn.active {
  background: white;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filter-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.filter-select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
}

/* Images Table */
.images-table-container {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.images-table th,
.images-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.images-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-light);
  background: var(--color-bg-alt);
}

.check-col {
  width: 40px;
}

.images-table tbody tr:hover {
  background: #fafafa;
}

/* Image Cell */
.image-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.image-thumb {
  width: 60px;
  height: 45px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.image-info {
  display: flex;
  flex-direction: column;
}

.image-title-link {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.image-title-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.image-filename {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.published {
  background: #d1fae5;
  color: #059669;
}

.status-badge.draft {
  background: #fef3c7;
  color: #d97706;
}

.status-badge.ai_pending,
.status-badge.pending_ai {
  background: #e0e7ff;
  color: #4f46e5;
}

.status-badge.ai_failed {
  background: #fee2e2;
  color: #dc2626;
}

/* Category Badge */
.category-badge {
  font-size: 0.875rem;
}

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

.action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--color-bg-alt);
}

.action-btn.delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* Bulk Actions */
.bulk-actions {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.bulk-actions .btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.bulk-actions .btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

.bulk-actions .btn-danger {
  border-color: #f87171;
  color: #f87171;
}

.bulk-actions .btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

.selected-count {
  font-size: 0.875rem;
  opacity: 0.8;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-light);
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--color-bg-alt);
}

.modal-body {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
}

.modal-preview img {
  width: 100%;
  border-radius: var(--radius-md);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.modal-form label {
  font-size: 0.8rem;
  font-weight: 500;
}

/* 言語タブ */
.lang-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lang-tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  background: transparent;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.lang-tab:hover {
  background: var(--color-bg-alt);
}

.lang-tab.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.modal-form textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
}

.modal-form input,
.modal-form select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

/* Responsive */
@media (max-width: 900px) {
  .filters-bar {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .images-table {
    font-size: 0.875rem;
  }

  .images-table th:nth-child(5),
  .images-table td:nth-child(5) {
    display: none;
  }

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

  .bulk-actions {
    left: 1rem;
    right: 1rem;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .images-table th:nth-child(6),
  .images-table td:nth-child(6),
  .images-table th:nth-child(7),
  .images-table td:nth-child(7) {
    display: none;
  }
}

/* ========================================
   Card View Styles
   ======================================== */
.images-card-container {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.images-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.image-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.2s;
  position: relative;
}

.image-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.image-card-thumb {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.image-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: transform 0.3s;
}

.image-card:hover .image-card-thumb img {
  transform: scale(1.05);
}

.image-card-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.image-card-status {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.image-card-body {
  padding: 1rem;
}

.image-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

.image-card-title a {
  color: inherit;
  text-decoration: none;
}

.image-card-title a:hover {
  color: var(--color-primary);
}

.image-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-bottom: 0.75rem;
}

.image-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.image-card-actions {
  display: flex;
  gap: 0.5rem;
}

.image-card-actions .action-btn {
  flex: 1;
  justify-content: center;
}

/* Card View Empty State */
.images-card-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-light);
}

.images-card-empty svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Card View Responsive */
@media (max-width: 1200px) {
  .images-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .images-card-grid {
    grid-template-columns: 1fr;
  }
}
