/* ========================================================================
   SLMDFormV3.css -- DFormV3Dialog layout + chrome
   Independent from SLMDForm.css (V1). Prefix: slm-dformv3-*
   ======================================================================== */

/* -- Overlay (backdrop) -- */
.slm-dformv3-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    overflow: auto;
    background: rgba(0, 0, 0, 0.18);
}

/* -- Dialog surface (popup mode) -- */
.slm-dformv3-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3001;
    width: auto;
    min-width: 480px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    min-height: 200px;

    display: flex;
    flex-direction: column;

    background: var(--slm-dialog-surface, #fafbfc);
    border: 1px solid var(--slm-dialog-border, #d1d5db);
    border-radius: var(--slm-dialog-radius, 12px);
    padding: 18px;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.12),
        0 24px 48px rgba(0, 0, 0, 0.06);

    /* Resizable: CSS resize requires overflow != visible */
    overflow: hidden;
    resize: both;
}

/* -- Embedded surface (inline mode, no overlay/fixed positioning) -- */
.slm-dformv3-surface {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;

    background: var(--slm-dialog-surface, #fafbfc);
    border: 1px solid var(--slm-dialog-border, #d1d5db);
    border-radius: var(--slm-dialog-radius, 8px);
    padding: 14px;
    overflow: hidden;
}

/* -- Header -- */
.slm-dformv3-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
}

.slm-dformv3-title {
    margin: 0;
    min-width: 0;
    flex: 1 1 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.1rem;
    font-weight: 600;
    align-self: flex-start;
    line-height: 2rem;
}

/* -- Header action buttons (Edit/Delete/Save/Close) -- */
.slm-dformv3-header-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

/* -- Body (scrollable field area) -- */
.slm-dformv3-body {
    margin-top: 12px;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.slm-dformv3-fields {
    display: flex;
    flex-flow: row wrap;
    gap: 12px;
    align-items: flex-start;
    width: 100%;
    padding: 4px 2px;
}

/* -- Footer -- */
.slm-dformv3-footer {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

.slm-dformv3-footer-hint {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    color: var(--slm-color-text-muted, #6b6f73);
}

/* -- Error display -- */
.slm-dformv3-error {
    padding: 16px;
    color: var(--slm-color-danger, #b91c1c);
    white-space: pre-wrap;
}

/* -- Loading state -- */
.slm-dformv3-loading {
    padding: 20px;
    color: var(--slm-color-text-muted, #6b6f73);
    font-style: italic;
}

/* -- Dropdowns need stacking above dialog chrome -- */
.slm-dformv3-dialog .slm-dropdown {
    z-index: 4000;
}

/* ========================================================================
   Grouped mode -- collapsible group sections
   ======================================================================== */

/* -- Group wrapper -- */
.slm-dformv3-group {
    width: 100%;
}

.slm-dformv3-group + .slm-dformv3-group {
    margin-top: 8px;
}

/* -- Group header -- */
.slm-dformv3-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--slm-color-border, #d1d5db);
    margin-bottom: 8px;
    user-select: none;
}

.slm-dformv3-group-header--collapsible {
    cursor: pointer;
}

.slm-dformv3-group-header--collapsible:hover {
    background: color-mix(in srgb, var(--slm-color-accent, #2563eb) 6%, transparent);
    border-radius: 4px;
}

.slm-dformv3-group-chevron {
    font-size: 0.85rem;
    flex: 0 0 auto;
    width: 1rem;
    text-align: center;
    color: var(--slm-color-text-muted, #6b6f73);
}

.slm-dformv3-group-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--slm-label-color, #6b6f73);
}
