/**
 * KureBot Communication Hub - Frontend Styles
 * Version: 3.0.1
 * Enterprise-grade glassmorphism design with dark mode support.
 *
 * @package Geohubng_KureBot
 */

/* ==========================================================================
   1. CSS VARIABLES & THEME
   ========================================================================== */

:root {
    /* Primary Colors */
    --kurebot-primary: #1a56db;
    --kurebot-primary-dark: #1e40af;
    --kurebot-primary-light: #3b82f6;
    --kurebot-secondary: #0ea5e9;
    --kurebot-secondary-dark: #0284c7;
    
    /* Neutral Colors - Light Mode */
    --kurebot-bg: #ffffff;
    --kurebot-bg-secondary: #f8fafc;
    --kurebot-bg-tertiary: #f1f5f9;
    --kurebot-text: #0f172a;
    --kurebot-text-secondary: #475569;
    --kurebot-text-muted: #94a3b8;
    --kurebot-border: #e2e8f0;
    --kurebot-shadow: rgba(15, 23, 42, 0.1);
    
    /* Glassmorphism */
    --kurebot-glass-bg: rgba(255, 255, 255, 0.85);
    --kurebot-glass-border: rgba(255, 255, 255, 0.3);
    --kurebot-glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    
    /* Sizing */
    --kurebot-icon-size: 56px;
    --kurebot-border-radius: 50%;
    --kurebot-panel-radius: 20px;
    
    /* Animation */
    --kurebot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --kurebot-bg: #0f172a;
        --kurebot-bg-secondary: #1e293b;
        --kurebot-bg-tertiary: #334155;
        --kurebot-text: #f8fafc;
        --kurebot-text-secondary: #cbd5e1;
        --kurebot-text-muted: #64748b;
        --kurebot-border: #334155;
        --kurebot-shadow: rgba(0, 0, 0, 0.3);
        
        --kurebot-glass-bg: rgba(15, 23, 42, 0.85);
        --kurebot-glass-border: rgba(255, 255, 255, 0.1);
        --kurebot-glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
}

/* ==========================================================================
   2. BASE CONTAINER
   ========================================================================== */

#kurebot-root {
    position: fixed !important;
    z-index: 99999 !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

#kurebot-root *,
#kurebot-root *::before,
#kurebot-root *::after {
    box-sizing: inherit;
}

#kurebot-root.bottom-right {
    right: 24px !important;
    left: auto !important;
    bottom: 24px !important;
    top: auto !important;
}

#kurebot-root.bottom-left {
    left: 24px !important;
    right: auto !important;
    bottom: 24px !important;
    top: auto !important;
}

/* ==========================================================================
   3. FLOATING LAUNCHER
   ========================================================================== */

.kurebot-launcher {
    width: var(--kurebot-icon-size);
    height: var(--kurebot-icon-size);
    border-radius: var(--kurebot-border-radius);
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--kurebot-primary) 0%, var(--kurebot-secondary) 100%);
    color: #ffffff;
    box-shadow: 0 10px 40px rgba(26, 86, 219, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: var(--kurebot-transition);
    position: relative;
    overflow: hidden;
    padding: 0;
    line-height: 1;
}

.kurebot-launcher::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.kurebot-launcher:hover::before {
    left: 100%;
}

.kurebot-launcher:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 50px rgba(26, 86, 219, 0.5);
}

.kurebot-launcher:active {
    transform: scale(0.95);
}

.kurebot-launcher.open {
    transform: rotate(90deg);
}

/* Pulse Animation for Auto-Greeting */
@keyframes kurebot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26, 86, 219, 0.7); }
    50% { box-shadow: 0 0 0 20px rgba(26, 86, 219, 0); }
}

.kurebot-launcher.pulse {
    animation: kurebot-pulse 2s infinite;
}

/* ==========================================================================
   4. COMMUNICATION HUB PANEL
   ========================================================================== */

.kurebot-panel {
    position: absolute;
    width: 400px;
    max-width: calc(100vw - 48px);
    max-height: 75vh;
    background: var(--kurebot-glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--kurebot-glass-border);
    border-radius: var(--kurebot-panel-radius);
    box-shadow: var(--kurebot-glass-shadow);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: var(--kurebot-transition);
    display: flex;
    flex-direction: column;
}

