/* ============================================================
   Dhakane Academy Chatbot – Styles
   Floating chat widget: WhatsApp-inspired, dark/light mode
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --cb-accent:        #4f46e5;       /* Indigo primary */
    --cb-accent-dark:   #3730a3;
    --cb-accent-light:  #818cf8;
    --cb-success:       #22c55e;
    --cb-bg:            #ffffff;
    --cb-surface:       #f8fafc;
    --cb-border:        #e2e8f0;
    --cb-text:          #1e293b;
    --cb-text-muted:    #64748b;
    --cb-bubble-user:   #4f46e5;
    --cb-bubble-bot:    #f1f5f9;
    --cb-shadow:        0 20px 60px rgba(0,0,0,.18);
    --cb-radius:        18px;
    --cb-input-bg:      #f8fafc;
    --cb-toggle-size:   60px;
}

/* Dark mode */
body.dark-mode {
    --cb-bg:          #1e1b2e;
    --cb-surface:     #2a2640;
    --cb-border:      #3d3a5c;
    --cb-text:        #e2e8f0;
    --cb-text-muted:  #94a3b8;
    --cb-bubble-bot:  #2d2a45;
    --cb-input-bg:    #252240;
}

/* ── Floating Toggle Button ───────────────────────────────── */
#chatbot-toggle {
    position:       fixed;
    bottom:         28px;
    right:          28px;
    width:          var(--cb-toggle-size);
    height:         var(--cb-toggle-size);
    border-radius:  50%;
    background:     linear-gradient(135deg, var(--cb-accent), var(--cb-accent-dark));
    color:          #fff;
    border:         none;
    cursor:         pointer;
    display:        flex;
    align-items:    center;
    justify-content:center;
    font-size:      26px;
    box-shadow:     0 8px 25px rgba(79,70,229,.5);
    z-index:        9999;
    transition:     transform .3s ease, box-shadow .3s ease;
    animation:      cb-pulse 2.5s ease-in-out infinite;
}
#chatbot-toggle:hover {
    transform:   scale(1.12);
    box-shadow:  0 12px 35px rgba(79,70,229,.7);
    animation:   none;
}
@keyframes cb-pulse {
    0%,100% { box-shadow: 0 8px 25px rgba(79,70,229,.5); }
    50%      { box-shadow: 0 8px 40px rgba(79,70,229,.85), 0 0 0 10px rgba(79,70,229,.12); }
}

/* Notification badge */
#chatbot-toggle .cb-badge {
    position:        absolute;
    top:             -4px;
    right:           -4px;
    width:           20px;
    height:          20px;
    background:      #ef4444;
    color:           #fff;
    border-radius:   50%;
    font-size:       11px;
    font-weight:     700;
    display:         flex;
    align-items:     center;
    justify-content: center;
    border:          2px solid #fff;
    display:         none;
}
#chatbot-toggle .cb-badge.show { display: flex; }

/* ── Chat Window ──────────────────────────────────────────── */
#chatbot-window {
    position:       fixed;
    bottom:         100px;
    right:          28px;
    width:          min(400px, calc(100vw - 32px));
    height:         min(580px, calc(100vh - 130px));
    background:     var(--cb-bg);
    border-radius:  var(--cb-radius);
    box-shadow:     var(--cb-shadow);
    display:        flex;
    flex-direction: column;
    z-index:        9998;
    overflow:       hidden;
    transform:      scale(.85) translateY(30px);
    opacity:        0;
    pointer-events: none;
    transition:     transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
    border:         1px solid var(--cb-border);
}
#chatbot-window.open {
    transform:      scale(1) translateY(0);
    opacity:        1;
    pointer-events: all;
}
#chatbot-window.minimized {
    height:         62px;
}

