/* ── DocTemplater App Styles ────────────────────────────────────────────── */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.dt-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.dt-main {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    padding: 0 20px 20px 20px;
}

/* ── Auth pages (login, register, etc.) — cancel dt-main padding ─────── */
.dt-auth-bg {
    margin: 0 -20px -20px;
}

/* ── Template card (index page) ────────────────────────────────────────── */
.dt-template-card {
    transition: box-shadow 0.18s, transform 0.18s;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    overflow: hidden;
}

.dt-template-card:hover {
    box-shadow: 0 6px 24px rgba(13,110,253,0.13) !important;
    transform: translateY(-3px);
    border-color: #c2d4fb;
}

.dt-thumb {
    background: #f3f6fb;
    border-bottom: 1px solid #e9ecef;
    overflow: hidden;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dt-thumb-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.dt-thumb-inner svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── Card metadata date ──────────────────────────────────────────────────── */
.dt-card-date {
    font-size: 0.72rem;
    white-space: nowrap;
}

/* ── Index page header ───────────────────────────────────────────────────── */
.dt-index-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e9ecef;
}

/* ── Index page scroll ───────────────────────────────────────────────────── */
.dt-index-scroll {
    flex: 1;
    min-height: 0;      /* critical: lets flex child be constrained by parent */
    overflow-y: auto;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.dt-empty-state {
    text-align: center;
    padding: 80px 20px;
}

.dt-empty-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e8f0fe 0%, #dbeafe 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: #0d6efd;
    box-shadow: 0 4px 16px rgba(13,110,253,0.12);
}

/* ── Editor layout ─────────────────────────────────────────────────────── */
.dt-editor {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    overflow: hidden;
    flex: 1;
}

.dt-editor-topbar {
    height: 52px;
    min-height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
}

.dt-name-input {
    max-width: 280px;
    font-weight: 600;
}

.dt-editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* critical for flex children to scroll */
}

/* ── Sidebars ───────────────────────────────────────────────────────────── */
.dt-sidebar-left {
    width: 220px;
    min-width: 220px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.dt-sidebar-right {
    width: 270px;
    min-width: 270px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Field list items ───────────────────────────────────────────────────── */
.dt-field-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 2px;
    transition: background 0.1s;
}

.dt-field-item:hover {
    background: #f0f4ff;
}

.dt-field-item.active {
    background: #e7f0ff;
    border: 1px solid #b6d0ff;
}

.dt-field-del {
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
    font-size: 12px;
}

.dt-field-item:hover .dt-field-del {
    opacity: 1;
}

/* ── Sidebar section labels & collapsible ───────────────────────────────── */
.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6c757d;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 2px;
}

.sidebar-section > .sidebar-summary {
    padding: 8px 8px 0 8px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    margin-bottom: 6px;
}
.sidebar-section > .sidebar-summary::-webkit-details-marker { display: none; }
.sidebar-section > .sidebar-summary::marker { display: none; }

.sidebar-section > .sidebar-summary::after {
    content: "\f282"; /* bi-chevron-down */
    font-family: "bootstrap-icons";
    font-size: 10px;
    margin-left: auto;
    transition: transform .15s;
    color: #adb5bd;
}
.sidebar-section[open] > .sidebar-summary::after {
    transform: rotate(180deg);
}

.sidebar-section > .sidebar-summary:hover {
    color: #495057;
}

/* ── Layer list items (左 panel) ────────────────────────────────────────── */
.dt-layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 1px;
    transition: background .1s;
}

.dt-layer-item:hover {
    background: #f0f4ff;
}

.dt-layer-item.active {
    background: #e7f0ff;
    outline: 1px solid #b6d0ff;
}

.dt-layer-item:hover .dt-layer-del {
    opacity: 1 !important;
}

/* ── Canvas area ─────────────────────────────────────────────────────────── */
.dt-canvas-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.dt-canvas-wrapper {
    display: inline-block;
    flex-shrink: 0;
}

