/* ==========================================================================
   Karsh Premium Chat Module Stylesheet (WhatsApp-inspired dark/glass design)
   ========================================================================== */

:root {
    --chat-bg: #09090b;
    --chat-sidebar-bg: #121215;
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-primary: #6366f1;
    --chat-primary-hover: #4f46e5;
    --chat-primary-glow: rgba(99, 102, 241, 0.25);
    --chat-msg-sent: #1e1b4b;
    --chat-msg-received: #1e293b;
    --chat-text-main: #f8fafc;
    --chat-text-muted: #94a3b8;
    --chat-online: #22c55e;
}

.chat-app-wrapper {
    display: flex;
    height: calc(100vh - 120px);
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: var(--chat-text-main);
    font-family: 'Inter', sans-serif;
}

/* Sidebar styles */
.chat-sidebar {
    width: 320px;
    background: var(--chat-sidebar-bg);
    border-right: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-search-box {
    position: relative;
}

.chat-search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    color: white;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.3s;
}

.chat-search-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 10px var(--chat-primary-glow);
}

.chat-search-box span {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--chat-text-muted);
}

.chat-convo-list {
    flex: 1;
    overflow-y: auto;
}

.chat-convo-item {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: background 0.2s;
    gap: 0.75rem;
}

.chat-convo-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-convo-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--chat-primary);
}

.chat-avatar-wrapper {
    position: relative;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 1.1rem;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--chat-text-muted);
    border: 2px solid var(--chat-sidebar-bg);
}

.status-dot.online {
    background: var(--chat-online);
}

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

.chat-convo-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.chat-convo-name {
    font-weight: 500;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-convo-time {
    font-size: 0.75rem;
    color: var(--chat-text-muted);
}

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

.chat-unread-badge {
    background: var(--chat-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.35rem;
}

/* Chat Main Area */
.chat-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d0d11;
}

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

.chat-empty-state span {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.chat-area-header {
    height: 64px;
    padding: 0 1.25rem;
    background: var(--chat-sidebar-bg);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-name {
    font-weight: 600;
    font-size: 1rem;
}

.chat-header-status {
    font-size: 0.75rem;
    color: var(--chat-text-muted);
}

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

.chat-btn-icon {
    background: transparent;
    border: none;
    color: var(--chat-text-main);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    outline: none;
}

.chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-messages-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Bubble Styles */
.chat-msg-bubble {
    max-width: 65%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    font-size: 0.925rem;
    line-height: 1.4;
}

.chat-msg-bubble.sent {
    align-self: flex-end;
    background: var(--chat-msg-sent);
    border-top-right-radius: 2px;
}

.chat-msg-bubble.received {
    align-self: flex-start;
    background: var(--chat-msg-received);
    border-top-left-radius: 2px;
}

.chat-msg-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--chat-primary);
    margin-bottom: 0.2rem;
}

.chat-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--chat-text-muted);
    margin-top: 0.25rem;
    align-self: flex-end;
}

/* System Message */
.chat-msg-system {
    align-self: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--chat-border);
    padding: 0.35rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--chat-text-muted);
}

/* Input Area */
.chat-input-area {
    padding: 1rem;
    background: var(--chat-sidebar-bg);
    border-top: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-input-box {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    padding: 0.65rem 1.25rem;
    color: white;
    outline: none;
    font-size: 0.925rem;
    resize: none;
}

.chat-input-box::placeholder {
    color: var(--chat-text-muted);
}

.chat-btn-send {
    background: var(--chat-primary);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--chat-primary-glow);
    transition: all 0.2s;
}

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

/* File Sharing Styling */
.chat-file-bubble {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

.chat-file-icon {
    font-size: 2rem;
    color: var(--chat-primary);
}

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

.chat-file-name {
    font-weight: 500;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-file-size {
    font-size: 0.75rem;
    color: var(--chat-text-muted);
}

.chat-image-preview {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    max-height: 250px;
    object-fit: cover;
    cursor: pointer;
}

/* Call Overlay / Modal */
.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 14, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.call-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.call-video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    padding: 2rem;
    background: #020205;
}

.video-feed-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    border: 1px solid var(--chat-border);
}

.video-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* mirror */
}

.video-feed-label {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
}

.call-controls {
    height: 90px;
    background: #0c0c10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    border-top: 1px solid var(--chat-border);
}

.btn-call {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
}

.btn-call-mute { background: #374151; }
.btn-call-mute.muted { background: #ea580c; }
.btn-call-video { background: #374151; }
.btn-call-video.disabled { background: #ea580c; }
.btn-call-screen { background: #374151; }
.btn-call-screen.active { background: #10b981; }
.btn-call-end { background: #ef4444; }

.btn-call:hover {
    transform: scale(1.1);
}

/* Ringing Info overlay */
.call-ringing-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.ringing-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    animation: ring-pulse 2s infinite;
}

@keyframes ring-pulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 20px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.call-incoming-actions {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}

.btn-incoming-accept {
    background: #22c55e;
    color: white;
}

.btn-incoming-reject {
    background: #ef4444;
    color: white;
}

/* Remote control pointer / annotation */
.annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.remote-control-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(16, 185, 129, 0.85);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
