/* ============================================
   NoukhaInsight AI Assistant — Production UI
   ============================================ */

:root {
    --primary: #4D4DFF;
    --primary-hover: #3d3de6;
    --primary-light: #B5B5FF;
    --primary-bg: rgba(77,77,255,0.06);
    --primary-ring: rgba(77,77,255,0.12);
    --bg: #f4f5f7;
    --bg-white: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --green: #10b981;
    --green-bg: rgba(16,185,129,0.08);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.06);
    --amber: #f59e0b;
    --amber-bg: rgba(245,158,11,0.08);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06),0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06),0 2px 4px -2px rgba(0,0,0,0.04);
    --t: 0.2s ease;
    --sidebar-w: 300px;
}

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

body {
    font-family:'Poppins',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
    background:var(--bg);color:var(--text);font-size:14px;line-height:1.5;
    -webkit-font-smoothing:antialiased;height:100vh;display:flex;flex-direction:column;overflow:hidden;
}

/* ==================== HEADER ==================== */
.header{height:60px;background:var(--bg-white);border-bottom:1px solid var(--border);flex-shrink:0;z-index:50}
.header-inner{width:100%;padding:0 24px;height:100%;display:flex;align-items:center;justify-content:space-between}
.header-left{display:flex;align-items:center}
.header-brand{display:flex;align-items:center;gap:12px}
.header-brand-info{display:flex;flex-direction:column;line-height:1.2}
.header-brand-name{font-weight:700;font-size:16px;color:var(--text)}
.header-brand-sub{font-size:11px;color:var(--text-muted);font-weight:500}
.header-right{display:flex;align-items:center;gap:12px}

.status-chip{display:inline-flex;align-items:center;gap:6px;padding:5px 12px;border-radius:20px;font-size:12px;font-weight:500}
.status-chip--ok{background:var(--green-bg);color:#059669}
.status-chip--err{background:var(--red-bg);color:var(--red)}
.status-dot{width:6px;height:6px;border-radius:50%;background:currentColor;animation:blink 2s infinite}
@keyframes blink{0%,100%{opacity:1}50%{opacity:.4}}

/* ==================== APP LAYOUT ==================== */
.app-layout{flex:1;display:flex;overflow:hidden;position:relative}

/* ==================== SIDEBAR ==================== */
.sidebar{width:var(--sidebar-w);background:var(--bg-white);border-right:1px solid var(--border);display:flex;flex-direction:column;overflow-y:auto;flex-shrink:0;padding:20px 16px 0}

.sidebar-section{margin-bottom:20px}
.sidebar-label{font-size:10px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:0.08em;padding:0 8px;margin-bottom:12px}
.sidebar-divider{height:1px;background:var(--border);margin:4px 0 20px}

/* Action buttons with icon + text */
.action-list{display:flex;flex-direction:column;gap:4px}

.action-btn{
    display:flex;align-items:center;gap:12px;padding:10px 12px;
    background:transparent;border:none;border-radius:var(--radius);
    cursor:pointer;transition:all var(--t);text-align:left;
    font-family:'Poppins',sans-serif;
}
.action-btn:hover{background:var(--primary-bg)}
.action-btn:hover .action-icon{background:var(--primary);color:#fff}
.action-btn:hover .action-title{color:var(--primary)}

.action-icon{
    width:36px;height:36px;border-radius:var(--radius);
    background:var(--bg);display:flex;align-items:center;justify-content:center;
    flex-shrink:0;color:var(--text-muted);transition:all var(--t);
}
.action-icon--red{color:var(--red)}
.action-btn:hover .action-icon--red{background:var(--red);color:#fff}

.action-text{display:flex;flex-direction:column;min-width:0}
.action-title{font-size:13px;font-weight:600;color:var(--text);transition:color var(--t)}
.action-desc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Suggestion buttons */
.suggestion-list{display:flex;flex-direction:column;gap:6px}

.suggestion-btn{
    display:flex;align-items:center;gap:8px;padding:9px 12px;
    background:var(--bg);border:1px solid transparent;border-radius:var(--radius);
    color:var(--text-secondary);font-size:12.5px;font-weight:500;
    cursor:pointer;transition:all var(--t);text-align:left;
    font-family:'Poppins',sans-serif;
}
.suggestion-btn svg{flex-shrink:0;color:var(--text-muted);transition:color var(--t)}
.suggestion-btn:hover{background:var(--primary-bg);border-color:var(--primary-light);color:var(--primary)}
.suggestion-btn:hover svg{color:var(--primary)}

/* Sidebar footer */
.sidebar-footer{margin-top:auto;padding:16px 8px;border-top:1px solid var(--border)}
.sidebar-footer-brand{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--text-muted);font-weight:500}

/* Mobile */
.sidebar-toggle{
    display:none;position:fixed;bottom:90px;left:16px;z-index:45;
    width:44px;height:44px;border-radius:50%;background:var(--primary);color:#fff;
    border:none;cursor:pointer;box-shadow:var(--shadow-md);align-items:center;justify-content:center;
}
.sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.3);z-index:39}
.sidebar-overlay.active{display:block}