.dt-canvas-doc {
    background: white;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.dt-canvas-doc svg {
    display: block;
    pointer-events: none;
    user-select: none;
}

/* ── Drag handles ───────────────────────────────────────────────────────── */
.dt-drag-handle {
    position: absolute;
    cursor: move;
    border: 2px solid transparent;
    border-radius: 2px;
    transition: border-color 0.1s;
    box-sizing: border-box;
    z-index: 10;
}

.dt-drag-handle:hover {
    border-color: rgba(13, 110, 253, 0.4);
}

.dt-drag-handle.selected {
    border-color: #0d6efd;
    border-width: 2px;
}

/* ── Resize handle (bottom-right corner) ───────────────────────────────── */
.dt-resize-handle {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 14px;
    height: 14px;
    background: #0d6efd;
    border-radius: 2px;
    cursor: se-resize;
    z-index: 20;
}

.dt-resize-handle::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: white;
    border-radius: 1px;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */
.font-monospace {
    font-family: 'Courier New', monospace !important;
    font-size: 12px !important;
}

.form-control-color.form-control-sm {
    width: 36px;
    height: 31px;
    padding: 2px;
    cursor: pointer;
}

/* Scrollbar styling */
.dt-sidebar-left::-webkit-scrollbar,
.dt-sidebar-right::-webkit-scrollbar {
    width: 4px;
}
.dt-sidebar-left::-webkit-scrollbar-thumb,
.dt-sidebar-right::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 4px;
}

/* ── Batch fill layout ───────────────────────────────────────────────────── */
.dt-batch-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.dt-batch-data {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dt-batch-table-wrap {
    flex: 1;
    overflow: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dt-batch-table {
    white-space: nowrap;
}

.dt-batch-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8f9fa;
}

.dt-batch-preview {
    width: 380px;
    min-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Shared fields section */
.dt-shared-section {
    padding: 12px 16px;
    background: #fffdf0;
    flex-shrink: 0;
}

.dt-shared-field {
    background: #fff;
    border: 1px solid #ffd966;
    border-radius: 6px;
    padding: 8px 10px;
}

/* Pin buttons — always visible */
.dt-pin-btn,
.dt-unpin-btn {
    opacity: 0.45;
    transition: opacity 0.15s;
    line-height: 1;
    font-size: 11px;
}

th:hover .dt-pin-btn,
.dt-shared-field:hover .dt-unpin-btn {
    opacity: 1;
}

/* Compact image upload button in table cells */
.dt-img-upload-btn {
    font-size: 11px;
    line-height: 22px;
    padding: 0 6px;
}

/* ── Panel resize divider ────────────────────────────────────────────────── */
.dt-panel-divider {
    width: 6px;
    flex-shrink: 0;
    background: transparent;
    cursor: col-resize;
    position: relative;
    transition: background 0.15s;
}

.dt-panel-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: #dee2e6;
    border-radius: 2px;
    transition: background 0.15s, height 0.15s;
}

.dt-panel-divider:hover,
.dt-panel-divider:active {
    background: #e7f0ff;
}

.dt-panel-divider:hover::after,
.dt-panel-divider:active::after {
    background: #0d6efd;
    height: 60px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .dt-sidebar-left  { display: none; }
    .dt-sidebar-right { display: none; }
    .dt-canvas-area   { padding: 16px; }
    .dt-batch-preview { display: none; }
}

/* ── Blazor reconnect overlay ───────────────────────────────────────────── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 320px;
    max-width: 480px;
}

#components-reconnect-modal.components-reconnect-show {
    display: block;
    animation: dt-slide-up 0.25s ease;
}

#components-reconnect-modal.components-reconnect-failed {
    display: block;
}

#components-reconnect-modal.components-reconnect-rejected {
    display: block;
}

.dt-reconnect-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    border: 1px solid #dee2e6;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.dt-reconnect-card .dt-reconnect-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.dt-reconnect-card .dt-reconnect-icon.warning  { background: #fff3cd; color: #856404; }
.dt-reconnect-card .dt-reconnect-icon.danger    { background: #f8d7da; color: #842029; }

.dt-reconnect-card .dt-reconnect-body { flex: 1; }
.dt-reconnect-card .dt-reconnect-title { font-weight: 600; font-size: 0.9rem; margin: 0 0 2px; }
.dt-reconnect-card .dt-reconnect-sub   { font-size: 0.8rem; color: #6c757d; margin: 0; }

@keyframes dt-slide-up {
    from { opacity: 0; transform: translateX(-50%) translateY(16px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── BalanceBadge ───────────────────────────────────────────────────────── */
.balance-badge {
  display: inline-flex;
  align-items: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.875rem;
  color: #166534;
}
