/**
 * QualityShift — Simplified Document Template Preview Portal Styles
 * Clean, modern layout focused purely on template browsing and previewing.
 */

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --bg-page: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --shadow-card: 0 2px 8px -2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 12px 24px -4px rgba(15, 23, 42, 0.1), 0 4px 8px -2px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Simple Clean Header — Just the name and count */
.simple-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.header-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.header-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #bae6fd;
}

/* Main Container */
.main-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 24px 48px 24px;
  width: 100%;
  flex: 1;
}

/* Search & Filters Bar */
.search-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  background: #ffffff;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 14px;
}

.search-wrap input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s ease;
}

.search-wrap input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.category-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cat-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: #475569;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pill:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.cat-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.sort-wrap {
  display: flex;
  align-items: center;
}

.sort-dropdown {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  cursor: pointer;
}

/* Template Cards Grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 22px;
}

.template-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

/* Card Visual Thumbnail Header */
.card-header-visual {
  height: 120px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.card-visual-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-category {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cat-mr { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.cat-qa { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.cat-hr { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.cat-social { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

.badge-format {
  font-size: 10.5px;
  font-weight: 700;
  background: #0f172a;
  color: #f8fafc;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-doc-code {
  font-family: monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  background: rgba(255, 255, 255, 0.9);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
}

/* Card Body */
.card-body {
  padding: 16px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 4px;
}

.card-company {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 12px;
}

.card-details-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.card-detail-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-detail-row strong {
  color: var(--text-main);
}

.card-notes {
  font-size: 11.5px;
  color: #475569;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  margin-top: auto;
  line-height: 1.4;
}

/* Card Footer Actions */
.card-footer {
  padding: 12px 18px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-open-preview {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  flex: 1;
  justify-content: center;
}

.btn-open-preview:hover {
  background: var(--primary-hover);
}

.btn-standalone {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-standalone:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

/* Dedicated Preview Modal — Pure Document View */
.preview-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.preview-modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #0f172a;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  width: 96vw;
  max-width: 1440px;
  height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #334155;
}

.modal-header-toolbar {
  padding: 12px 18px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  color: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-doc-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.modal-meta-tag {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.modal-actions-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-tool-btn {
  background: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.modal-tool-btn:hover {
  background: #475569;
}

.modal-tool-btn.btn-print {
  background: var(--primary);
  border-color: var(--primary);
}

.modal-tool-btn.btn-print:hover {
  background: var(--primary-hover);
}

.modal-tool-btn.btn-close-modal {
  background: #dc2626;
  border-color: #ef4444;
}

.modal-tool-btn.btn-close-modal:hover {
  background: #b91c1c;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: #475569;
  margin: 0 4px;
}

.zoom-text {
  font-size: 11.5px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
  color: #94a3b8;
}

/* Modal Viewport (Document Only) */
.modal-viewport {
  flex: 1;
  background: #cbd5e1;
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 18px;
}

.doc-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  transition: transform 0.2s ease;
  transform-origin: top center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  grid-column: 1 / -1;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px dashed #cbd5e1;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Simple Footer */
.simple-footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .simple-header {
    padding: 12px 16px;
  }
  .main-container {
    padding: 16px 16px 36px 16px;
  }
  .search-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .templates-grid {
    grid-template-columns: 1fr;
  }
  .modal-actions-area {
    width: 100%;
    justify-content: flex-end;
  }
}