/* ==================== CHAT MAIN ==================== */
.chat-main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0}
.chat-container{flex:1;overflow-y:auto;padding:24px 32px}
.chatbox{max-width:860px;margin:0 auto;display:flex;flex-direction:column;gap:16px;min-height:100%}

/* ==================== EMPTY STATE ==================== */
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;flex:1;padding:40px 20px;animation:fadeUp .4s ease}

.empty-icon-wrapper{position:relative;width:80px;height:80px;margin-bottom:24px;display:flex;align-items:center;justify-content:center}
.empty-icon-ring{position:absolute;inset:0;border-radius:50%;border:2px solid var(--primary-light);animation:ring-pulse 2s ease infinite}
.empty-icon-svg{position:relative;z-index:1}

@keyframes ring-pulse{0%,100%{opacity:.3;transform:scale(1)}50%{opacity:.7;transform:scale(1.1)}}

.empty-title{font-size:20px;font-weight:700;color:var(--text);margin-bottom:8px}
.empty-text{font-size:13px;color:var(--text-secondary);margin-bottom:20px;max-width:400px;line-height:1.7}
.empty-chips{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}
.empty-chip{padding:4px 12px;background:var(--primary-bg);color:var(--primary);border-radius:20px;font-size:11px;font-weight:600;letter-spacing:.02em}

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

/* ==================== MESSAGES ==================== */
.message{max-width:75%;padding:14px 18px;border-radius:var(--radius-lg);font-size:13px;line-height:1.7;white-space:pre-wrap;word-wrap:break-word;animation:msgIn .3s ease}

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

.user-message{
    background:var(--primary);color:#fff;margin-left:auto;
    border-radius:var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    box-shadow:0 2px 8px rgba(77,77,255,0.25);font-weight:500;
}

.assistant-message{
    background:var(--bg-white);color:var(--text-secondary);margin-right:auto;
    border-radius:var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
    border:1px solid var(--border);box-shadow:var(--shadow-xs);
}

.assistant-message strong{color:var(--text);font-weight:700}
.assistant-message h1,.assistant-message h2,.assistant-message h3{font-size:13px;font-weight:700;color:var(--text);margin:14px 0 6px}
.assistant-message h1:first-child,.assistant-message h2:first-child,.assistant-message h3:first-child{margin-top:0}
.assistant-message p{margin:8px 0;line-height:1.7}
.assistant-message p:first-child{margin-top:0}
.assistant-message p:last-child{margin-bottom:0}
.assistant-message ul,.assistant-message ol{margin:10px 0;padding-left:20px}
.assistant-message li{margin:6px 0;line-height:1.7;color:var(--text-secondary);font-size:13px}
.assistant-message code{background:var(--primary-bg);padding:2px 6px;border-radius:4px;font-size:12px;color:var(--primary);font-family:'Courier New',monospace}
.assistant-message pre{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:12px;overflow-x:auto;margin:10px 0}
.assistant-message a{color:var(--primary);text-decoration:none;font-weight:600}
.assistant-message a:hover{text-decoration:underline}
.assistant-message blockquote{border-left:3px solid var(--primary-light);padding:8px 12px;margin:10px 0;background:var(--primary-bg);border-radius:0 var(--radius-sm) var(--radius-sm) 0;color:var(--text-secondary);font-style:italic}

