/* ==========================================================================
   ProChat Live Support - Full-Screen Direct Messenger (Light Theme)
   ========================================================================== */

:root {
    --bg-app: #f1f5f9;
    --bg-chat: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --border-subtle: #edf2f7;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;
    
    --bubble-user: #2563eb;
    --bubble-user-text: #ffffff;
    --bubble-admin: #ffffff;
    --bubble-admin-text: #0f172a;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 10px -2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 30px -4px rgba(0, 0, 0, 0.08);
    
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, -apple-system, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

/* ==========================================================================
   Full-Screen Chat Wrapper (Direct Chat, Zero Header / Zero Footer)
   ========================================================================== */
.fullscreen-chat-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: var(--bg-chat);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    position: relative;
}

@media (min-width: 1024px) {
    .fullscreen-chat-app {
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
    }
}

/* Top Navigation Bar inside Messenger */
.chat-app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.profile-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.avatar-container {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.online-pulse {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background-color: var(--success);
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.profile-meta h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.verified-badge {
    color: var(--primary);
    display: inline-flex;
    vertical-align: middle;
}

.profile-meta p {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.header-action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--border-color);
    color: var(--text-main);
}

.btn-admin-link {
    text-decoration: none;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-border);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s;
}

.btn-admin-link:hover {
    background: var(--primary);
    color: white;
}

/* ==========================================================================
   Chat Messages Scroll Window
   ========================================================================== */
.chat-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: #f8fafc;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 24px 24px;
    scroll-behavior: smooth;
}

.chat-banner-info {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    max-width: 550px;
    margin: 0 auto 0.5rem;
    box-shadow: var(--shadow-sm);
}

.history-divider {
    text-align: center;
    position: relative;
    margin: 0.75rem 0;
}

.history-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.history-divider span {
    position: relative;
    background: #f8fafc;
    padding: 0 0.85rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Message Rows */
.chat-row {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    margin-bottom: 4px;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-row.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-row.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.sender-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
    padding: 0 0.35rem;
}

.message-card {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: 0.5rem 0.8rem;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
}

.chat-row.user .message-card {
    background: var(--bubble-user);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 3px;
}

.chat-row.admin .message-card {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 3px;
}

.msg-text-content {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Image Attachment in Message Bubble */
.chat-attachment-wrap {
    display: block;
    margin-bottom: 0.35rem;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    line-height: 0;
}

.chat-attachment-img {
    display: block;
    max-width: 250px;
    max-height: 200px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 12px;
    transition: transform 0.2s;
    background: rgba(0, 0, 0, 0.04);
}

.chat-attachment-wrap:hover .chat-attachment-img {
    transform: scale(1.02);
}

.time-stamp {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    margin-top: 0.25rem;
    padding: 0 0.35rem;
    color: var(--text-light);
}

.chat-row.user .time-stamp {
    justify-content: flex-end;
}

.check-tick {
    color: #60a5fa;
    font-weight: bold;
}

/* ==========================================================================
   Chat Bottom Composer Bar
   ========================================================================== */
.chat-composer-area {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

/* Pending Attachment Preview Strip */
.attachment-preview-strip {
    display: none;
    align-items: center;
    gap: 0.65rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--primary-border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
}

.attachment-preview-strip.active {
    display: flex;
}

.preview-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.preview-info {
    flex: 1;
    min-width: 0;
}

.preview-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.btn-remove-preview {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem 0.5rem;
    line-height: 1;
}

/* Quick prompt chips */
.quick-chips-row {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
}

.quick-chips-row::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.76rem;
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.chip-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-border);
}

/* Input Form */
.composer-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.5rem 0.35rem 0.75rem;
    transition: all 0.2s;
}

.composer-form:focus-within {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.composer-textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 0.4rem 0;
    color: var(--text-main);
}

.composer-textarea::placeholder {
    color: var(--text-light);
}

.btn-attach {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-attach:hover {
    background: var(--border-color);
    color: var(--primary);
}

.btn-send {
    background: var(--primary);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-send:disabled {
    background: var(--border-color);
    color: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.composer-subtext {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-light);
}

/* ==========================================================================
   Image Modal Lightbox
   ========================================================================== */
.lightbox-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.lightbox-modal.active {
    display: flex;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   Admin Panel Styles (Full Viewport)
   ========================================================================== */
.admin-wrapper {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-app);
}

.admin-sidebar {
    width: 380px;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
}

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

.admin-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-search-box {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    outline: none;
    background: var(--bg-secondary);
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    background: #ffffff;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
}

.conv-item {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    transition: background 0.15s ease;
}

.conv-item:hover {
    background: var(--bg-secondary);
}

.conv-item.active {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
}

.conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e0e7ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.conv-details {
    flex: 1;
    min-width: 0;
}

.conv-top-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.2rem;
}

.conv-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 0.72rem;
    color: var(--text-light);
    white-space: nowrap;
}

.conv-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-pill {
    background: var(--primary);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: 0.5rem;
}

.admin-wrapper {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
    background: var(--bg-app);
    position: relative;
}

.admin-main {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    overflow: hidden;
}

#activeChatArea {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.admin-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 0.75rem;
}

.admin-chat-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    gap: 0.5rem;
}

.admin-chat-header > div:first-child {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.admin-chat-header > div:first-child > div {
    min-width: 0;
    overflow: hidden;
}

#chatHeaderTitle {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta-info {
    font-size: 0.72rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-canned-bar {
    background: #ffffff;
    padding: 0.45rem 0.85rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    scrollbar-width: none;
}

.admin-canned-bar::-webkit-scrollbar {
    display: none;
}

.canned-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.74rem;
    padding: 0.28rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.canned-btn:hover {
    background: var(--border-color);
    color: var(--text-main);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .fullscreen-chat-app {
        border: none;
        max-width: 100%;
    }
    
    .chat-row {
        max-width: 82%;
    }

    .chat-attachment-img {
        max-width: 200px;
        max-height: 170px;
    }

    .admin-sidebar {
        width: 100%;
        position: absolute;
        inset: 0;
        z-index: 20;
    }

    .admin-sidebar.hide-on-mobile {
        display: none;
    }

    .admin-main {
        width: 100%;
        min-width: 0;
        max-width: 100vw;
    }

    .back-to-list-btn {
        display: inline-flex !important;
    }
}

.back-to-list-btn {
    display: none;
    margin-right: 0.5rem;
}

/* Toggle Switch Slider */
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
    background-color: var(--primary) !important;
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Per Conversation Bot Toggle Badge */
.bot-badge-on {
    background: #ecfdf5 !important;
    color: #065f46 !important;
    border: 1px solid #a7f3d0 !important;
}

.bot-badge-off {
    background: #f1f5f9 !important;
    color: #64748b !important;
    border: 1px solid #cbd5e1 !important;
}
