/* ============================================
   CHAT DETAIL V3.1 — UNIFIED WINDOW & MODAL
   ============================================ */

:root {
    --chat-border: #e2e8f0;
    --chat-bg-main: #ffffff;
    --chat-bg-subtle: #f8fafc;
    --chat-text-main: #0f172a;
    --chat-text-muted: #64748b;
}

.chat-v3-root {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 61px); /* Occupy full height minus top bar */
    background: var(--pd-surface);
    margin: -1.5rem -2rem; /* Negate parent dashboard-content padding */
    width: calc(100% + 4rem);
    border: none;
    border-radius: 0;
    overflow: hidden;
}

/* Unified Sections */
.chat-v3-header {
    padding: 0.75rem 2rem 1rem;
    border-bottom: 1px solid var(--pd-border);
    background: #fff;
    flex-shrink: 0;
}

.v3-inner-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--pd-text-subtle);
    margin-bottom: 0.5rem;
}

.v3-inner-breadcrumb a {
    color: var(--pd-text-subtle);
    text-decoration: none;
    transition: color 0.2s;
}

.v3-inner-breadcrumb a:hover {
    color: var(--pd-primary);
}

.v3-inner-breadcrumb i {
    font-size: 0.6rem;
    opacity: 0.5;
}

.chat-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.chat-v3-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--pd-text);
}

.chat-header-actions {
    display: flex;
    gap: 0.75rem;
}

.chat-header-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.chat-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--pd-text-muted);
}

/* Scrollable Body */
.chat-v3-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Footer Section */
.chat-v3-footer {
    padding: 1rem 1.5rem;
    background: var(--pd-bg-subtle);
    border-top: 1px solid var(--pd-border);
    flex-shrink: 0;
}

.v3-templates-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    margin-bottom: 0.25rem;
}

.v3-template-chip {
    white-space: nowrap;
    padding: 0.35rem 0.875rem;
    background: #fff;
    border: 1px solid var(--pd-border);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pd-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.v3-template-chip:hover {
    border-color: var(--pd-primary);
    color: var(--pd-primary);
}

.chat-v3-input-box {
    background: #fff;
    border: 1px solid var(--pd-border);
    border-radius: 24px; /* More rounded like WA */
    padding: 0.4rem 0.5rem 0.4rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chat-v3-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    color: var(--pd-text);
}

.v3-send-btn {
    background: var(--pd-primary);
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%; /* Circle */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.v3-send-btn:hover {
    background: var(--pd-primary-dark);
    transform: scale(1.05);
}

.v3-send-btn i {
    font-size: 1.1rem;
    margin-left: 2px; /* Optical centering for paper plane icon */
}

/* Message Bubbles */
.v3-msg-item {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}
.v3-msg-visitor { align-self: flex-start; }
.v3-msg-staff { align-self: flex-end; }
.v3-msg-system { align-self: flex-end; text-align: left; max-width: 85%; }


.v3-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
}
.v3-msg-visitor .v3-msg-bubble { background: var(--pd-primary); color: #fff; border-bottom-left-radius: 2px; }
.v3-msg-staff .v3-msg-bubble { background: #f1f5f9; color: var(--pd-text); border: 1px solid var(--pd-border); border-bottom-right-radius: 2px; }
.v3-msg-system .v3-msg-bubble { background: #fefce8; color: #854d0e; font-size: 0.8125rem; padding: 0.75rem 1rem; border: 1px solid #fef08a; border-radius: 12px; border-bottom-right-radius: 2px; }


.v3-msg-time { font-size: 0.65rem; color: var(--pd-text-muted); margin-top: 0.25rem; }

/* Buttons */
.v3-btn-finish { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.8125rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; }
.v3-btn-assign { background: #fff; border: 1px solid var(--pd-border); padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.8125rem; font-weight: 500; cursor: pointer; }

/* Standard Dashboard Modal (Base Style) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--pd-radius-lg);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--pd-shadow-lg);
    overflow: hidden;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--pd-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--pd-text-muted);
}

.modal-body {
    padding: 1.5rem;
    color: var(--pd-text-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    background: var(--pd-bg-subtle);
    border-top: 1px solid var(--pd-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Post-Session / AI Mode UI */
.v3-session-finished {
    background: var(--pd-bg-subtle);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.25rem;
    border-top: 1px solid var(--pd-border);
}

.v3-ai-status-banner {
    background: #f0fdfa;
    border: 1px solid #ccfbf1;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 500px;
}

.v3-ai-status-icon {
    width: 40px;
    height: 40px;
    background: #14b8a6;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.v3-ai-status-text {
    text-align: left;
}

.v3-ai-status-text h4 {
    margin: 0 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f766e;
}

.v3-ai-status-text p {
    margin: 0;
    font-size: 0.8125rem;
    color: #134e4a;
    line-height: 1.4;
}

.v3-btn-takeover {
    background: #0ea5e9;
    color: #fff;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.v3-btn-takeover:hover {
    background: #0284c7;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

.v3-btn-takeover i {
    font-size: 1.1rem;
}

/* Dropdown Alihkan (Moved down for context) */
.assign-dropdown { position: relative; }
.assign-dropdown-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: #fff; border-radius: 10px; border: 1px solid var(--pd-border); box-shadow: var(--pd-shadow-lg); width: 260px; z-index: 1000; padding: 1.25rem; }
.assign-dropdown-menu.show { display: block; }

/* Badges */
.v3-badge { padding: 0.2rem 0.625rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; }
.v3-status-pending { background: #fef3c7; color: #92400e; }
.v3-status-read { background: #dbeafe; color: #1e40af; }
.v3-status-replied { background: #ccfbf1; color: #0f766e; }
.v3-status-help { background: #fee2e2; color: #991b1b; display: inline-flex; align-items: center; gap: 0.35rem; }