/* Status badges */
.status-badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em}
.status-red{background:var(--red-bg);color:var(--red)}
.status-green{background:var(--green-bg);color:var(--green)}
.status-yellow{background:var(--amber-bg);color:var(--amber)}

.assistant-message ul.client-list{padding-left:20px}
.assistant-message li.client-item{margin:8px 0;padding-left:4px;line-height:1.8}

/* ==================== TOOL CALLING LOADER ==================== */
.tool-loader{
    max-width:340px;margin-right:auto;
    animation:msgIn .3s ease;
}

.tool-loader-head{
    display:flex;align-items:center;gap:8px;
    padding:0 0 10px 2px;
}

.tool-loader-icon{
    width:24px;height:24px;border-radius:6px;
    background:var(--primary);display:flex;align-items:center;justify-content:center;
    flex-shrink:0;
}

.tool-loader-head-text{font-size:12px;font-weight:600;color:var(--text)}
.tool-loader-head-sub{font-size:11px;color:var(--text-muted);font-weight:400}

.tool-steps{padding:0 0 0 2px}

.tool-step{
    display:flex;align-items:flex-start;gap:12px;
    position:relative;padding:8px 0;
}

/* Vertical connector line */
.tool-step:not(:last-child)::after{
    content:'';position:absolute;left:9px;top:28px;
    width:1.5px;height:calc(100% - 12px);
    background:var(--border);transition:background .3s ease;
}
.tool-step.done:not(:last-child)::after{background:var(--green)}

/* Step indicator circle */
.tool-step-indicator{
    width:20px;height:20px;border-radius:50%;
    border:2px solid var(--border);background:var(--bg-white);
    display:flex;align-items:center;justify-content:center;
    flex-shrink:0;position:relative;z-index:1;
    transition:all .3s ease;
}

.tool-step.active .tool-step-indicator{
    border-color:var(--primary);background:var(--primary-bg);
}

.tool-step.done .tool-step-indicator{
    border-color:var(--green);background:var(--green);
}

/* Spinner inside active step */
.tool-step.active .tool-step-indicator::after{
    content:'';width:8px;height:8px;
    border:1.5px solid transparent;border-top-color:var(--primary);
    border-radius:50%;animation:spin .6s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* Checkmark inside done step */
.tool-step.done .tool-step-indicator svg{display:block}
.tool-step:not(.done) .tool-step-indicator svg{display:none}

.tool-step-content{flex:1;min-width:0;padding-top:1px}

.tool-step-label{
    font-size:12.5px;font-weight:500;
    color:var(--text-muted);transition:color .3s ease;
}
.tool-step.active .tool-step-label{color:var(--text);font-weight:600}
.tool-step.done .tool-step-label{color:var(--text-secondary)}

.tool-step-tag{
    display:inline-block;margin-top:2px;
    padding:1px 6px;border-radius:4px;
    font-size:10px;font-weight:600;font-family:'Poppins',sans-serif;
    background:var(--bg);color:var(--text-muted);
    transition:all .3s ease;
}
.tool-step.active .tool-step-tag{background:var(--primary-bg);color:var(--primary)}
.tool-step.done .tool-step-tag{background:var(--green-bg);color:var(--green)}

/* ==================== INPUT BAR ==================== */
.input-bar{flex-shrink:0;padding:16px 32px;background:var(--bg-white);border-top:1px solid var(--border)}
.input-row{max-width:860px;margin:0 auto;display:flex;align-items:flex-end;gap:10px}

.input-field{
    flex:1;display:flex;align-items:center;gap:10px;
    background:var(--bg);border:1.5px solid var(--border);border-radius:var(--radius-lg);
    padding:10px 16px;transition:border-color var(--t),box-shadow var(--t);
}
.input-field:focus-within{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-ring);background:var(--bg-white)}
.input-prefix-icon{flex-shrink:0;transition:color var(--t)}
.input-field:focus-within .input-prefix-icon{color:var(--primary)!important}

.chat-input{width:100%;background:transparent;color:var(--text);border:none;font-size:13px;font-family:'Poppins',sans-serif;resize:none;min-height:22px;max-height:120px;outline:none;line-height:1.5}
.chat-input::placeholder{color:var(--text-muted)}

