@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

@page {
  size: A4 portrait;
  margin: 7mm 9mm;
}

@media print {
  * {
    box-sizing: border-box;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
}

.opr-sheet,
.opr-sheet * {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.opr-sheet {
  width: 100%;
  height: 283mm; /* exact printable A4 height */
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.opr-body {
  padding: 12px 18px !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
  min-height: 0;
  box-sizing: border-box;
}

/* Header */
.opr-header {
  background: var(--primary) !important;
  color: white;
  padding: 8px 14px !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px !important;
  border-radius: 6px;
  margin-bottom: 8px;
}
.opr-header-left {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.opr-header img {
  width: 46px !important;
  height: 46px !important;
  object-fit: contain;
}
.opr-header-center {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.opr-school-name {
  font-size: 15px !important;
  font-weight: 600;
  color: white;
  line-height: 1.2;
}
.opr-school-sub {
  font-size: 11px !important;
  color: rgba(255,255,255,0.75);
  line-height: 1.4;
}
.opr-school-label {
  font-size: 9px !important;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.opr-header-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  flex-shrink: 0;
}
.opr-date {
  font-size: 12px !important;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9) !important;
  white-space: nowrap;
}

/* Title and Badge */
.opr-title-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  margin-top: 6px;
}
.opr-title {
  font-size: 24px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  color: var(--ink) !important;
  margin: 0;
}
.opr-badge {
  padding: 4px 10px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 12px;
  display: inline-block;
  text-transform: uppercase;
  border: 1.5px solid;
  white-space: nowrap;
}
.opr-badge-success {
  background-color: #e6f4ea !important;
  color: #137333 !important;
  border-color: #b3e6c3 !important;
}
.opr-badge-warning {
  background-color: #fef7e0 !important;
  color: #b06000 !important;
  border-color: #fce196 !important;
}
.opr-badge-danger {
  background-color: #fce8e6 !important;
  color: #c5221f !important;
  border-color: #fbc2be !important;
}
.opr-badge-neutral {
  background-color: #f1f3f4 !important;
  color: #5f6368 !important;
  border-color: #dadce0 !important;
}

/* Summary Card */
.opr-summary-card {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--canvas-soft) !important;
  margin-bottom: 4px;
}
.opr-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opr-summary-item:last-child {
  grid-column: 1 / -1 !important;
}
.opr-summary-icon {
  font-size: 14px;
  color: var(--primary);
}
.opr-summary-details {
  display: flex;
  flex-direction: column;
}
.opr-summary-label {
  font-size: 7px !important;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.opr-summary-value {
  font-size: 11px !important;
  font-weight: 600;
  color: var(--ink);
}

/* Sections */
.opr-section {
  margin-bottom: 4px !important;
  flex-shrink: 0 !important;
}
.opr-section-head {
  font-size: 12px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.4px !important;
  padding: 3px 8px !important;
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  margin-bottom: 0;
}
.opr-section-body {
  font-size: 11px !important;
  line-height: 1.35 !important;
  padding: 3px 6px !important;
  color: var(--body) !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  white-space: pre-wrap !important;
}

.opr-dashboard-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
  margin-bottom: 4px !important;
}

/* Primary Outcome Section (Hasil & Pencapaian) */
.opr-section-hasil {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
.opr-section-body-hasil {
  font-size: 11px !important;
  line-height: 1.35 !important;
  font-weight: 400 !important;
  color: var(--body) !important;
}

/* Photos Grid */
.opr-section-photos {
  flex-grow: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  height: 0 !important;
  margin-bottom: 0 !important;
}

.opr-photos {
  display: grid !important;
  gap: 8px !important;
  padding: 4px 10px !important;
  flex-grow: 1 !important;
  min-height: 0 !important;
  height: 0 !important;
}

.opr-photos-count-1 {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}

.opr-photos-count-2 {
  grid-template-columns: repeat(2, 1fr) !important;
  grid-template-rows: 1fr !important;
}

.opr-photos-count-3 {
  grid-template-columns: repeat(2, 1fr) !important;
  grid-template-rows: 1.2fr 1.8fr !important;
}
.opr-photos-count-3 > .opr-photo-container:first-child {
  grid-column: 1 / span 2 !important;
}

.opr-photos-count-4 {
  grid-template-columns: repeat(2, 1fr) !important;
  grid-template-rows: repeat(2, 1fr) !important;
}

.opr-photos-count-5,
.opr-photos-count-6,
.opr-photos-count-7,
.opr-photos-count-8,
.opr-photos-count-9 {
  grid-template-columns: repeat(3, 1fr) !important;
  grid-auto-rows: 1fr !important;
}

.opr-photo-container {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  min-height: 0 !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.opr-photo-img {
  width: 100% !important;
  height: 0 !important;
  flex-grow: 1 !important;
  object-fit: cover !important;
  border-radius: var(--r-sm) !important;
  border: 1px solid var(--hairline-strong) !important;
}

.opr-photo-img.portrait {
  object-fit: contain !important;
  background-color: var(--surface-strong) !important;
}

.opr-photos.all-portrait .opr-photo-img {
  object-fit: cover !important;
  background-color: transparent !important;
}

.opr-photos.all-portrait.opr-photos-count-1 {
  display: flex !important;
  justify-content: center !important;
  align-items: stretch !important;
}
.opr-photos.all-portrait.opr-photos-count-1 .opr-photo-container {
  width: 55% !important;
  flex: none !important;
  min-height: 0 !important;
}

.opr-photos.all-portrait.opr-photos-count-3 {
  grid-template-columns: repeat(3, 1fr) !important;
  grid-template-rows: 1fr !important;
}
.opr-photos.all-portrait.opr-photos-count-3 > .opr-photo-container:first-child {
  grid-column: auto !important;
}

.opr-photos-count-1 .opr-photo-img,
.opr-photos-count-2 .opr-photo-img,
.opr-photos-count-3 .opr-photo-container:first-child .opr-photo-img,
.opr-photos-count-3 .opr-photo-img {
  min-height: 0 !important;
}
.opr-photo-caption {
  font-size: 9px !important;
  color: var(--muted);
  text-align: center;
  margin-top: 2px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.opr-photo-caption:empty {
  display: none !important;
}

/* Notes Space */
.opr-notes {
  margin-top: 5px !important;
}
.opr-notes-empty {
  display: none !important;
}

/* Timestamp */
.opr-timestamp {
  display: flex !important;
  justify-content: space-between !important;
  font-size: 8px !important;
  color: var(--muted) !important;
  padding: 4px 10px 0 !important;
  border-top: 1px solid var(--hairline) !important;
  margin-top: 10px !important;
}

/* Force page-break avoid rules */
.opr-sheet,
.opr-section,
.opr-summary-card,
.opr-dashboard-grid,
.opr-photos,
.opr-photo-container,
.opr-timestamp {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Hide non-print elements and strip page container styling */
body {
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}

.app-header, 
.app-footer, 
#form-wrapper, 
.opr-actions, 
header.app-header, 
footer.app-footer,
button,
.btn {
  display: none !important;
}

.app-container, 
.app-container.preview-mode {
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  background: transparent !important;
  background-color: transparent !important;
}

#preview-wrapper {
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
}

/* Ensure simulated paper boundaries match printable page */
.opr-paper.opr-sheet {
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 283mm !important;
}
}
