/* ==========================================================================
   CUSTOMER STYLES
   Uses CSS variables from style.css only.
   ========================================================================== */

/* ==========================================================================
   CUSTOMER DASHBOARD — Quick Links
   ========================================================================== */

.st-dash-quick-links {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

/* Messages card */
.st-dash-messages-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    text-decoration: none;
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: var(--shadow-sm);
}

.st-dash-messages-card:hover {
    border-color: var(--color-primary, #EB1F3A);
    box-shadow: 0 4px 16px rgba(235,31,58,0.12);
    text-decoration: none;
}

.st-dash-messages-card__icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: var(--radius-sm);
    background: rgba(235,31,58,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary, #EB1F3A);
}

.st-dash-messages-card__body { flex: 1; min-width: 0; }

.st-dash-messages-card__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--gray-900);
    margin-bottom: 3px;
}

.st-dash-messages-card__sub {
    font-size: 13px;
    color: var(--gray-500);
}

.st-dash-messages-card__cta {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary, #EB1F3A);
    flex-shrink: 0;
}

/* ==========================================================================
   CUSTOMER MESSAGES PAGE
   ========================================================================== */

.st-msg-page {
    padding: 40px 0 60px;
    background: var(--gray-100);
    min-height: calc(100vh - 120px);
}

.st-msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.st-msg-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

/* New Message button */
.st-msg-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-primary, #EB1F3A);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.18s ease;
}

.st-msg-new-btn:hover { opacity: 0.88; }

/* New conversation form */
.st-msg-new-form {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.st-msg-new-form[hidden] { display: none; }

.st-msg-new-form__inner {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.st-msg-new-form__title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 4px;
}

.st-msg-new-form__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.st-msg-new-form__select,
.st-msg-new-form__textarea {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--gray-900);
    outline: none;
    width: 100%;
    transition: border-color 0.15s ease;
    background: var(--white);
}

.st-msg-new-form__select:focus,
.st-msg-new-form__textarea:focus { border-color: var(--color-primary, #EB1F3A); }

.st-msg-new-form__textarea { resize: vertical; line-height: 1.55; }

.st-msg-new-form__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.st-msg-new-form__note {
    font-size: 13px;
    color: var(--color-primary, #EB1F3A);
    margin: 0;
}

/* ---- Two-panel layout ---- */
.st-msg-layout {
    display: flex;
    gap: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    min-height: 520px;
    max-height: 680px;
}

/* Left: thread list */
.st-msg-list {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    scrollbar-width: thin;
    background: var(--gray-50);
}

.st-msg-empty {
    padding: 40px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.st-msg-empty svg { opacity: 0.35; }
.st-msg-empty p { margin: 0; }
.st-msg-empty strong { color: var(--gray-600); }

.st-msg-thread-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid var(--gray-100);
    background: transparent;
    text-align: left;
    width: 100%;
    cursor: pointer;
    transition: background 0.15s ease;
}

.st-msg-thread-item:hover { background: var(--white); }

.st-msg-thread-item.is-active {
    background: rgba(235,31,58,0.05);
    border-left: 3px solid var(--color-primary, #EB1F3A);
}

.st-msg-thread-item__icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: rgba(235,31,58,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary, #EB1F3A);
}

.st-msg-thread-item__body { flex: 1; min-width: 0; }

.st-msg-thread-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.st-msg-thread-item__order {
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-msg-thread-item__time {
    font-size: 11px;
    color: var(--gray-400);
    flex-shrink: 0;
}

.st-msg-thread-item__product {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-msg-thread-item__preview {
    font-size: 12px;
    color: var(--gray-400);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-msg-sender-label {
    font-weight: 600;
    font-size: 11px;
    color: var(--gray-500);
}

/* Right: chat panel */
.st-msg-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--gray-50);
}

.st-msg-chat__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--gray-400);
    font-size: 14px;
    text-align: center;
    padding: 32px;
}

.st-msg-chat__empty svg { opacity: 0.35; }
.st-msg-chat__empty p { margin: 0; line-height: 1.6; }

.st-msg-chat__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.st-msg-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.st-msg-back-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
    display: none;
}

.st-msg-back-btn:hover { background: var(--gray-100); color: var(--gray-900); }

.st-msg-chat__header-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--gray-900);
}

.st-msg-chat__header-sub {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 1px;
}

.st-msg-chat__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
}

.st-msg-loading {
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
    padding: 24px;
}

/* Chat bubbles */
.st-msg-bubble {
    max-width: 72%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.st-msg-bubble--admin    { align-self: flex-start; }
.st-msg-bubble--customer { align-self: flex-end; }

.st-msg-bubble__text {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.st-msg-bubble--admin .st-msg-bubble__text {
    background: var(--white);
    color: var(--gray-900);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
}

.st-msg-bubble--customer .st-msg-bubble__text {
    background: var(--color-primary, #EB1F3A);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.st-msg-bubble__meta {
    font-size: 11px;
    color: var(--gray-400);
    padding: 0 4px;
}

.st-msg-bubble--customer .st-msg-bubble__meta { text-align: right; }

.st-msg-no-messages {
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
    padding: 20px;
}

/* Reply footer */
.st-msg-chat__footer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 20px;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.st-msg-input {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--gray-900);
    resize: none;
    outline: none;
    transition: border-color 0.15s ease;
    line-height: 1.5;
    background: var(--white);
}

.st-msg-input:focus { border-color: var(--color-primary, #EB1F3A); }
.st-msg-input::placeholder { color: var(--gray-400); }

/* Shared button styles for customer pages */
.st-msg-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.18s ease;
    white-space: nowrap;
}

.st-msg-btn--primary {
    background: var(--color-primary, #EB1F3A);
    color: var(--white);
}

.st-msg-btn--outline {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.st-msg-btn--primary:hover,
.st-msg-btn--outline:hover { opacity: 0.85; }

.st-msg-btn--send { flex-shrink: 0; }

/* Responsive */
@media (max-width: 768px) {
    .st-msg-layout {
        flex-direction: column;
        max-height: none;
        min-height: 0;
    }

    .st-msg-list {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
        max-height: 240px;
    }

    .st-msg-back-btn { display: flex; }

    .st-msg-chat__body { padding: 16px 14px; }
    .st-msg-chat__footer { padding: 10px 14px; }
    .st-msg-bubble { max-width: 88%; }
}

/* ---- Unread message badge ---- */
.st-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 8px;
    background: var(--color-primary, #eb1f3a);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    line-height: 1;
    vertical-align: middle;
    animation: st-badge-pop 0.2s ease;
}

@keyframes st-badge-pop {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
