/* =========================================================
   Mana Message Form
   CSS matched with:
   - includes/form.php
   - assets/js/form.js
   ========================================================= */

.mana-message-wrapper {
    width: 100%;
    max-width: 850px;
    margin: 40px auto;
    padding: 0;
    direction: rtl;
    font-family: inherit;
    box-sizing: border-box;
}

.mana-message-wrapper *,
.mana-message-wrapper *::before,
.mana-message-wrapper *::after {
    box-sizing: border-box;
}


/* =========================================================
   CARD
   ========================================================= */

.mana-message-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e3e8ed;
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.07);
}


/* =========================================================
   HEADER
   ========================================================= */

.mana-message-header {
    display: flex;
    align-items: center;
    gap: 15px;

    margin-bottom: 28px;
    padding-bottom: 22px;

    border-bottom: 1px solid #edf0f3;
}

.mana-message-header-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 14px;

    background: #0b3558;
    color: #ffffff;

    font-size: 23px;
    line-height: 1;
}

.mana-message-header h2 {
    margin: 0 0 6px;

    color: #183247;

    font-size: 22px;
    font-weight: 700;
    line-height: 1.5;
}

.mana-message-header p {
    margin: 0;

    color: #6b7280;

    font-size: 14px;
    line-height: 1.7;
}


/* =========================================================
   FORM
   ========================================================= */

.mana-message-form {
    width: 100%;
    position: relative;
}


/* =========================================================
   GRID
   ========================================================= */

.mana-form-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;
}

.mana-field {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 8px;
}

.mana-field-full {
    grid-column: 1 / -1;
}


/* =========================================================
   LABEL
   ========================================================= */

.mana-field label {
    display: flex;
    align-items: center;

    gap: 4px;

    margin: 0;

    color: #263746;

    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
}

.mana-field label span {
    color: #c62828;
}


/* =========================================================
   INPUT WRAPPER
   IMPORTANT:
   This matches form.php:
   .mana-input-wrapper
   ========================================================= */

.mana-input-wrapper {
    position: relative;

    width: 100%;

    display: block;
}


/* =========================================================
   INPUTS
   ========================================================= */

