/**
 * Esyasoft Unified Utility Cloud (UUC) Modal Styles
 * Based on the MDM modal / MessageBox and the Unified Utility Command dialog.
 */

body.uuc-modal-open {
    overflow: hidden !important;
}

.uuc-modal-root {
    position: fixed;
    inset: 0;
    z-index: var(--uuc-modal-z-index, 1400);
    font-family: var(--uuc-font-primary);
    color: var(--uuc-color-text-primary, #1f2937);
}

.uuc-modal-mask {
    position: absolute;
    inset: 0;
    background: var(--uuc-modal-mask-bg, rgba(10, 14, 18, 0.45));
    animation: uucModalFade 0.16s ease-out;
}

/* Positions the dialog: near the top by default, centered with Centered="true" */
.uuc-modal-wrap {
    position: absolute;
    inset: 0;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: calc(8vh + env(safe-area-inset-top, 0px)) 16px 24px;
}

.uuc-modal-wrap--centered {
    align-items: center;
    padding: 24px 16px;
}

/* Dialog */
.uuc-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 520px;
    max-width: 100%;
    max-height: calc(100vh - 48px);
    background: var(--uuc-modal-bg, #ffffff);
    border-radius: var(--uuc-modal-radius, 12px);
    box-shadow: var(--uuc-modal-shadow);
    outline: none;
    overflow: hidden;
    animation: uucModalPop 0.16s ease-out;
    box-sizing: border-box;
}

.uuc-modal *,
.uuc-modal *::before,
.uuc-modal *::after {
    box-sizing: border-box;
}

.uuc-modal-wrap:not(.uuc-modal-wrap--centered) .uuc-modal {
    max-height: calc(100vh - 8vh - 24px);
}

.uuc-modal--sm { width: 416px; }
.uuc-modal--md { width: 520px; }
.uuc-modal--lg { width: 800px; }
.uuc-modal--xl { width: min(1140px, 100%); }

.uuc-modal--fullscreen {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
}

.uuc-modal-wrap:has(.uuc-modal--fullscreen) {
    padding: 0;
}

/* Resizable from the bottom-right corner (MDM modal) */
.uuc-modal--resizable {
    resize: both;
    min-width: 320px;
    min-height: 180px;
}

.uuc-modal--dragging {
    user-select: none;
    transition: none;
}

/* Header */
.uuc-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: var(--uuc-modal-header-padding, 12px 16px);
    border-bottom: 1px solid var(--uuc-modal-border-color, #e8ebe5);
}

.uuc-modal--draggable .uuc-modal-header {
    cursor: move;
    touch-action: none;
}

.uuc-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 16px;
    font-weight: var(--uuc-font-weight-semibold, 600);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.uuc-modal-extra {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.uuc-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    margin-right: -6px;
    padding: 0;
    color: var(--uuc-color-text-secondary, #6b7280);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.uuc-modal-close:hover {
    color: var(--uuc-color-text-primary, #1f2937);
    background: rgba(0, 0, 0, 0.06);
}

.uuc-modal-close:focus-visible {
    outline: 2px solid var(--uuc-color-primary, #1677ff);
    outline-offset: 1px;
}

.uuc-modal-status-icon {
    display: inline-flex;
    flex-shrink: 0;
}

/* Status headers (MDM MessageBox colors, on the kit's tokens) */
.uuc-modal-header--info {
    background: var(--uuc-color-primary-bg, #e6f4ff);
}
.uuc-modal-header--info .uuc-modal-status-icon { color: var(--uuc-color-primary, #1677ff); }

.uuc-modal-header--success {
    background: var(--uuc-color-success-bg, #ecfdf5);
}
.uuc-modal-header--success .uuc-modal-status-icon { color: var(--uuc-color-success-active, #059669); }

.uuc-modal-header--warning {
    background: var(--uuc-color-warning-bg, #fffbeb);
}
.uuc-modal-header--warning .uuc-modal-status-icon { color: var(--uuc-color-warning-active, #d97706); }

.uuc-modal-header--error {
    background: var(--uuc-color-danger-bg, #fef2f2);
}
.uuc-modal-header--error .uuc-modal-status-icon { color: var(--uuc-color-danger-active, #dc2626); }

/* Body scrolls; header and footer stay put */
.uuc-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: var(--uuc-modal-body-padding, 16px);
    font-size: 14px;
    line-height: 1.55;
}

/* Footer */
.uuc-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    padding: var(--uuc-modal-footer-padding, 10px 16px);
    border-top: 1px solid var(--uuc-modal-border-color, #e8ebe5);
    background: var(--uuc-modal-footer-bg, #fafafa);
}

/* DialogService content */
.uuc-dialog-message {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.uuc-dialog-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--uuc-color-text-secondary, #6b7280);
}

.uuc-dialog-input {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    font: inherit;
    font-size: 14px;
    color: var(--uuc-input-color, #1f2937);
    background: #ffffff;
    border: 1px solid var(--uuc-input-border, #d9d9d9);
    border-radius: var(--uuc-input-radius-md, 6px);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.uuc-dialog-input:hover {
    border-color: var(--uuc-input-border-hover, #4096ff);
}

.uuc-dialog-input:focus {
    border-color: var(--uuc-input-border-focus, #1677ff);
    box-shadow: var(--uuc-input-focus-shadow, 0 0 0 2px rgba(22, 119, 255, 0.15));
}

textarea.uuc-dialog-input {
    resize: vertical;
}

@keyframes uucModalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes uucModalPop {
    from { opacity: 0.6; transform: scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .uuc-modal,
    .uuc-modal-mask {
        animation: none;
    }
}

/* Tablet: a little wider */
@media (max-width: 1024px) {
    .uuc-modal--lg,
    .uuc-modal--xl {
        width: 95vw;
    }
}

/* Phone: dialogs fill the screen (MDM behaviour); drag and resize are off */
@media (max-width: 768px) {
    .uuc-modal-wrap,
    .uuc-modal-wrap--centered {
        padding: 0;
        align-items: stretch;
    }

    .uuc-modal:not(.uuc-modal--sm) {
        width: 100%;
        max-height: none;
        height: 100%;
        border-radius: 0;
        resize: none;
        translate: none !important;
    }

    .uuc-modal--sm {
        align-self: center;
        width: calc(100% - 32px);
        max-width: 416px;
        translate: none !important;
    }
}