#kurebot-root.open .kurebot-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.bottom-right .kurebot-panel {
    bottom: calc(var(--kurebot-icon-size) + 16px);
    right: 0;
}

.bottom-left .kurebot-panel {
    bottom: calc(var(--kurebot-icon-size) + 16px);
    left: 0;
}

/* ==========================================================================
   5. HEADER
   ========================================================================== */

.kurebot-header {
    background: linear-gradient(135deg, var(--kurebot-primary) 0%, var(--kurebot-secondary-dark) 100%);
    color: #ffffff;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.kurebot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.kurebot-title-group {
    flex: 1;
}

.kurebot-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.kurebot-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.kurebot-close {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--kurebot-transition);
    flex-shrink: 0;
    padding: 0;
}

.kurebot-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ==========================================================================
   6. BODY & MENU GRID
   ========================================================================== */

.kurebot-body {
    background: var(--kurebot-bg-secondary);
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.kurebot-menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.kurebot-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    background: var(--kurebot-bg);
    border: 1px solid var(--kurebot-border);
    border-radius: 16px;
    cursor: pointer;
    transition: var(--kurebot-transition);
    text-decoration: none;
    color: var(--kurebot-text);
    position: relative;
    overflow: hidden;
}

.kurebot-menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--kurebot-primary), var(--kurebot-secondary));
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 0;
}

.kurebot-menu-item:hover::before {
    opacity: 0.05;
}

.kurebot-menu-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--kurebot-shadow);
    border-color: var(--kurebot-primary-light);
}

.kurebot-menu-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    transition: transform 0.3s;
}

.kurebot-menu-item:hover .kurebot-menu-icon {
    transform: scale(1.1);
}

