/* =============================================================================
   public/css/doc-templates.css
   Document Template Themes UI & Preview Modal Styling
   ============================================================================= */

.doc-templates-wrap {
  margin-top: 14px;
  margin-bottom: 20px;
}

.doc-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.doc-template-card {
  position: relative;
  background: var(--surface2, #f8fafc);
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.doc-template-card:hover {
  border-color: var(--accent, #2a7a4f);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.08);
}

.doc-template-card.active {
  border-color: var(--border-strong, #090b09);
  background: var(--surface, #ffffff);
  box-shadow: 0 0 0 1.5px var(--border-strong, #090b09), 0 8px 20px -4px rgba(0, 0, 0, 0.12);
}

.doc-template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.doc-template-title-wrap {
  flex: 1;
  padding-right: 8px;
}

.doc-template-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-template-tagline {
  font-size: 10.5px;
  color: var(--text3, #64748b);
  margin-top: 2px;
}

.doc-template-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2.5px 8px;
  border-radius: 12px;
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.32);
  white-space: nowrap;
}

[data-theme='dark'] .doc-template-badge {
  background: rgba(252, 225, 1, 0.15);
  color: #fce101;
  border-color: rgba(252, 225, 1, 0.35);
}

.doc-template-preview-frame {
  width: 100%;
  height: 90px;
  background: #ffffff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  margin: 10px 0;
  padding: 4px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.doc-template-card:hover .doc-template-preview-frame {
  border-color: #cbd5e1;
}

.doc-template-desc {
  font-size: 11px;
  color: var(--text2, #475569);
  line-height: 1.45;
  margin-bottom: 12px;
  min-height: 48px;
}

.doc-template-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border, #e2e8f0);
  margin-top: auto;
}

.doc-template-radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #0f172a);
  cursor: pointer;
}

.doc-template-card input[type="radio"] {
  accent-color: var(--border-strong, #090b09);
  cursor: pointer;
  width: 15px;
  height: 15px;
}

.doc-template-preview-btn {
  background: none;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2, #475569);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.doc-template-preview-btn:hover {
  background: var(--surface2, #f1f5f9);
  color: var(--accent, #2a7a4f);
  border-color: var(--accent, #2a7a4f);
}

/* == Interactive Sample Preview Modal ======================================= */
#docTemplateSampleModal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-modal, 1000005) !important;
  background: var(--overlay, rgba(15, 23, 42, 0.65)) !important;
  backdrop-filter: blur(6px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(6px) saturate(140%) !important;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 20px;
}

#docTemplateSampleModal.open {
  display: flex !important;
}

.doc-template-modal-content {
  width: 95vw;
  max-width: 1100px;
  height: 90vh;
  background: var(--surface, #ffffff);
  border-radius: 12px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border, #cbd5e1);
}

.doc-template-modal-header {
  padding: 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface2, #f8fafc);
  display: flex;
  flex-direction: column;
}

.doc-template-modal-header-top {
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.doc-template-modal-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 4px;
  padding: 0 16px;
  border-top: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #ffffff);
  scroll-snap-type: inline proximity;
  scrollbar-width: none;
}

.doc-template-modal-tabs::-webkit-scrollbar {
  display: none;
}

.doc-template-tab-btn {
  flex: none;
  white-space: nowrap;
  scroll-snap-align: start;
  position: relative;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2, #64748b);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.doc-template-tab-btn:hover {
  color: var(--text, #0f172a);
  background: rgba(0, 0, 0, 0.04);
}

.doc-template-tab-btn.active,
.doc-template-tab-btn[aria-selected="true"] {
  color: var(--text, #0f172a);
}

.doc-template-tab-btn.active::after,
.doc-template-tab-btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  border-block-end: 3px solid var(--accent, #2a7a4f);
}

.doc-template-modal-body {
  flex: 1;
  background: #eee;
  overflow: hidden;
  position: relative;
  display: flex;
}

.doc-template-modal-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #eee;
}

/* == Lock Mode Enforcement for Company Profile ============================= */
.sb-section.sb-locked .doc-templates-wrap .doc-template-card {
  cursor: default;
}
.sb-section.sb-locked .doc-templates-wrap .doc-template-card:not(.active) {
  opacity: 0.72;
}
.sb-section.sb-locked .doc-templates-wrap .doc-template-card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border, #e2e8f0);
}
.sb-section.sb-locked .doc-templates-wrap .doc-template-card input[type="radio"],
.sb-section.sb-locked .doc-templates-wrap .doc-template-card .doc-template-radio-label {
  cursor: not-allowed;
}
.sb-section.sb-locked .doc-templates-wrap .doc-template-card .doc-template-preview-btn {
  cursor: pointer;
  pointer-events: auto;
}

/* == Template Personalisation Panel ======================================== */
.doc-personalize-panel {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface2, #f8fafc);
}

.doc-personalize-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 10px;
}

.doc-personalize-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text, #0f172a);
}

.doc-personalize-hint {
  font-size: 10.5px;
  color: var(--text3, #64748b);
}

.doc-personalize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  gap: 10px 12px;
}

.doc-personalize-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-personalize-field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text2, #475569);
  margin: 0;
}

.doc-personalize-field select {
  width: 100%;
  min-height: 36px;
  box-sizing: border-box;
}

.sb-section.sb-locked .doc-personalize-field select {
  opacity: 0.72;
  cursor: not-allowed;
}