.btn-send{
    width:44px;height:44px;border-radius:var(--radius);background:var(--primary);color:#fff;
    border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;
    transition:all var(--t);flex-shrink:0;box-shadow:0 2px 6px rgba(77,77,255,0.3);
}
.btn-send:hover{background:var(--primary-hover);box-shadow:0 4px 12px rgba(77,77,255,0.35);transform:translateY(-1px)}
.btn-send:disabled{opacity:.4;cursor:not-allowed;transform:none;box-shadow:none}

.btn-icon-muted{
    width:44px;height:44px;border-radius:var(--radius);background:var(--bg);color:var(--text-muted);
    border:1px solid var(--border);cursor:pointer;display:flex;align-items:center;justify-content:center;
    transition:all var(--t);flex-shrink:0;
}
.btn-icon-muted:hover{background:var(--red-bg);color:var(--red);border-color:rgba(239,68,68,.2)}

/* ==================== FOOTER ==================== */
.footer{flex-shrink:0;background:var(--bg-white);border-top:1px solid var(--border);padding:12px 0}
.footer-inner{width:100%;padding:0 24px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px}
.footer-powered{font-size:12px;color:var(--text-secondary)}
.footer-powered strong{color:var(--text);font-weight:600}
.footer-copy{font-size:11px;color:var(--text-muted)}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar{width:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:10px}
::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}

/* ==================== RESPONSIVE ==================== */
@media(max-width:900px){
    .sidebar{position:fixed;top:60px;left:0;bottom:0;z-index:40;transform:translateX(-100%);transition:transform .3s ease;box-shadow:var(--shadow-md)}
    .sidebar.open{transform:translateX(0)}
    .sidebar-toggle{display:flex}
    .chat-container{padding:16px}
    .input-bar{padding:12px 16px}
    .message{max-width:85%}
    .tool-loader{max-width:90%}
}

@media(max-width:600px){
    .header-brand-sub{display:none}
    .footer-inner{flex-direction:column;text-align:center}
    .chatbox{gap:12px}
}

/* ==================== AUTOMATED DEMO CONTROL BAR ==================== */
#hr-demo-control-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    background: rgba(11, 16, 32, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 10px 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(77, 77, 255, 0.2);
    color: #ffffff;
    font-family: 'Poppins', -apple-system, sans-serif;
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: max-content;
    max-width: 95vw;
}
.hr-demo-bar-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 20px) !important;
}
.hr-demo-bar-content {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    white-space: nowrap;
}
.hr-demo-left-status {
    display: flex;
    align-items: center;
    gap: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    padding-right: 16px;
    white-space: nowrap;
}
.hr-demo-dot-emerald {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 10px #34d399;
    animation: hr-pulse 1.5s infinite;
    flex-shrink: 0;
}
.hr-demo-dot-amber {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 10px #f59e0b;
    flex-shrink: 0;
}
@keyframes hr-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}
.hr-demo-title-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 800;
    color: #34d399;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.2;
    white-space: nowrap;
}
.hr-demo-title-row span {
    white-space: nowrap;
}
.hr-demo-sub-text {
    font-size: 11px;
    font-weight: 500;
    color: #cbd5e1;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.3;
}
.hr-demo-timer-badge {
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    padding: 6px 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.hr-demo-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.hr-demo-btn {
    border: none;
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.hr-demo-btn span {
    white-space: nowrap;
}
.hr-demo-btn-secondary {
    background: rgba(30, 41, 59, 0.9);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.hr-demo-btn-secondary:hover {
    background: rgba(51, 65, 85, 1);
    border-color: rgba(255, 255, 255, 0.3);
}
.hr-demo-btn-danger {
    background: rgba(220, 38, 38, 0.9);
    color: #ffffff;
}
.hr-demo-btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}
@media (max-width: 650px) {
    #hr-demo-control-bar {
        width: 92%;
        padding: 8px 12px;
        bottom: 16px;
    }
    .hr-demo-bar-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .hr-demo-left-status {
        border-right: none;
        padding-right: 0;
    }
}
