/* Certificate layout designer (Areas/Admin/Views/CertificateForms). The page itself is drawn in mm/pt, so these rules
   only frame it; the printed certificate does not use this file. */
.cf-designer { --cf-line: #dee2e6; --cf-muted: #6c757d; --cf-accent: #2563eb; }

.cf-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.cf-topbar .cf-name { flex: 1 1 220px; min-width: 0; font-weight: 600; }
.cf-topbar .cf-paper { width: auto; flex: 0 0 auto; }
.cf-topbar .cf-orientation { width: auto; flex: 0 0 auto; }

.cf-body { display: grid; grid-template-columns: 240px minmax(0, 1fr) 290px; gap: .75rem; align-items: start; }
.cf-palette, .cf-props { background: #fff; border: 1px solid var(--cf-line); border-radius: .5rem; padding: .75rem; }
.cf-palette { position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
.cf-props { position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
.cf-section-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--cf-muted); margin-bottom: .5rem; }

.cf-field-list { display: flex; flex-direction: column; gap: 2px; }
.cf-field-btn { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; border: 1px solid transparent;
    background: transparent; border-radius: .375rem; padding: .3rem .5rem; line-height: 1.25; }
.cf-field-btn:hover, .cf-field-btn:focus-visible { background: #eef2ff; border-color: #c7d2fe; outline: none; }
.cf-field-btn span { font-size: .875rem; }
.cf-field-btn small { color: var(--cf-muted); font-size: .75rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cf-prop { margin-bottom: .6rem; }
.cf-prop > label { display: block; font-size: .8rem; color: var(--cf-muted); margin-bottom: .2rem; }
.cf-props .form-control-color { width: 2.25rem; padding: .15rem; }

.cf-stage { background: #e8ebf0; border-radius: .5rem; padding: 16px; min-height: 300px; overflow: hidden; }
.cf-page-wrap { position: relative; margin: 0 auto; }
.cf-page { position: absolute; top: 0; left: 0; transform-origin: 0 0; background: #fff; overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18); color: #000; outline: none;
    background-image: linear-gradient(to right, rgba(37, 99, 235, .06) 1px, transparent 1px), linear-gradient(to bottom, rgba(37, 99, 235, .06) 1px, transparent 1px);
    background-size: 10mm 10mm; }
.cf-page .cf-bg { position: absolute; pointer-events: none; user-select: none; }

.cf-field { position: absolute; cursor: move; border: 1px dashed transparent; user-select: none; touch-action: none; }
.cf-field:hover { border-color: rgba(37, 99, 235, .45); }
.cf-field.selected { border: 1px solid var(--cf-accent); box-shadow: 0 0 0 1px rgba(37, 99, 235, .25); z-index: 5; }
.cf-field.cf-data { background: rgba(37, 99, 235, .05); }
.cf-field img { display: block; width: 100%; height: auto; pointer-events: none; }
.cf-qr-box { display: block; width: 100%; height: 100%; pointer-events: none; }

.cf-h { position: absolute; display: none; background: var(--cf-accent); border: 1px solid #fff; }
.cf-field.selected .cf-h { display: block; }
.cf-h-w { top: 50%; right: -5px; width: 8px; height: 18px; margin-top: -9px; border-radius: 3px; cursor: ew-resize; }
.cf-h-size { right: -5px; bottom: -5px; width: 10px; height: 10px; border-radius: 2px; cursor: nwse-resize; }

/* Snap guides while dragging, and "view as printed" (no grid, no frames). */
.cf-guide { position: absolute; z-index: 10; pointer-events: none; background: #f97316; }
.cf-guide-v { top: 0; bottom: 0; width: 1px; }
.cf-guide-h { left: 0; right: 0; height: 1px; }
.cf-page.cf-preview { background-image: none; }
.cf-page.cf-preview .cf-field { border-color: transparent !important; background: transparent !important; box-shadow: none !important; cursor: default; }
.cf-page.cf-preview .cf-h { display: none !important; }
#cf-preview.active { background: #0f172a; border-color: #0f172a; color: #fff; }

.cf-prop-row { display: flex; gap: .5rem; }
.cf-prop-row > .cf-prop { flex: 1 1 0; min-width: 0; }
.cf-sep { width: 1px; background: var(--cf-line); margin: 0 .15rem; }
.cf-more { border-top: 1px solid var(--cf-line); padding-top: .5rem; margin-top: .25rem; }
.cf-more > summary { cursor: pointer; font-size: .85rem; color: var(--cf-muted); margin-bottom: .5rem; }
.cf-empty { text-align: center; color: var(--cf-muted); padding: 1.5rem .5rem; font-size: .875rem; }
.cf-empty i { display: block; font-size: 1.75rem; margin-bottom: .5rem; opacity: .6; }
.cf-help { border-top: 1px solid var(--cf-line); padding-top: .5rem; }

/* Template gallery (Index). */
.cf-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.cf-card { display: flex; flex-direction: column; border: 1px solid #dee2e6; border-radius: .6rem; background: #fff; overflow: hidden;
    transition: box-shadow .15s, border-color .15s; }
.cf-card:hover { border-color: #93c5fd; box-shadow: 0 4px 16px rgba(15, 23, 42, .08); }
.cf-thumb { display: flex; align-items: center; justify-content: center; width: 100%; height: 200px; padding: 12px;
    background: #eef1f5; border: 0; border-bottom: 1px solid #e5e7eb; cursor: pointer; text-decoration: none; overflow: hidden; }
.cf-thumb .cf-page-wrap { flex: 0 0 auto; }
.cf-thumb .cf-page { box-shadow: 0 1px 6px rgba(0, 0, 0, .15); pointer-events: none; }
.cf-thumb-blank span { display: flex; align-items: center; justify-content: center; height: 100%; aspect-ratio: 297 / 210; background: #fff;
    border: 2px dashed #cbd5e1; border-radius: 4px; color: #94a3b8; font-size: 2rem; }
.cf-card-body { padding: .75rem .9rem .9rem; display: flex; flex-direction: column; flex: 1 1 auto; }
.cf-card-body > .btn { align-self: flex-start; margin-top: auto !important; }
.cf-card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-card-meta { font-size: .8rem; color: #6c757d; margin-bottom: .25rem; }

@media (max-width: 1199.98px) {
    .cf-body { grid-template-columns: 220px minmax(0, 1fr); }
    .cf-props { grid-column: 1 / -1; position: static; max-height: none; }
}
.cf-more-fields > summary { cursor: pointer; font-size: .85rem; color: var(--cf-accent); padding: .3rem .5rem; }
.cf-more-fields[open] > summary { margin-bottom: 2px; }

@media (max-width: 767.98px) {
    .cf-body { grid-template-columns: minmax(0, 1fr); }
    .cf-stage { order: -1; }
    .cf-palette { position: static; max-height: none; }
    .cf-stage { padding: 8px; }
}
