@import url('fonts.css');

/* Local High-Quality Bengali Fonts (Offline & Local Ready) */
@font-face {
  font-family: 'Hind Siliguri';
  src: url('assets/fonts/HindSiliguri-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hind Siliguri';
  src: url('assets/fonts/HindSiliguri-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hind Siliguri';
  src: url('assets/fonts/HindSiliguri-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Noto Sans Bengali';
  src: url('assets/fonts/NotoSansBengali.ttf') format('truetype');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

/* Google Fonts with complete character support */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Hind+Siliguri:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=Merriweather:ital,wght@0,400;0,700;1,400&family=Noto+Sans+Bengali:wght@400;500;600;700;800&family=Noto+Serif+Bengali:wght@400;600;700&family=Playfair+Display:ital,wght@0,600;0,700;0,900;1,400&display=swap');

:root {
  --primary-accent: #1e3a8a;
  --gold-accent: #f59e0b;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Strict fix for Bengali / Indic script broken ligatures (যুক্তাক্ষর ও কারচিহ্ন) */
.font-bengali-title,
[data-field="assignmentTitle"],
.template-page,
.template-page * {
  letter-spacing: normal !important;
  font-variant-ligatures: normal !important;
  font-feature-settings: "kern" 1, "liga" 1, "clig" 1, "calt" 1 !important;
  text-rendering: optimizeLegibility !important;
}

.font-bengali-title,
[data-field="assignmentTitle"] {
  font-family: 'CoverCraftBangla', 'Hind Siliguri', 'Noto Sans Bengali', 'Nirmala UI', sans-serif !important;
  font-weight: 700 !important;
  line-height: 1.45 !important;
  word-spacing: normal !important;
  letter-spacing: normal !important;
}

.template-page h1,
.template-page h2,
.template-page h3,
.template-page p,
.template-page span {
  font-family: 'CoverCraftBangla', 'Hind Siliguri', 'Noto Sans Bengali', 'Nirmala UI', 'Inter', sans-serif;
  letter-spacing: normal !important;
  font-variant-ligatures: normal !important;
}

/* Template Card Item matching user uploaded screenshot */
.template-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem 0.75rem;
  background-color: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 1.25rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

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

.template-card.active {
  border: 2px solid #0f172a;
  background-color: #f8fafc;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

.template-card .check-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background-color: #f59e0b;
  color: #ffffff;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s ease;
}

.template-card.active .check-badge {
  opacity: 1;
  transform: scale(1);
}

.template-card .icon-container {
  width: 52px;
  height: 68px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-card .card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.125rem;
}

.template-card.active .card-title {
  color: #b45309;
}

.template-card .card-subtitle {
  font-size: 0.725rem;
  color: #64748b;
}

.template-card.active .card-subtitle {
  color: #d97706;
}

/* A4 Paper Dimensions and Container */
#a4-page-wrapper {
  width: 210mm;
  height: 297mm;
  min-height: 297mm;
  max-height: 297mm;
  background-color: #ffffff;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  transform-origin: top center;
  transition: transform 0.2s ease-out;
}

.template-page {
  width: 100%;
  height: 100%;
  max-height: 297mm;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Inline Edit Highlight */
[data-field] {
  transition: background-color 0.15s ease, outline 0.15s ease;
  border-radius: 3px;
  padding: 0 2px;
}

[data-field]:hover {
  outline: 1.5px dashed #3b82f6 !important;
  background-color: rgba(59, 130, 246, 0.08) !important;
  cursor: text;
}

[data-field]:focus {
  outline: 2px solid #2563eb !important;
  background-color: rgba(37, 99, 235, 0.12) !important;
}

/* Custom Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Print Styles for 100% Native Vector PDF & Paper Print */
@media print {
  @page {
    size: A4 portrait;
    margin: 0 !important;
  }
  
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    box-sizing: border-box !important;
  }
  
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    overflow: hidden !important;
  }
  
  /* Hide non-print UI completely */
  .no-print, header, nav, aside, #sidebar-controls, #preview-section > div:first-child, .modal, .toast, #modal-du-directory, #modal-pdf-guide {
    display: none !important;
  }
  
  main, #preview-section, #main-viewport {
    display: block !important;
    position: static !important;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }
  
  #a4-page-wrapper {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    transform: none !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    page-break-before: avoid !important;
    overflow: hidden !important;
  }

  .template-page {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  /* Bengali Typography perfection in print */
  .font-bengali-title,
  [data-field="assignmentTitle"],
  .template-page,
  .template-page * {
    letter-spacing: normal !important;
    font-variant-ligatures: normal !important;
    font-feature-settings: "kern" 1, "liga" 1, "clig" 1, "calt" 1 !important;
    text-rendering: optimizeLegibility !important;
  }

  [data-field]:hover, [data-field]:focus {
    outline: none !important;
    background-color: transparent !important;
  }
}
