@use "../globals" as *;

/* ====== SHELL LAYOUT ====== */

.adminShell {
    display: grid;
    grid-template-columns: repeat(3, minmax(250px, 1fr));
    gap: 1.5em;
    height: calc(100vh - 80px); // fits nicely inside WP admin
    padding: 1em 0;
    box-sizing: border-box;

    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #111827;
    height: 77vh;
    overflow-x: auto;
}

.adminHeader {
    display: flex;
    flex-wrap: wrap;
    /* allow items to wrap to next line */
    gap: 10px;
    align-items: center;
    gap: 15px;

    h1 {
        padding: 0px;
    }

    button {
        @extend button;
    }
}

.adminHeaderTop {
    display: flex;
    align-items: center;
    gap: 12px;
}

.adminHeaderActions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.emailSearchBar {
    display: flex;
    gap: 8px;
}

.searchInputWrap {
    position: relative;

    input {
        padding-right: 32px; // space for X
    }
}

.searchClear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    line-height: 22px;
    padding: 0px !important;
    font-size: 18px !important;
}


.errorText {
    font-size: 0.85em;
    color: var(--error);
}

/* ====== SIDEBAR (LEFT) ====== */

.sidebar {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-bg);
    overflow: hidden;
    position: relative;
}

.sidebarHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75em 0.9em;
    border-bottom: 1px solid var(--border-subtle);
    background: #ffffff;

}

.emailGroupList,
.detailsBody {
    flex: 1;
    overflow-y: auto;
    padding: 0.5em 0.75em 0.75em;
    display: flex;
    flex-direction: column;
    gap: 0.75em;
    position: relative;
}

/* Vertical loader bar */
.sideLoader {
    position: absolute;
    top: 0;
    right: 0;
    /* stick it to the right side of the sidebar */
    width: 10px;
    height: 100%;
    background-color: #ffffff;

    /* dashed effect using background, not border */
    background-image: repeating-linear-gradient(to bottom,
            #f9fafb 0 6px,
            /* dash color + length */
            transparent 6px 12px
            /* gap */
        );

    animation: dashMove 0.5s linear infinite;
}

@keyframes dashMove {
    0% {
        background-position-y: 0;
    }

    100% {
        background-position-y: 12px;
        /* same as dash+gap length */
    }
}

.emailGroup {
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid var(--accent-light);
    padding: 0.45em 0.55em 0.55em;
}

.emailHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3em;
}

.emailTitle {
    font-size: 0.85em;
    font-weight: 600;
    padding-bottom: 5px;
    color: var(--text-dark);
    word-break: break-all;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.emailMeta {
    font-size: 0.75em;
    color: var(--text-secondary);
}

.emailConversations {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    max-height: 140px;
    overflow: auto;
}

.conversationItem {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 4px;
    padding: 0.35em 0.4em;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15em;
    transition: background-color 0.12s ease, box-shadow 0.12s ease;

    &:hover {
        .conversationMeta {
            color: #fff;
        }
    }
}

.conversationItemSelected {
    background: var(--accent) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);

    .conversationMeta {
        color: var(--accent-light-2);
    }
}

.conversationTopRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1em;
    font-weight: 500;
}

.conversationMeta {
    font-size: 0.8em;
    color: var(--surface-bg);
}

/* status badges */

.statusBadge {
    font-size: 0.8em;
    border-radius: 999px;
    padding: 5px 10px;
    margin-top: 5px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.badgePending {
    background: #fff8e1;
    color: #9e7c20;
}

.badgeApproved {
    background: #e8f5e9;
    color: #2e7d32;
}

.badgeClosed {
    background: #e5e7eb;
    color: #4b5563;
}

/* ====== MAIN PANEL (MIDDLE) ====== */

.mainPanel {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    overflow: hidden;
    min-width: 0; // allow MessageList to shrink
    position: relative;
}

.mainHeader {
    padding: 0.75em 0.9em;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    min-width: 0;
    position: relative;

    h2 {
        margin: 0;
        font-size: 1em;
        font-weight: 600;
        white-space: normal;
        overflow-wrap: break-word;
    }

    .selectedMeta {
        margin-top: 5px;

        h2 {
            display: flex;
            flex-direction: column;
            margin-bottom: 5px;

            span {
                font-size: 0.75em;
                color: #6b7280;
                font-weight: normal;
            }
        }

        div {
            display: inline-block;
        }
    }

    .refreshing {
        position: absolute;
        right: 15px;
        bottom: 10px;
        font-size: 0.8em;
    }
}

.approveBtn {
    font-size: 0.8em;
    border-radius: 999px;
    padding: 0.35em 0.9em;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease,
        box-shadow 0.12s ease;

    &:hover:not(:disabled) {
        background: #005fcc;
        border-color: #005fcc;
    }

    &:disabled {
        opacity: 0.6;
        cursor: default;
    }
}

.messagesPane {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0em 0.75em 1em 1em;
    overflow: hidden;
    position: relative;

    // let MessageList scroll if it gets tall
    >*:first-child {
        flex: 1;
        overflow-y: auto;
        margin-bottom: 0.5em;
    }
}

.messagesScroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4em; // space between messages
    padding-right: 15px;
}

/* ====== RIGHT PANEL (DETAILS) ====== */

.sidePanel {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    overflow: hidden;

    h3 {
        margin-top: 0;
        margin-bottom: 0.5em;
        font-size: 0.95em;
        font-weight: 600;
    }
}

.detailsList {
    margin: 0;
    font-size: 14px;

    li+li {
        margin-top: 6px;
    }
}

/* ====== GENERIC TEXT STYLES ====== */

.hLoader {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: #e5e7eb;
}

.hLoader::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #48c8b9, #ef7008, #41db2d);
    animation: hLoaderSlide 0.9s linear infinite;
}

@keyframes hLoaderSlide {
    from {
        left: -30%;
    }

    to {
        left: 100%;
    }
}

.typingComponent {
    display: flex;
    flex: 0 0 auto;
    /* Stay at the bottom, don't expand */
    height: 5px;
    justify-content: right;
}