.kurebot-menu-label {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* Icon Backgrounds */
.kurebot-menu-icon.chat { background: linear-gradient(135deg, #1a56db, #3b82f6); color: #fff; }
.kurebot-menu-icon.whatsapp { background: linear-gradient(135deg, #25d366, #128c7e); color: #fff; }
.kurebot-menu-icon.phone { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.kurebot-menu-icon.email { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.kurebot-menu-icon.quote { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: #fff; }
.kurebot-menu-icon.maps { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.kurebot-menu-icon.geohub { background: linear-gradient(135deg, #06b6d4, #0891b2); color: #fff; }

/* ==========================================================================
   7. CHATBOT SECTION
   ========================================================================== */

.kurebot-chat-container {
    display: none;
    flex-direction: column;
    height: 55vh;
}

#kurebot-root.chat-mode .kurebot-chat-container {
    display: flex;
}

#kurebot-root.chat-mode .kurebot-menu {
    display: none;
}

.kurebot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--kurebot-bg);
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kurebot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: kurebot-message-in 0.3s ease;
}

@keyframes kurebot-message-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.kurebot-message.bot {
    background: var(--kurebot-bg);
    color: var(--kurebot-text);
    border: 1px solid var(--kurebot-border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.kurebot-message.user {
    background: linear-gradient(135deg, var(--kurebot-primary), var(--kurebot-secondary));
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.kurebot-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: var(--kurebot-bg);
    border-radius: 16px;
    align-self: flex-start;
    border: 1px solid var(--kurebot-border);
}

.kurebot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--kurebot-text-muted);
    animation: kurebot-typing 1.4s infinite;
}

.kurebot-typing span:nth-child(2) { animation-delay: 0.2s; }
.kurebot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes kurebot-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Quick Replies */
.kurebot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
}

.kurebot-quick-btn {
    background: var(--kurebot-bg);
    border: 1px solid var(--kurebot-border);
    color: var(--kurebot-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--kurebot-transition);
}

.kurebot-quick-btn:hover {
    background: var(--kurebot-primary);
    color: #ffffff;
    border-color: var(--kurebot-primary);
    transform: translateY(-2px);
}

/* Composer */
.kurebot-composer {
    display: flex;
    gap: 10px;
    background: var(--kurebot-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--kurebot-border);
}

.kurebot-input {
    flex: 1;
    border: 1px solid var(--kurebot-border);
    background: var(--kurebot-bg-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: var(--kurebot-transition);
    color: var(--kurebot-text);
}

.kurebot-input:focus {
    border-color: var(--kurebot-primary);
    background: var(--kurebot-bg);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.kurebot-send {
    border: none;
    background: linear-gradient(135deg, var(--kurebot-primary), var(--kurebot-secondary));
    color: #ffffff;
    border-radius: 12px;
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    transition: var(--kurebot-transition);
}

.kurebot-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4);
}

/* ==========================================================================
   8. AUTO GREETING OVERLAY
   ========================================================================== */

.kurebot-greeting {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    background: var(--kurebot-glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--kurebot-glass-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--kurebot-glass-shadow);
    max-width: 320px;
    animation: kurebot-greeting-in 0.4s ease;
    z-index: 10;
}

@keyframes kurebot-greeting-in {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.kurebot-greeting-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--kurebot-text);
    margin: 0 0 12px 0;
}

.kurebot-greeting-text {
    font-size: 14px;
    color: var(--kurebot-text-secondary);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.kurebot-greeting-actions {
    display: flex;
    gap: 10px;
}

.kurebot-greeting-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--kurebot-transition);
}

.kurebot-greeting-btn.primary {
    background: var(--kurebot-primary);
    color: #ffffff;
}

.kurebot-greeting-btn.primary:hover {
    background: var(--kurebot-primary-dark);
}

.kurebot-greeting-btn.secondary {
    background: var(--kurebot-bg-tertiary);
    color: var(--kurebot-text);
}

.kurebot-greeting-btn.secondary:hover {
    background: var(--kurebot-border);
}

/* ==========================================================================
   9. RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 480px) {
    #kurebot-root.bottom-right {
        right: 16px !important;
        left: auto !important;
        bottom: 16px !important;
        top: auto !important;
    }

    #kurebot-root.bottom-left {
        left: 16px !important;
        right: auto !important;
        bottom: 16px !important;
        top: auto !important;
    }
    
    .kurebot-panel {
        width: calc(100vw - 32px);
        max-height: 85vh;
    }
    
    .kurebot-menu {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .kurebot-menu-item {
        padding: 16px 12px;
    }
}

/* ==========================================================================
   10. ACCESSIBILITY & REDUCED MOTION
   ========================================================================== */

.kurebot-menu-item:focus,
.kurebot-close:focus,
.kurebot-launcher:focus,
.kurebot-send:focus,
.kurebot-quick-btn:focus,
.kurebot-input:focus {
    outline: 2px solid var(--kurebot-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Scrollbar Styling */
.kurebot-messages::-webkit-scrollbar,
.kurebot-body::-webkit-scrollbar {
    width: 6px;
}

.kurebot-messages::-webkit-scrollbar-track,
.kurebot-body::-webkit-scrollbar-track {
    background: var(--kurebot-bg-tertiary);
    border-radius: 3px;
}

.kurebot-messages::-webkit-scrollbar-thumb,
.kurebot-body::-webkit-scrollbar-thumb {
    background: var(--kurebot-text-muted);
    border-radius: 3px;
}

.kurebot-messages::-webkit-scrollbar-thumb:hover,
.kurebot-body::-webkit-scrollbar-thumb:hover {
    background: var(--kurebot-text-secondary);
}


/* ==========================================================================
   11. SVG ICON STYLING
   ========================================================================== */

.kurebot-menu-icon svg,
.kurebot-avatar svg,
.kurebot-launcher svg,
.kurebot-close svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    display: block;
}

/* WhatsApp uses a filled path instead of a stroke */
.kurebot-menu-icon.whatsapp svg {
    fill: currentColor;
    stroke: none;
    width: 26px;
    height: 26px;
}

/* Slightly larger icon for the main launcher button */
.kurebot-launcher svg {
    width: 28px;
    height: 28px;
}

/* Slightly smaller icon for the close button */
.kurebot-close svg {
    width: 18px;
    height: 18px;
}