.mana-field .mana-input {
    width: 100%;
    height: 48px;

    display: block;

    border: 1px solid #d9dee5;
    border-radius: 10px;

    background: #fafbfc;

    color: #263746;

    padding: 0 14px 0 52px;

    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.mana-field .mana-input::placeholder {
    color: #a5adb6;
    opacity: 1;
}

.mana-field .mana-input:focus {
    background: #ffffff;

    border-color: #0b3558;

    box-shadow:
        0 0 0 3px rgba(11, 53, 88, 0.08);
}


/* =========================================================
   MOBILE INPUT
   ========================================================= */

.mana-mobile-wrapper {
    direction: ltr;
}

.mana-field .mana-mobile-input {
    direction: ltr !important;
    text-align: left !important;

    unicode-bidi: plaintext;

    letter-spacing: 0.5px;

    padding-left: 52px;
    padding-right: 14px;
}


/* =========================================================
   NORMAL FIELD MICROPHONE
   IMPORTANT:
   Microphone remains INSIDE its own input wrapper.
   ========================================================= */

.mana-input-wrapper .mana-mic-button {
    position: absolute;

    left: 9px;
    top: 50%;

    width: 32px;
    height: 32px;

    transform: translateY(-50%);

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    border: 1px solid #d9e1e7;
    border-radius: 8px;

    background: #eef3f7;
    color: #0b3558;

    font-family:
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        sans-serif;

    font-size: 16px;
    line-height: 1;

    cursor: pointer;

    z-index: 5;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.mana-input-wrapper .mana-mic-button:hover {
    background: #dfe9f0;
    border-color: #c8d4de;
    color: #092b47;
}

.mana-input-wrapper .mana-mic-button:active {
    transform: translateY(-50%) scale(0.96);
}


/* =========================================================
   MICROPHONE RECORDING STATE
   JS:
   .mana-mic-active
   ========================================================= */

.mana-mic-button.mana-mic-active {
    background: #dc2626 !important;
    border-color: #dc2626 !important;

    color: #ffffff !important;

    animation: mana-mic-pulse 1.2s infinite;
}

.mana-input-wrapper .mana-mic-button.mana-mic-active {
    transform: translateY(-50%) scale(1.04);
}

@keyframes mana-mic-pulse {

    0% {
        box-shadow:
            0 0 0 0 rgba(220, 38, 38, 0.45);
    }

    70% {
        box-shadow:
            0 0 0 9px rgba(220, 38, 38, 0);
    }

    100% {
        box-shadow:
            0 0 0 0 rgba(220, 38, 38, 0);
    }
}


/* =========================================================
   TEXTAREA WRAPPER
   IMPORTANT:
   This matches form.php:
   .mana-textarea-wrapper
   ========================================================= */

.mana-textarea-wrapper {
    position: relative;

    width: 100%;

    display: block;
}


/* =========================================================
   TEXTAREA
   ========================================================= */

.mana-field .mana-textarea {
    width: 100%;
    min-height: 170px;

    display: block;

    resize: vertical;

    border: 1px solid #d9dee5;
    border-radius: 10px;

    background: #fafbfc;

    color: #263746;

    padding:
        13px
        14px
        58px
        14px;

    font-family: inherit;
    font-size: 14px;
    line-height: 1.9;

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.mana-field .mana-textarea::placeholder {
    color: #a5adb6;
    opacity: 1;
}

.mana-field .mana-textarea:focus {
    background: #ffffff;

    border-color: #0b3558;

    box-shadow:
        0 0 0 3px rgba(11, 53, 88, 0.08);
}


/* =========================================================
   TEXTAREA TOOLS
   Matches form.php:
   .mana-message-tools
   ========================================================= */

.mana-message-tools {
    position: absolute;

    left: 10px;
    right: 10px;
    bottom: 10px;

    height: 36px;

    display: flex;
    align-items: center;

    justify-content: flex-start;

    gap: 7px;

    z-index: 20;

    pointer-events: none;
}


/* =========================================================
   TEXTAREA TOOL BUTTON
   ========================================================= */

.mana-textarea-tool {
    width: 34px;
    height: 34px;

    flex: 0 0 34px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    border: 1px solid #dce2e8;
    border-radius: 9px;

    background: #ffffff;
    color: #536372;

    font-family: inherit;

    font-size: 17px;
    line-height: 1;

    cursor: pointer;

    pointer-events: auto;

    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04);

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.mana-textarea-tool:hover {
    background: #f2f6f9;
    color: #0b3558;
    border-color: #c8d4de;

    transform: translateY(-1px);

    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.07);
}

.mana-textarea-tool:active {
    transform: translateY(0) scale(0.96);
}


/* =========================================================
   TEXTAREA MICROPHONE
   ========================================================= */

.mana-message-tools .mana-mic-button {
    position: relative;

    width: 34px;
    height: 34px;

    flex: 0 0 34px;

    transform: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    border: 1px solid #dce2e8;
    border-radius: 9px;

    background: #ffffff;
    color: #536372;

    font-family:
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        sans-serif;

    font-size: 17px;
    line-height: 1;

    cursor: pointer;

    pointer-events: auto;

    z-index: 21;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.mana-message-tools .mana-mic-button:hover {
    background: #f2f6f9;
    color: #0b3558;
    border-color: #c8d4de;

    transform: translateY(-1px);
}


/* =========================================================
   TEXTAREA RECORDING
   ========================================================= */

.mana-message-tools .mana-mic-button.mana-mic-active {
    background: #dc2626 !important;
    border-color: #dc2626 !important;

    color: #ffffff !important;

    transform: none !important;

    animation: mana-mic-pulse 1.2s infinite;
}


/* =========================================================
   EMOJI BUTTON
   ========================================================= */

.mana-message-tools .mana-emoji-button {
    font-family:
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        sans-serif;

    font-size: 19px;
}


/* =========================================================
   EMOJI PICKER
   IMPORTANT:
   JS appends picker directly into FORM.
   Therefore anchor it to the textarea wrapper area
   using absolute positioning relative to form.

   Since JS currently appends:
       form.appendChild(picker)

   we position it relative to .mana-message-form
   and keep it inside the form.
   ========================================================= */

.mana-message-form {
    position: relative;
}


/* =========================================================
   GENERATED EMOJI PICKER
   JS:
   .mana-emoji-picker
   .mana-open
   ========================================================= */

.mana-emoji-picker {
    position: absolute;

    left: 10px;

    /*
     * This puts picker above the textarea tools.
     * The textarea occupies the lower part of the grid.
     */
    bottom: 205px;

    width: 340px;
    max-width: calc(100% - 20px);

    padding: 12px;

    background: #ffffff;

    border: 1px solid #dfe5ea;
    border-radius: 14px;

    box-shadow:
        0 15px 45px rgba(0, 0, 0, 0.16);

    direction: rtl;

    z-index: 99999;

    display: none;

    overflow: hidden;
}

.mana-emoji-picker.mana-open {
    display: block;
}


/* =========================================================
   EMOJI HEADER
   JS:
   .mana-emoji-picker-header
   ========================================================= */

.mana-emoji-picker-header {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;

    margin: 0 0 10px;
    padding: 0 0 9px;

    border-bottom: 1px solid #edf0f3;
}

.mana-emoji-picker-header strong {
    color: #263746;

    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}


/* =========================================================
   EMOJI CLOSE
   JS:
   .mana-emoji-picker-close
   ========================================================= */

.mana-emoji-picker-close {
    width: 28px;
    height: 28px;

    flex: 0 0 28px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    border: none;
    border-radius: 7px;

    background: transparent;
    color: #7a858f;

    font-family: inherit;
    font-size: 18px;
    line-height: 1;

    cursor: pointer;
}

.mana-emoji-picker-close:hover {
    background: #f2f4f6;
    color: #263746;
}


/* =========================================================
   EMOJI LIST
   JS:
   .mana-emoji-list
   ========================================================= */

.mana-emoji-list {
    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(8, minmax(0, 1fr));

    gap: 4px;

    max-height: 210px;

    padding: 3px;

    overflow-y: auto;

    direction: ltr;

    scrollbar-width: thin;
}


/* =========================================================
   EMOJI ITEM
   ========================================================= */

.mana-emoji-item {
    width: 100%;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    border: none;
    border-radius: 7px;

    background: transparent;

    color: inherit;

    font-family:
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        sans-serif;

    font-size: 22px;
    line-height: 1;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.mana-emoji-item:hover {
    background: #f1f5f8;

    transform: scale(1.12);
}

.mana-emoji-item:active {
    transform: scale(0.95);
}


/* =========================================================
   CAPTCHA
   ========================================================= */

.mana-captcha-section {
    width: 100%;

    margin-top: 24px;
}

.mana-captcha-title {
    margin-bottom: 9px;

    color: #263746;

    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
}

.mana-captcha-box {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 9px;
}

.mana-captcha-image {
    width: 125px;
    height: 48px;

    flex: 0 0 125px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid #d9dee5;
    border-radius: 9px;

    background: #f6f8fa;

    color: #263746;

    font-family:
        Arial,
        sans-serif;

    font-size: 22px;
    font-weight: 700;

    letter-spacing: 5px;

    user-select: none;
    overflow: hidden;
}

.mana-captcha-refresh {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    border: 1px solid #d9dee5;
    border-radius: 9px;

    background: #ffffff;
    color: #0b3558;

    font-family: inherit;
    font-size: 20px;
    line-height: 1;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.mana-captcha-refresh:hover {
    background: #f1f5f8;
    border-color: #c8d4de;

    transform: rotate(25deg);
}

.mana-captcha-input {
    flex: 1 1 auto;

    min-width: 0;

    width: auto !important;
}

.mana-captcha-input.mana-captcha-invalid {
    border-color: #dc2626 !important;

    background: #fff7f7 !important;

    box-shadow:
        0 0 0 3px rgba(220, 38, 38, 0.08) !important;
}

.mana-captcha-input.mana-captcha-valid {
    border-color: #16a34a !important;

    background: #f6fff8 !important;

    box-shadow:
        0 0 0 3px rgba(22, 163, 74, 0.08) !important;
}

.mana-captcha-timer {
    min-height: 20px;

    margin-top: 7px;

    color: #7a858f;

    font-size: 12px;
    line-height: 1.6;
}


/* =========================================================
   FORM FOOTER
   ========================================================= */

.mana-form-footer {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-top: 25px;
    padding-top: 22px;

    border-top: 1px solid #edf0f3;
}

.mana-form-note {
    color: #7a858f;

    font-size: 12px;
    line-height: 1.8;
}

.mana-form-note span {
    display: inline-block;

    margin-left: 4px;
}


/* =========================================================
   SUBMIT BUTTON
   ========================================================= */

.mana-submit-button {
    min-width: 155px;
    height: 48px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 12px;

    padding: 0 20px;

    border: none;
    border-radius: 10px;

    background: #0b3558;
    color: #ffffff;

    font-family: inherit;

    font-size: 14px;
    font-weight: 600;
    line-height: 1;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.mana-submit-button:hover {
    background: #092b47;

    transform: translateY(-1px);

    box-shadow:
        0 7px 18px rgba(11, 53, 88, 0.22);
}

.mana-submit-button:active {
    transform: translateY(0);
}

.mana-submit-button:disabled {
    opacity: 0.65;

    cursor: not-allowed;

    transform: none;

    box-shadow: none;
}

.mana-submit-arrow {
    font-size: 18px;
    line-height: 1;

    transition:
        transform 0.2s ease;
}

.mana-submit-button:hover .mana-submit-arrow {
    transform: translateX(-3px);
}


/* =========================================================
   SUBMIT LOADING
   ========================================================= */

.mana-submit-loading .mana-submit-arrow {
    display: none;
}

.mana-submit-loading::after {
    content: "";

    width: 17px;
    height: 17px;

    display: inline-block;

    border: 2px solid rgba(255, 255, 255, 0.35);

    border-top-color: #ffffff;

    border-radius: 50%;

    animation:
        mana-spinner 0.7s linear infinite;
}

@keyframes mana-spinner {

    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   FORM MESSAGE
   JS CLASSES:
   .mana-form-message
   .mana-message-success
   .mana-message-error
   .mana-message-warning
   .mana-message-visible
   ========================================================= */

.mana-form-message {
    display: none;

    width: 100%;

    align-items: center;

    margin-bottom: 20px;

    padding: 13px 15px;

    border-radius: 11px;

    font-size: 13px;
    line-height: 1.8;
}

.mana-form-message.mana-message-visible {
    display: flex;
}

.mana-form-message.mana-message-success {
    background: #f0fdf4;

    border: 1px solid #bbf7d0;

    color: #166534;
}

.mana-form-message.mana-message-error {
    background: #fef2f2;

    border: 1px solid #fecaca;

    color: #991b1b;
}

.mana-form-message.mana-message-warning {
    background: #fffbeb;

    border: 1px solid #fde68a;

    color: #92400e;
}


/* =========================================================
   GLOBAL TOAST
   JS:
   .mana-global-toast
   .mana-toast-success
   .mana-toast-error
   .mana-toast-warning
   .mana-toast-visible
   ========================================================= */

.mana-global-toast {
    position: fixed;

    top: 24px;
    right: 24px;

    width: min(380px, calc(100vw - 30px));

    padding: 14px 16px;

    border-radius: 12px;

    background: #ffffff;

    border: 1px solid #e1e6eb;

    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.13);

    color: #263746;

    font-size: 13px;
    line-height: 1.8;

    z-index: 999999;

    opacity: 0;

    transform: translateY(-10px);

    pointer-events: none;

    visibility: hidden;

    transition:
        opacity 0.25s ease,
        transform 0.25s ease,
        visibility 0.25s ease;
}

.mana-global-toast.mana-toast-visible {
    opacity: 1;

    transform: translateY(0);

    visibility: visible;
}

.mana-global-toast.mana-toast-success {
    border-right: 4px solid #22c55e;

    background: #f0fdf4;

    color: #166534;
}

.mana-global-toast.mana-toast-error {
    border-right: 4px solid #dc2626;

    background: #fef2f2;

    color: #991b1b;
}

.mana-global-toast.mana-toast-warning {
    border-right: 4px solid #f59e0b;

    background: #fffbeb;

    color: #92400e;
}


/* =========================================================
   FOCUS ACCESSIBILITY
   ========================================================= */

.mana-message-wrapper button:focus-visible,
.mana-message-wrapper input:focus-visible,
.mana-message-wrapper textarea:focus-visible {
    outline: 2px solid rgba(11, 53, 88, 0.35);

    outline-offset: 2px;
}


/* =========================================================
   SCROLLBAR - EMOJI
   ========================================================= */

.mana-emoji-list::-webkit-scrollbar {
    width: 6px;
}

.mana-emoji-list::-webkit-scrollbar-track {
    background: #f4f6f8;
    border-radius: 10px;
}

.mana-emoji-list::-webkit-scrollbar-thumb {
    background: #cbd3da;
    border-radius: 10px;
}

.mana-emoji-list::-webkit-scrollbar-thumb:hover {
    background: #aeb8c1;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 700px) {

    .mana-message-wrapper {
        width: 100%;

        margin: 25px auto;

        padding: 0 10px;
    }

    .mana-message-card {
        padding: 22px 18px;

        border-radius: 14px;
    }

    .mana-form-grid {
        grid-template-columns: 1fr;
    }

    .mana-field-full {
        grid-column: auto;
    }

    .mana-message-header {
        gap: 12px;

        margin-bottom: 22px;
        padding-bottom: 18px;
    }

    .mana-message-header h2 {
        font-size: 19px;
    }

    .mana-message-header p {
        font-size: 13px;
    }

    .mana-form-footer {
        flex-direction: column;

        align-items: stretch;
    }

    .mana-submit-button {
        width: 100%;
    }

    /*
     * On mobile the picker remains INSIDE the form.
     * It is not fixed to the browser window.
     */

    .mana-emoji-picker {
        left: 50%;

        width: 330px;
        max-width: calc(100% - 20px);

        transform: translateX(-50%);
    }

    .mana-emoji-list {
        grid-template-columns:
            repeat(7, minmax(0, 1fr));
    }

    .mana-captcha-box {
        display: grid;

        grid-template-columns:
            125px minmax(0, 1fr) 42px;

        align-items: center;

        gap: 8px;
    }

    .mana-captcha-image {
        width: 125px;

        flex: none;
    }

    .mana-captcha-input {
        width: 100% !important;
    }

    .mana-captcha-refresh {
        width: 42px;
    }

    .mana-global-toast {
        top: 15px;
        right: 15px;

        width: calc(100vw - 30px);
    }
}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 420px) {

    .mana-message-wrapper {
        padding: 0 7px;
    }

    .mana-message-card {
        padding: 18px 14px;
    }

    .mana-message-header {
        gap: 10px;
    }

    .mana-message-header-icon {
        width: 45px;
        height: 45px;

        min-width: 45px;

        font-size: 20px;
    }

    .mana-message-header h2 {
        font-size: 17px;
    }

    .mana-message-header p {
        font-size: 12px;
    }

    .mana-field .mana-input {
        font-size: 13px;
    }

    .mana-field .mana-textarea {
        min-height: 155px;

        padding-bottom: 58px;
    }

    .mana-emoji-picker {
        width: 290px;

        max-width: calc(100% - 10px);
    }

    .mana-emoji-list {
        grid-template-columns:
            repeat(6, minmax(0, 1fr));
    }

    .mana-emoji-item {
        font-size: 21px;
    }

    .mana-captcha-box {
        grid-template-columns:
            105px minmax(0, 1fr) 40px;

        gap: 6px;
    }

    .mana-captcha-image {
        width: 105px;
        height: 46px;
    }

    .mana-captcha-refresh {
        width: 40px;
        height: 40px;

        flex-basis: 40px;
    }
}


/* =========================================================
   VERY SMALL DEVICES
   ========================================================= */

@media (max-width: 350px) {

    .mana-message-card {
        padding: 16px 11px;
    }

    .mana-message-header h2 {
        font-size: 16px;
    }

    .mana-message-header p {
        font-size: 11px;
    }

    .mana-captcha-box {
        grid-template-columns:
            90px minmax(0, 1fr) 38px;
    }

    .mana-captcha-image {
        width: 90px;
    }

    .mana-captcha-refresh {
        width: 38px;
        height: 38px;
    }

    .mana-emoji-picker {
        width: 275px;
    }
}
