/*
Theme Name: SHOUT Templates
Theme URI: https://shoutmedia.nl
Author: SHOUT Media
Description: Template library dashboard — Worklenz-inspired design
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 8.0
License: Proprietary
Text Domain: shout-templates
*/

/* ---- Reset & Variables ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f9fa;
  --card: #fff;
  --border: #e5e7eb;
  --text: #111827;
  --text-sub: #6b7280;
  --text-muted: #9ca3af;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --orange: #ea580c;
  --orange-bg: #fff7ed;
  --red: #dc2626;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* WordPress admin bar fix */
body.admin-bar .topbar { top: 32px; }
@media screen and (max-width: 782px) {
  body.admin-bar .topbar { top: 46px; }
}

a { color: inherit; text-decoration: none; }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}

.topbar-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo svg {
  width: 28px;
  height: 28px;
}

.topbar-spacer { flex: 1; }

.topbar-stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-stats span { white-space: nowrap; }
.topbar-stats b { color: var(--text-sub); font-weight: 600; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  gap: 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-box {
  height: 36px;
  width: 280px;
  max-width: 100%;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cline x1='11' y1='11' x2='14' y2='14'/%3E%3C/svg%3E") no-repeat 10px center;
  color: var(--text);
  font-family: inherit;
}
.search-box:focus { border-color: var(--blue); background-color: var(--card); }
.search-box::placeholder { color: var(--text-muted); }

.toolbar-select {
  height: 36px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--card);
  color: var(--text-sub);
  outline: none;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.toolbar-select:focus { border-color: var(--blue); }

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.view-toggle-btn {
  height: 34px;
  padding: 0 14px;
  border: none;
  background: var(--card);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s;
}
.view-toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.view-toggle-btn:hover { background: var(--bg); }
.view-toggle-btn.active { background: var(--blue); color: #fff; }

.toolbar-spacer { flex: 1; }

.toolbar-count {
  font-size: 13px;
  color: var(--text-muted);
}
.toolbar-count b { color: var(--text-sub); font-weight: 600; }

/* ---- Template Grid ---- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .template-grid {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
}

/* ---- Template Card ---- */
.template-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  border: 1px solid var(--border);
}
.template-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.template-card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #e5e7eb;
}
.template-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform 0.3s;
}
.template-card:hover .template-card-thumb img {
  transform: scale(1.03);
}

/* Overlay on hover */
.template-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}
.template-card:hover .template-card-overlay {
  opacity: 1;
}

.overlay-btn {
  height: 36px;
  padding: 0 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.overlay-btn-primary {
  background: var(--blue);
  color: #fff;
}
.overlay-btn-primary:hover { background: #1d4ed8; }
.overlay-btn-secondary {
  background: rgba(255,255,255,0.9);
  color: var(--text);
}
.overlay-btn-secondary:hover { background: #fff; }

.template-card-body {
  padding: 14px 16px;
}

.template-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-category {
  background: var(--blue-bg);
  color: var(--blue);
}
.badge-library {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-dark {
  background: #1f2937;
  color: #e5e7eb;
}
.badge-light {
  background: var(--bg);
  color: var(--text-sub);
  border: 1px solid var(--border);
}

/* ---- Template List View ---- */
.template-list {
  display: none;
  flex-direction: column;
  padding: 24px;
  gap: 8px;
  max-width: 1600px;
  margin: 0 auto;
}
.template-list.active { display: flex; }
.template-grid.hidden { display: none; }

.template-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
  cursor: pointer;
}
.template-list-item:hover {
  box-shadow: var(--shadow);
}

.template-list-thumb {
  width: 120px;
  height: 75px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #e5e7eb;
}
.template-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.template-list-info { flex: 1; min-width: 0; }
.template-list-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.template-list-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.template-list-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-sm {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s;
}
.btn-sm:hover { background: var(--bg); }
.btn-sm-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-sm-primary:hover { background: #1d4ed8; }

/* ---- Preview Modal ---- */
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.8);
  display: none;
  flex-direction: column;
}
.preview-modal.active { display: flex; }

.preview-modal-bar {
  height: 48px;
  background: #1f2937;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.preview-modal-title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  flex: 1;
}
.preview-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.preview-modal-close:hover { background: rgba(255,255,255,0.2); }

.preview-device-btns {
  display: flex;
  gap: 4px;
}
.preview-device-btn {
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.preview-device-btn.active,
.preview-device-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

.preview-modal-frame {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0;
  background: #111;
  overflow: hidden;
}
.preview-modal-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  transition: max-width 0.3s;
}
.preview-modal-frame iframe.tablet { max-width: 768px; }
.preview-modal-frame iframe.mobile { max-width: 375px; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-sub); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ---- Category tabs (horizontal scroll) ---- */
.category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.12s;
}
.category-tab:hover { background: var(--bg); }
.category-tab.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