/* ── Header ───────────────────────────────────────────────── */
#cb-header {
    background:   linear-gradient(135deg, var(--cb-accent) 0%, #7c3aed 100%);
    color:        #fff;
    padding:      14px 16px;
    display:      flex;
    align-items:  center;
    gap:          12px;
    flex-shrink:  0;
    cursor:       pointer;
    user-select:  none;
}
#cb-header .cb-avatar {
    width:          42px;
    height:         42px;
    border-radius:  50%;
    background:     rgba(255,255,255,.2);
    display:        flex;
    align-items:    center;
    justify-content:center;
    font-size:      22px;
    flex-shrink:    0;
    border:         2px solid rgba(255,255,255,.4);
}
#cb-header .cb-info { flex: 1; min-width: 0; }
#cb-header .cb-name {
    font-weight:  700;
    font-size:    15px;
    line-height:  1.2;
    white-space:  nowrap;
    overflow:     hidden;
    text-overflow:ellipsis;
}
#cb-header .cb-status {
    font-size:   11px;
    opacity:     .85;
    display:     flex;
    align-items: center;
    gap:         5px;
}
#cb-header .cb-status::before {
    content:       '';
    width:         7px;
    height:        7px;
    border-radius: 50%;
    background:    #4ade80;
    display:       inline-block;
    animation:     cb-blink 1.4s ease-in-out infinite;
}
@keyframes cb-blink {
    0%,100% { opacity: 1; } 50% { opacity: .3; }
}
.cb-header-actions {
    display:  flex;
    gap:      6px;
    align-items: center;
}
.cb-header-btn {
    background:   rgba(255,255,255,.15);
    border:       none;
    color:        #fff;
    width:        30px;
    height:       30px;
    border-radius:8px;
    cursor:       pointer;
    font-size:    15px;
    display:      flex;
    align-items:  center;
    justify-content: center;
    transition:   background .2s;
}
.cb-header-btn:hover { background: rgba(255,255,255,.28); }

/* ── Messages Area ─────────────────────────────────────────── */
#cb-messages {
    flex:       1;
    overflow-y: auto;
    padding:    16px 14px 8px;
    display:    flex;
    flex-direction: column;
    gap:        10px;
    scroll-behavior: smooth;
}
#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb { background: var(--cb-border); border-radius: 10px; }

