/* =========================================================
   XERION — MODALS
========================================================= */


/* =========================================================
   MODAL OVERLAY
========================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;

    background: rgba(15, 23, 42, 0.42);

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transition:
        opacity var(--transition),
        visibility var(--transition);

    z-index: 1000;
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;

    pointer-events: auto;
}


/* =========================================================
   MODAL
========================================================= */

.modal {
    position: relative;

    width: min(100%, 520px);
    max-height: min(720px, calc(100vh - 48px));

    display: flex;
    flex-direction: column;

    border: 1px solid var(--border);
    border-radius: 16px;

    background: var(--white);

    box-shadow:
        0 20px 55px rgba(15, 23, 42, 0.16),
        0 4px 14px rgba(15, 23, 42, 0.06);

    overflow: hidden;

    transform: translateY(8px) scale(0.99);

    transition:
        transform var(--transition),
        opacity var(--transition);

    opacity: 0;
}

.modal-overlay.is-open .modal {
    transform: translateY(0) scale(1);

    opacity: 1;
}


/* =========================================================
   MODAL CLOSE
========================================================= */

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;

    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid transparent;
    border-radius: 8px;

    background: transparent;
    color: var(--muted);

    font-size: 20px;
    font-weight: 400;
    line-height: 1;

    cursor: pointer;

    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition);
}

.modal-close:hover {
    border-color: var(--border);

    background: var(--surface-soft);

    color: var(--text);
}

.modal-close:active {
    background: var(--surface-hover);
}

.modal-close:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}


/* =========================================================
   MODAL BODY
========================================================= */

#modalBody {
    min-width: 0;

    max-height: inherit;

    overflow-y: auto;

    padding: 30px;
}

#modalBody::-webkit-scrollbar {
    width: 6px;
}

#modalBody::-webkit-scrollbar-thumb {
    border-radius: 999px;

    background: #d3dbe5;
}

#modalBody::-webkit-scrollbar-thumb:hover {
    background: #c1ccd9;
}


/* =========================================================
   MODAL HEADER
========================================================= */

.modal-header {
    margin-bottom: 24px;

    padding-right: 34px;
}

.modal-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    margin-bottom: 10px;

    color: var(--blue);

    font-size: 10px;
    font-weight: 700;
    line-height: 1;

    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.modal-label::before {
    content: "";

    width: 14px;
    height: 1px;

    background: var(--blue);
}

.modal-title {
    margin: 0;

    color: var(--black);

    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;

    letter-spacing: -0.03em;
}

.modal-description {
    margin: 8px 0 0;

    max-width: 430px;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.55;
}


/* =========================================================
   MODAL CONTENT
========================================================= */

.modal-content {
    min-width: 0;
}

.modal-content p {
    margin-top: 0;

    color: var(--text-soft);

    font-size: 13px;
    line-height: 1.6;
}

.modal-content p:last-child {
    margin-bottom: 0;
}


/* =========================================================
   MODAL SECTION
========================================================= */

.modal-section {
    margin-bottom: 22px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section-title {
    margin-bottom: 9px;

    color: var(--text);

    font-size: 12px;
    font-weight: 650;
    line-height: 1.4;
}

.modal-section-description {
    margin: -3px 0 12px;

    color: var(--muted);

    font-size: 11px;
    line-height: 1.5;
}


/* =========================================================
   MODAL FORM
========================================================= */

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 17px;
}

.modal-form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.modal-form-field label {
    color: var(--text-soft);

    font-size: 12px;
    font-weight: 600;
}

.modal-form-field input,
.modal-form-field select,
.modal-form-field textarea {
    width: 100%;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);

    background: var(--white);
    color: var(--text);

    outline: none;

    font-size: 13px;

    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

.modal-form-field input,
.modal-form-field select {
    height: 43px;

    padding: 0 12px;
}

.modal-form-field textarea {
    min-height: 100px;

    padding: 10px 12px;

    line-height: 1.5;

    resize: vertical;
}

.modal-form-field input::placeholder,
.modal-form-field textarea::placeholder {
    color: var(--muted-light);
}

.modal-form-field input:hover,
.modal-form-field select:hover,
.modal-form-field textarea:hover {
    border-color: #b7c3d3;
}

.modal-form-field input:focus,
.modal-form-field select:focus,
.modal-form-field textarea:focus {
    border-color: var(--blue);

    box-shadow:
        0 0 0 3px rgba(49, 88, 168, 0.08);
}


/* =========================================================
   MODAL ACTIONS
========================================================= */

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;

    margin-top: 26px;
    padding-top: 18px;

    border-top: 1px solid var(--border);
}

.modal-actions-left {
    margin-right: auto;

    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-actions .button {
    min-height: 40px;
}


/* =========================================================
   MODAL BUTTONS
========================================================= */

.modal-button {
    min-height: 40px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 14px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);

    background: var(--white);
    color: var(--text-soft);

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        transform var(--transition);
}

