/* Diálogo reutilizable estilo ventana (escritorio, admin, instalador).
   Adapta los colores al tema activo: NO se aplican colores por tipo (success/error/danger/etc.).
   El tipo solo cambia el icono semántico. La barra de título incluye el rótulo del diálogo
   y un único botón X que equivale a Cancelar/cerrar. */

.grid-app-dialog {
    padding: 0;
    border: none;
    background: transparent;
    max-width: calc(100vw - 1.5rem);
    width: min(92vw, 26rem);
    color: var(--app-dialog-text, var(--text-color, var(--text, #e8f4ff)));
}

.grid-app-dialog::backdrop {
    background: var(--app-dialog-backdrop, rgba(0, 0, 0, 0.52));
    backdrop-filter: blur(2px);
}

.grid-app-dialog-panel {
    margin: 0;
    padding: 0;
    border-radius: 14px;
    background-color: var(--app-dialog-bg, var(--control-field-bg, var(--neumorphic-bg, var(--panel, rgba(12, 22, 40, 0.94)))));
    color: inherit;
    border: 1px solid var(--app-dialog-border, var(--control-field-border, var(--border-color, var(--border, rgba(148, 163, 184, 0.22)))));
    box-shadow: var(--app-dialog-shadow, 0 18px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset);
    max-height: min(88vh, 32rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* === Barra de título (estilo ventana) === */
.grid-app-dialog-titlebar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.6rem 0.55rem 0.85rem;
    border-bottom: 1px solid var(--app-dialog-border, var(--control-field-border, var(--border-color, var(--border, rgba(148, 163, 184, 0.22)))));
    background: var(--app-dialog-titlebar-bg, color-mix(in srgb, var(--app-dialog-text, #e8f4ff) 6%, transparent));
    flex-shrink: 0;
}

.grid-app-dialog-titlebar-text {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
}

.grid-app-dialog-titlebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    color: inherit;
    opacity: 0.85;
    flex-shrink: 0;
}

.grid-app-dialog-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: inherit;
    text-align: left;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}

.grid-app-dialog-close {
    appearance: none;
    -webkit-appearance: none;
    width: var(--shell-modal-close-size, 30px);
    height: var(--shell-modal-close-size, 30px);
    min-width: var(--shell-modal-close-size, 30px);
    border-radius: var(--shell-modal-close-radius, 8px);
    border: 1px solid var(--app-dialog-btn-border, var(--control-chip-border, var(--border-color, var(--border, rgba(148, 163, 184, 0.35)))));
    background: var(--app-dialog-btn-secondary-bg, var(--control-chip-bg, transparent));
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.15s ease, filter 0.15s ease;
}

.grid-app-dialog-close:hover {
    filter: brightness(1.1);
    background: var(--control-chip-hover-bg, color-mix(in srgb, var(--app-dialog-text, #e8f4ff) 12%, transparent));
}

.grid-app-dialog-close:focus-visible {
    outline: 2px solid var(--app-dialog-focus, var(--focus-color, var(--cyan, #00f2ff)));
    outline-offset: 2px;
}

/* === Cuerpo === */
.grid-app-dialog-body {
    padding: 0.95rem 1.05rem 0.6rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
}

.grid-app-dialog-message {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: inherit;
    opacity: 0.92;
    text-align: left;
}

.grid-app-dialog-extras {
    margin-top: 1rem;
    padding-top: 0.95rem;
    border-top: 1px solid var(--app-dialog-border, color-mix(in srgb, var(--app-dialog-text, #e8f4ff) 14%, transparent));
}

.grid-app-dialog-toggle3d-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.grid-app-dialog-toggle3d {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.grid-app-dialog-toggle3d__input {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    width: 54px;
    height: 32px;
    margin: 0;
    z-index: 2;
    cursor: pointer;
}

.grid-app-dialog-toggle3d__track {
    position: relative;
    flex-shrink: 0;
    width: 54px;
    height: 32px;
    border-radius: 32px;
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--app-dialog-text, #c8d4e8) 18%, #2a3344) 0%,
        color-mix(in srgb, var(--app-dialog-text, #8899b0) 12%, #1a2230) 100%);
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.45),
        inset 0 -1px 0 rgba(255, 255, 255, 0.06),
        0 1px 0 rgba(255, 255, 255, 0.08);
    transition: background 0.28s ease, box-shadow 0.28s ease;
}

.grid-app-dialog-toggle3d__knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #ffffff 0%, #e8eef8 42%, #c5cedd 100%);
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.38),
        0 1px 2px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -2px 4px rgba(0, 0, 0, 0.08);
    transition: transform 0.32s cubic-bezier(0.34, 1.2, 0.48, 1);
}

.grid-app-dialog-toggle3d__input:checked + .grid-app-dialog-toggle3d__track {
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--app-dialog-accent-3, #00f2ff) 55%, #0ea5e9) 0%,
        color-mix(in srgb, var(--app-dialog-accent-2, #0072ff) 70%, #0369a1) 100%);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.28),
        0 0 14px color-mix(in srgb, var(--app-dialog-accent-3, #00f2ff) 35%, transparent),
        0 2px 6px rgba(0, 0, 0, 0.25);
}

.grid-app-dialog-toggle3d__input:checked + .grid-app-dialog-toggle3d__track .grid-app-dialog-toggle3d__knob {
    transform: translateX(22px);
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.32),
        0 0 0 1px rgba(255, 255, 255, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -2px 3px rgba(0, 0, 0, 0.06);
}

.grid-app-dialog-toggle3d__input:focus-visible + .grid-app-dialog-toggle3d__track {
    outline: 2px solid var(--app-dialog-focus, var(--focus-color, #00f2ff));
    outline-offset: 3px;
}

.grid-app-dialog-toggle3d__label {
    flex: 1 1 auto;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    color: inherit;
}

.grid-app-dialog-toggle3d__hint {
    margin: 0;
    padding-left: calc(54px + 0.85rem);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--app-dialog-muted, var(--text-muted, rgba(200, 220, 255, 0.72)));
}

.grid-app-dialog-field {
    margin-top: 0.85rem;
}

.grid-app-dialog-label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--app-dialog-muted, var(--text-muted, var(--text-dim, rgba(200, 220, 255, 0.65))));
    margin-bottom: 0.35rem;
}

.grid-app-dialog-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    border: 1px solid var(--app-dialog-input-border, var(--control-field-border, var(--border-color, var(--border, rgba(0, 242, 255, 0.25)))));
    background: var(--app-dialog-input-bg, var(--control-field-bg, rgba(0, 0, 0, 0.25)));
    color: inherit;
    font-size: 0.95rem;
}

.grid-app-dialog-input:focus {
    outline: 2px solid var(--app-dialog-focus, var(--focus-color, var(--cyan, #00f2ff)));
    outline-offset: 1px;
}

/* === Pie de acciones === */
.grid-app-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1.05rem 0.95rem;
    flex-shrink: 0;
}

.grid-app-dialog-btn {
    min-height: var(--shell-btn-min-h, 40px);
    padding: 0.45rem 0.95rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--app-dialog-btn-border, var(--control-chip-border, var(--border-color, var(--border, rgba(148, 163, 184, 0.35)))));
    background: var(--app-dialog-btn-secondary-bg, var(--control-chip-bg, rgba(0, 0, 0, 0.2)));
    color: inherit;
}

.grid-app-dialog-btn--primary {
    border-color: transparent;
    background: linear-gradient(
        95deg,
        var(--app-dialog-accent-1, var(--accent-violet, var(--violet, #7000ff))),
        var(--app-dialog-accent-2, var(--accent-blue, var(--blue, #0072ff))) 50%,
        var(--app-dialog-accent-3, var(--accent-cyan, var(--cyan, #00f2ff)))
    );
    color: #fff;
    box-shadow: 0 0 14px color-mix(in srgb, var(--app-dialog-accent-2, #0072ff) 28%, transparent);
}

.grid-app-dialog-btn--secondary:hover,
.grid-app-dialog-btn:hover {
    filter: brightness(1.08);
}

.grid-app-dialog-btn--secondary {
    background: var(--app-dialog-btn-secondary-bg, color-mix(in srgb, var(--app-dialog-text, #e8f4ff) 6%, transparent));
}

@media (max-width: 480px) {
    .grid-app-dialog {
        width: 94vw;
        max-width: none;
    }
    .grid-app-dialog-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .grid-app-dialog-btn {
        width: 100%;
        justify-content: center;
    }
}