/* Welcome bar */
.cb-welcome {
    background:   linear-gradient(135deg, #f0f4ff, #e8f0ff);
    border:       1px solid #c7d4ff;
    border-radius:12px;
    padding:      12px 14px;
    text-align:   center;
    font-size:    13px;
    color:        var(--cb-text-muted);
    margin-bottom:4px;
}
body.dark-mode .cb-welcome {
    background: rgba(79,70,229,.15);
    border-color: rgba(79,70,229,.3);
    color: #a5b4fc;
}

/* Message bubbles */
.cb-msg {
    display:    flex;
    align-items:flex-end;
    gap:        8px;
    max-width:  88%;
    animation:  cb-msg-in .25s ease;
}
@keyframes cb-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cb-msg.user {
    margin-left:  auto;
    flex-direction:row-reverse;
}
.cb-msg-avatar {
    width:        28px;
    height:       28px;
    border-radius:50%;
    background:   var(--cb-accent);
    color:        #fff;
    display:      flex;
    align-items:  center;
    justify-content:center;
    font-size:    13px;
    flex-shrink:  0;
}
.cb-msg.user .cb-msg-avatar {
    background:   #7c3aed;
}
.cb-bubble {
    padding:      10px 14px;
    border-radius:16px;
    font-size:    13.5px;
    line-height:  1.55;
    color:        var(--cb-text);
    white-space:  pre-wrap;
    word-break:   break-word;
    background:   var(--cb-bubble-bot);
    border:       1px solid var(--cb-border);
    border-bottom-left-radius: 4px;
    position: relative;
}
.cb-msg.user .cb-bubble {
    background:              var(--cb-bubble-user);
    color:                   #fff;
    border:                  none;
    border-bottom-left-radius:16px;
    border-bottom-right-radius:4px;
}
.cb-bubble strong { font-weight: 700; }
.cb-time {
    font-size:   10px;
    color:       var(--cb-text-muted);
    margin-top:  3px;
    padding:     0 2px;
}

/* Intent badge */
.cb-intent-tag {
    display:       inline-block;
    font-size:     10px;
    padding:       1px 6px;
    border-radius: 20px;
    margin-bottom: 4px;
    font-weight:   600;
    letter-spacing:.3px;
}
.cb-intent-tag.academy   { background: #d1fae5; color: #065f46; }
.cb-intent-tag.education { background: #dbeafe; color: #1e3a8a; }
.cb-intent-tag.oos       { background: #fee2e2; color: #7f1d1d; }
body.dark-mode .cb-intent-tag.academy   { background:#064e3b; color:#6ee7b7; }
body.dark-mode .cb-intent-tag.education { background:#1e3a8a; color:#93c5fd; }
body.dark-mode .cb-intent-tag.oos       { background:#7f1d1d; color:#fca5a5; }

/* ── Quick Replies ─────────────────────────────────────────── */
#cb-quick-replies {
    padding:    8px 14px;
    display:    flex;
    flex-wrap:  wrap;
    gap:        6px;
    flex-shrink:0;
    border-top: 1px solid var(--cb-border);
    background: var(--cb-surface);
    max-height: 90px;
    overflow-y: auto;
}
.cb-quick-btn {
    background:   var(--cb-bg);
    border:       1px solid var(--cb-accent);
    color:        var(--cb-accent);
    border-radius:20px;
    padding:      5px 12px;
    font-size:    12px;
    cursor:       pointer;
    white-space:  nowrap;
    transition:   all .2s;
    font-weight:  600;
}
.cb-quick-btn:hover {
    background:   var(--cb-accent);
    color:        #fff;
    transform:    translateY(-1px);
    box-shadow:   0 3px 10px rgba(79,70,229,.3);
}

/* ── Typing Indicator ──────────────────────────────────────── */
.cb-typing {
    display:    flex;
    align-items:center;
    gap:        5px;
    padding:    8px 12px;
    background: var(--cb-bubble-bot);
    border:     1px solid var(--cb-border);
    border-radius: 14px;
    width:      fit-content;
    animation:  cb-msg-in .2s ease;
}
.cb-dot {
    width:           8px;
    height:          8px;
    border-radius:   50%;
    background:      var(--cb-accent-light);
    animation:       cb-typing-dot 1.2s ease-in-out infinite;
}
.cb-dot:nth-child(2) { animation-delay: .2s; }
.cb-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cb-typing-dot {
    0%,60%,100% { transform: translateY(0); opacity: .4; }
    30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Input Area ────────────────────────────────────────────── */
#cb-input-area {
    display:     flex;
    align-items: flex-end;
    gap:         8px;
    padding:     10px 14px 14px;
    border-top:  1px solid var(--cb-border);
    background:  var(--cb-bg);
    flex-shrink: 0;
}
#cb-input {
    flex:            1;
    border:          1.5px solid var(--cb-border);
    background:      var(--cb-input-bg);
    color:           var(--cb-text);
    border-radius:   12px;
    padding:         10px 14px;
    font-size:       14px;
    font-family:     inherit;
    resize:          none;
    min-height:      42px;
    max-height:      120px;
    line-height:     1.4;
    outline:         none;
    transition:      border-color .2s;
}
#cb-input:focus {
    border-color: var(--cb-accent);
    box-shadow:   0 0 0 3px rgba(79,70,229,.12);
}
#cb-input::placeholder { color: var(--cb-text-muted); }

#cb-send {
    width:        42px;
    height:       42px;
    border-radius:12px;
    background:   linear-gradient(135deg, var(--cb-accent), #7c3aed);
    border:       none;
    color:        #fff;
    font-size:    17px;
    cursor:       pointer;
    display:      flex;
    align-items:  center;
    justify-content:center;
    flex-shrink:  0;
    transition:   transform .2s, box-shadow .2s;
}
#cb-send:hover {
    transform:  scale(1.08);
    box-shadow: 0 4px 14px rgba(79,70,229,.45);
}
#cb-send:disabled {
    opacity:    .5;
    cursor:     default;
    transform:  none;
    box-shadow: none;
}

/* ── Dark mode toggle in header ─────────────────────────────── */
#cb-dark-toggle { font-size: 16px; }

/* ── Footer note ──────────────────────────────────────────── */
#cb-footer-note {
    text-align:  center;
    font-size:   10px;
    color:       var(--cb-text-muted);
    padding:     4px 0 8px;
    background:  var(--cb-bg);
}
#cb-footer-note a { color: var(--cb-accent); text-decoration: none; }

/* ── Mobile tweaks ─────────────────────────────────────────── */
@media (max-width: 480px) {
    #chatbot-window {
        width:         calc(100vw - 16px);
        right:         8px;
        bottom:        90px;
        height:        calc(100vh - 110px);
        border-radius: 14px;
    }
    #chatbot-toggle {
        bottom: 18px;
        right:  18px;
    }
}
