/* =============================================
   P7CO Messages Panel - Wolmart styling
   Integrates with existing cart-dropdown structure
   ============================================= */

/* Panel shell */
.p7co-messages-panel {
    display: block;
    min-height: auto;
    max-height: none;
    background: #fff;
}

.p7co-messages-panel.thread-open {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.p7co-messages-header {
    background: transparent;
    color: #333;
    border-bottom: 0;
    padding: 0;
    margin-bottom: 1.4rem;
    text-transform: uppercase;
    box-shadow: none;
}

.p7co-messages-header span {
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Thread list */
.p7co-messages-body {
    flex: initial;
    overflow-y: auto;
    padding: 0;
    background: #fff;
    min-height: 0;
}

.p7co-messages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 3rem;
    color: #637295;
    gap: 0.8rem;
}

.p7co-messages-loading i { font-size: 1.8rem; }

.p7co-messages-list { display: block; }

.p7co-thread-item {
    display: flex;
    align-items: center;
    padding: 2rem 0 0;
    background: transparent;
    border-bottom: 0;
    cursor: pointer;
    transition: background 0.2s;
    gap: 0;
}

.p7co-thread-item:hover {
    background: transparent;
}

.p7co-thread-icon {
    width: 8rem;
    height: 8rem;
    border-radius: 0.3rem;
    background: #f5f5f5;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.p7co-thread-icon i { font-size: 1.4rem; }

.p7co-thread-preview {
    font-size: 1.2rem;
    color: #666;
    margin-top: 0;
    margin-bottom: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.p7co-thread-time {
    font-size: 1.2rem;
    color: #999;
}

.p7co-thread-item.unread .p7co-thread-preview {
    color: #222;
    font-weight: 600;
}

/* Empty state */
.p7co-messages-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #536f61;
}

.p7co-messages-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.32;
    display: block;
}

.p7co-messages-empty p { margin-bottom: 0.3rem; font-size: 1.3rem; }

.p7co-messages-empty small { color: #739782; }

/* Thread view */
.p7co-messages-thread {
    flex: 1;
    display: none;
    flex-direction: column;
    background: linear-gradient(180deg, #f8fbf8 0%, #f1f6f2 55%, #ffffff 100%);
    position: relative;
}

.p7co-thread-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.2rem;
    background: #189578;
    color: #fff;
    gap: 0.8rem;
    box-shadow: 0 6px 18px rgba(17, 110, 70, 0.22);
}

.p7co-thread-back {
    padding: 0.7rem 1rem;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.p7co-thread-back:hover { opacity: 0.85; }

.p7co-thread-title {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p7co-thread-close-btn,
.p7co-thread-block-btn {
    font-size: 0.95rem;
    color: #fff;
    cursor: pointer;
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.24);
    transition: all 0.2s ease;
    backdrop-filter: blur(2px);
}

.p7co-thread-close-btn:hover,
.p7co-thread-block-btn:hover {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(17, 110, 70, 0.23);
}

.p7co-thread-block-btn.is-blocked {
    background: rgba(255, 87, 87, 0.2);
    color: #ffe4e4;
}

.p7co-thread-alert {
    margin: 0.5rem 1rem 0;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    background: linear-gradient(120deg, #fff1f3 0%, #ffe9ea 100%);
    color: #c24b42;
    font-size: 1.2rem;
    font-weight: 600;
    border: 1px solid #ffdada;
}

.p7co-thread-messages {
    flex: 1;
    padding: 1.2rem 1.6rem 1rem; /* Extra horizontal padding for shadow visibility */
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    color: #27372d;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Message bubbles */
.p7co-message {
    max-width: 85%;
    padding: 0.72rem 1.02rem;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 4px 10px rgba(22, 90, 55, 0.11);
    border: 1px solid rgba(28, 130, 85, 0.07);
    background: #ffffff;
}

.p7co-message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #e9fff3 0%, #d9f6e7 100%);
    border-bottom-right-radius: 4px;
    border-color: rgba(28, 130, 85, 0.18);
}

.p7co-message.received {
    align-self: flex-start;
    background: #ffffff;
    border-bottom-left-radius: 4px;
}

.p7co-message .message-text {
    font-size: 1.22rem;
    line-height: 1.45;
    color: #24372b;
    margin-bottom: 0.2rem;
}

.p7co-message .message-time {
    font-size: 0.98rem;
    color: #6c9278;
    text-align: right;
    margin-top: 0.18rem;
}

.p7co-message.sent .message-time { color: #1a8b5a; }

/* Input - Force button inside with position absolute */
.p7co-thread-input {
    padding: 0.5rem 0.6rem !important;
    background: #f5faf6 !important;
    border-top: 1px solid #e3f0e7 !important;
}

#p7co-send-message-form {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

.p7co-input-wrapper {
    position: relative !important;
    display: block !important;
    background: #fff !important;
    border-radius: 20px !important;
    padding: 0 !important;
    border: 1px solid #d0e0d5 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.p7co-input-wrapper textarea,
#p7co-message-input {
    display: block !important;
    width: 100% !important;
    border: none !important;
    outline: none !important;
    resize: none !important;
    font-size: 1.3rem !important;
    line-height: 1.4 !important;
    max-height: 60px !important;
    min-height: 36px !important;
    height: 36px !important;
    padding: 0.5rem 3rem 0.5rem 1rem !important;
    font-family: inherit !important;
    color: #24372b !important;
    background: transparent !important;
    margin: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    border-radius: 20px !important;
}

.p7co-input-wrapper textarea::placeholder { color: #809786; }

.p7co-send-btn {
    position: absolute !important;
    right: 4px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: linear-gradient(135deg, #0f7e40 0%, #149356 55%, #16a86a 100%) !important;
    border: none !important;
    color: #fff !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 6px rgba(23, 133, 92, 0.3) !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 10 !important;
}

.p7co-send-btn:hover {
    transform: translateY(-50%) scale(1.05) !important;
}

.p7co-send-btn i { 
    font-size: 1rem !important; 
    line-height: 1 !important;
}

.p7co-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(23, 133, 92, 0.3);
}

.p7co-send-btn:disabled {
    background: linear-gradient(135deg, #e9f0eb 0%, #dde8e1 100%);
    color: #8ca394;
    cursor: not-allowed;
    box-shadow: none;
}

.p7co-send-btn i { font-size: 1.15rem; }

/* Footer action */
.p7co-messages-action {
    padding-top: 1rem !important;
    border-top: 1px solid #e3f0e7;
    display: block;
    background: #fff;
}

.p7co-messages-action .btn {
    display: block;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    box-shadow: 0 8px 18px rgba(23, 133, 92, 0.2);
}

/* Thread open state */
.p7co-messages-panel.thread-open .p7co-messages-body,
.p7co-messages-panel.thread-open .p7co-messages-header,
.p7co-messages-panel.thread-open .p7co-messages-action { display: none; }

.p7co-messages-panel.thread-open .p7co-messages-thread { display: flex !important; }

/* Date separator */
.p7co-message-date { text-align: center; margin: 0.8rem 0; }

.p7co-message-date span {
    display: inline-block;
    background: rgba(23, 133, 92, 0.08);
    padding: 0.35rem 1rem;
    border-radius: 14px;
    font-size: 1.05rem;
    color: #30523f;
    text-transform: uppercase;
    font-weight: 700;
}

/* Off-canvas overrides */
#p7co-messages-dropdown.cart-offcanvas .cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 2498;
}

#p7co-messages-dropdown.cart-offcanvas .dropdown-box.p7co-messages-panel {
    position: fixed;
    top: 0;
    right: -34rem;
    max-width: 34rem;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin-top: 0;
    padding: 2.9rem 3rem;
    opacity: 1;
    visibility: visible;
    transition: right 0.3s ease;
    transform: none;
    z-index: 2499;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    display: block;
    background: #fff;
    overflow: auto;
}

#p7co-messages-dropdown.cart-offcanvas .dropdown-box.p7co-messages-panel.thread-open {
    padding: 0;
    overflow: hidden;
}

#p7co-messages-dropdown.cart-offcanvas.opened .dropdown-box.p7co-messages-panel { right: 0; }

#p7co-messages-dropdown.cart-offcanvas.opened .cart-overlay {
    opacity: 1;
    visibility: visible;
}

#p7co-messages-dropdown .p7co-messages-panel .cart-header {
    padding: 0;
    border-bottom: 0;
    background: transparent;
    min-height: 0;
}

#p7co-messages-dropdown .p7co-messages-panel .p7co-messages-body {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    background: #fff;
}

#p7co-messages-dropdown .p7co-messages-panel .p7co-messages-action {
    padding: 1.8rem 0 0;
    border-top: 0;
    background: transparent;
    min-height: 0;
}

#p7co-messages-dropdown .p7co-messages-panel .p7co-messages-empty,
#p7co-messages-dropdown .p7co-messages-panel .p7co-messages-loading {
    padding: 3rem 2rem;
    text-align: center;
}

/* Responsive */
@media (max-width: 479px) {
    #p7co-messages-dropdown.cart-offcanvas .dropdown-box.p7co-messages-panel {
        max-width: 100%;
        width: 100%;
        right: -100%;
        padding: 2.4rem 2rem;
    }

    #p7co-messages-dropdown.cart-offcanvas.opened .dropdown-box.p7co-messages-panel { right: 0; }

    #p7co-messages-dropdown .p7co-messages-panel .cart-header { padding: 0; }

    #p7co-messages-dropdown .p7co-messages-panel .p7co-messages-action { padding: 1.4rem 0 0; }

    .p7co-thread-item { padding: 1.6rem 0 0; }
}

@media (max-width: 767px) and (min-width: 480px) {
    #p7co-messages-dropdown.cart-offcanvas .dropdown-box.p7co-messages-panel {
        max-width: 32rem;
        right: -32rem;
    }
}
