/* ═══════════════════════════════════════════════
   ThumbAI — History Page CSS
   ═══════════════════════════════════════════════ */

/* ── Page Hero overrides ─────────────────────── */
.page-hero {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
  gap: 1rem; margin-bottom: 1.8rem;
  padding: 1.5rem 1.8rem;
  background: linear-gradient(135deg,
    rgba(124,58,237,0.08) 0%,
    rgba(167,139,250,0.06) 50%,
    rgba(237,233,254,0.8) 100%);
  border: 1px solid rgba(124,58,237,0.15);
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(124,58,237,0.06);
}

.page-hero-title {
  font-size: 1.7rem; font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px; margin-bottom: 0.2rem;
}

.page-hero-sub {
  font-size: 0.85rem; color: var(--text2);
}

.page-hero-actions {
  display: flex; align-items: center; gap: 0.8rem;
}

.history-count {
  font-size: 0.8rem; font-weight: 600;
  color: var(--text2);
  padding: 0.3rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.btn-clear {
  padding: 0.4rem 1rem;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.18);
  color: var(--red);
  font-family: inherit; font-size: 0.78rem; font-weight: 600;
  border-radius: 8px; cursor: pointer;
  transition: background 0.18s;
}
.btn-clear:hover { background: rgba(239,68,68,0.12); }

/* ── Empty State ─────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0.8rem;
  padding: 4rem 2rem; text-align: center;
}

.empty-icon { font-size: 3rem; opacity: 0.4; }
.empty-state h2 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.empty-state p { font-size: 0.85rem; color: var(--text3); max-width: 320px; }

.btn-go-generate {
  margin-top: 0.8rem;
  padding: 0.6rem 1.4rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-family: inherit; font-size: 0.85rem; font-weight: 700;
  border: none; border-radius: 10px; cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 3px 14px rgba(124,58,237,0.2);
}
.btn-go-generate:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(124,58,237,0.35); }

/* ── History Grid ────────────────────────────── */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.history-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.history-card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg3);
  overflow: hidden;
}

.history-card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.history-card-thumb .loading-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 0.8rem;
}

.history-card-info {
  padding: 0.8rem 1rem;
}

.history-card-title {
  font-size: 0.82rem; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 0.3rem;
}

.history-card-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}

.history-card-date {
  font-size: 0.68rem; color: var(--text3); font-weight: 500;
}

.history-card-style {
  font-size: 0.62rem; font-weight: 600;
  color: var(--primary);
  padding: 1px 6px;
  background: var(--primary-bg);
  border-radius: 12px;
  text-transform: capitalize;
}

.history-card-delete {
  position: absolute; top: 0.5rem; right: 0.5rem;
  width: 26px; height: 26px;
  background: rgba(0,0,0,0.5); border: none;
  color: #fff; font-size: 0.7rem;
  border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
  opacity: 0; transition: opacity 0.18s;
  backdrop-filter: blur(4px);
}
.history-card:hover .history-card-delete { opacity: 1; }
.history-card-delete:hover { background: rgba(239,68,68,0.7); }

/* ── Modal ───────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 700px; width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-title { font-size: 1rem; font-weight: 700; color: var(--text); }

.modal-close {
  width: 30px; height: 30px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); font-size: 0.8rem;
  border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.18s;
}
.modal-close:hover { background: var(--primary-bg); color: var(--primary); }

.modal-body {
  padding: 1rem;
}

.modal-body img {
  width: 100%; border-radius: 10px;
  display: block;
  border: 1px solid var(--border);
}

.modal-meta {
  padding: 0 1.2rem 0.8rem;
  font-size: 0.75rem; color: var(--text3);
  display: flex; gap: 1rem; flex-wrap: wrap;
}

.modal-actions {
  display: flex; gap: 0.6rem;
  padding: 0.8rem 1.2rem 1.2rem;
  border-top: 1px solid var(--border);
}

.btn-modal-download, .btn-modal-reuse, .btn-modal-delete {
  flex: 1;
  padding: 0.55rem 0.8rem;
  font-family: inherit; font-size: 0.78rem; font-weight: 600;
  border-radius: 8px; cursor: pointer;
  transition: background 0.18s, transform 0.12s;
  border: 1px solid var(--border);
}

.btn-modal-download {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border: none;
}
.btn-modal-download:hover { transform: translateY(-1px); }

.btn-modal-reuse {
  background: var(--surface2);
  color: var(--text);
}
.btn-modal-reuse:hover { background: var(--primary-bg); color: var(--primary); }

.btn-modal-delete {
  background: rgba(239,68,68,0.06);
  color: var(--red);
  border-color: rgba(239,68,68,0.18);
}
.btn-modal-delete:hover { background: rgba(239,68,68,0.12); }

/* ── Dark mode ───────────────────────────────── */
[data-theme="dark"] .page-hero {
  background: linear-gradient(135deg,
    rgba(124,58,237,0.15) 0%,
    rgba(167,139,250,0.08) 50%,
    rgba(22,19,46,0.8) 100%);
  border-color: rgba(124,58,237,0.25);
}

[data-theme="dark"] .page-hero-title {
  color: var(--primary-light);
}

[data-theme="dark"] .modal-backdrop {
  background: rgba(0,0,0,0.7);
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 520px) {
  .history-grid { grid-template-columns: 1fr; }
  .page-hero { flex-direction: column; align-items: flex-start; }
  .modal-actions { flex-direction: column; }
}