.modal-button:hover {
    border-color: #b7c3d3;

    background: var(--surface-soft);

    color: var(--text);

    transform: translateY(-1px);
}

.modal-button:active {
    transform: translateY(0);
}

.modal-button-primary {
    border-color: var(--blue);

    background: var(--blue);
    color: var(--white);
}

.modal-button-primary:hover {
    border-color: var(--blue-hover);

    background: var(--blue-hover);

    color: var(--white);
}

.modal-button-danger {
    border-color: #ecd4d4;

    background: var(--white);
    color: var(--danger);
}

.modal-button-danger:hover {
    border-color: #e3bcbc;

    background: var(--danger-light);

    color: var(--danger);
}


/* =========================================================
   CONFIRM MODAL
========================================================= */

.modal-confirm {
    text-align: center;
}

.modal-confirm-icon {
    width: 46px;
    height: 46px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 0 auto 16px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface-soft);
    color: var(--blue);
}

.modal-confirm-icon svg {
    width: 21px;
    height: 21px;
}

.modal-confirm-title {
    margin: 0;

    color: var(--black);

    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;

    letter-spacing: -0.025em;
}

.modal-confirm-description {
    max-width: 380px;

    margin: 8px auto 0;

    color: var(--muted);

    font-size: 12px;
    line-height: 1.55;
}

.modal-confirm .modal-actions {
    justify-content: center;
}


/* =========================================================
   MODAL LIST
========================================================= */

.modal-list {
    display: flex;
    flex-direction: column;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    overflow: hidden;
}

.modal-list-item {
    min-height: 52px;

    display: flex;
    align-items: center;
    gap: 11px;

    padding: 9px 12px;

    border-bottom: 1px solid var(--border);

    background: var(--white);

    cursor: pointer;

    transition:
        background var(--transition);
}

.modal-list-item:last-child {
    border-bottom: 0;
}

.modal-list-item:hover {
    background: var(--surface-soft);
}

.modal-list-icon {
    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 8px;

    background: var(--blue-light);
    color: var(--blue);
}

.modal-list-icon svg {
    width: 16px;
    height: 16px;
}

.modal-list-content {
    min-width: 0;
    flex: 1;
}

.modal-list-title {
    color: var(--text);

    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.modal-list-description {
    margin-top: 2px;

    color: var(--muted);

    font-size: 10px;
    line-height: 1.4;
}

.modal-list-arrow {
    color: var(--muted-light);
}

.modal-list-arrow svg {
    width: 15px;
    height: 15px;
}


/* =========================================================
   MODAL DIVIDER
========================================================= */

.modal-divider {
    width: 100%;
    height: 1px;

    margin: 20px 0;

    background: var(--border);
}


/* =========================================================
   MODAL STATUS
========================================================= */

.modal-status {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 10px 12px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface-soft);

    color: var(--text-soft);

    font-size: 11px;
    line-height: 1.45;
}

.modal-status-dot {
    width: 7px;
    height: 7px;

    flex-shrink: 0;

    border-radius: 50%;

    background: var(--muted-light);
}

.modal-status.is-success .modal-status-dot {
    background: var(--success);
}

.modal-status.is-warning .modal-status-dot {
    background: var(--warning);
}

.modal-status.is-danger .modal-status-dot {
    background: var(--danger);
}


/* =========================================================
   MODAL LOADING
========================================================= */

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 150px;

    color: var(--muted);
}

.modal-loading-spinner {
    width: 26px;
    height: 26px;

    margin-bottom: 12px;

    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;

    animation: modal-spinner 0.75s linear infinite;
}

.modal-loading-text {
    font-size: 11px;
    line-height: 1.4;
}

@keyframes modal-spinner {

    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 640px) {

    .modal-overlay {
        align-items: flex-end;

        padding: 12px;
    }

    .modal {
        width: 100%;
        max-height: calc(100vh - 24px);

        border-radius: 15px;

        transform: translateY(14px);
    }

    .modal-overlay.is-open .modal {
        transform: translateY(0);
    }

    #modalBody {
        padding: 26px 22px;
    }

    .modal-header {
        padding-right: 38px;
    }

    .modal-title {
        font-size: 20px;
    }

    .modal-actions {
        flex-wrap: wrap;
    }

    .modal-actions .button,
    .modal-actions .modal-button {
        flex: 1;
    }

    .modal-actions-left {
        width: 100%;

        margin-right: 0;
    }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 420px) {

    .modal-overlay {
        padding: 8px;
    }

    .modal {
        max-height: calc(100vh - 16px);

        border-radius: 14px;
    }

    #modalBody {
        padding: 23px 18px;
    }

    .modal-close {
        top: 10px;
        right: 10px;
    }

    .modal-title {
        font-size: 19px;
    }

    .modal-form {
        gap: 15px;
    }
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .modal-overlay,
    .modal,
    .modal-close,
    .modal-button {
        transition: none;
    }

    .modal-loading-spinner {
        animation: none;
    }
}