/* ============================================================
   Khwaja AI Analyzer - Final Pro Style V60.0 (Neon Glass)
   ============================================================ */
:root { --bg-dark: #0f172a; --bg-panel: #1e293b; --accent: #3b82f6; --border: #334155; --text-main: #f1f5f9; --text-dim: #94a3b8; }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background: var(--bg-dark); color: var(--text-main); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* LAYOUT */
.app-container { display: flex; flex-direction: column; height: 100%; }
.main-header { height: 50px; background: #0b1120; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.logo-section { display: flex; align-items: center; gap: 10px; color: var(--accent); font-weight: 700; }
.status-indicator { font-size: 12px; color: #10b981; } .status-dot { display:inline-block; width:8px; height:8px; background:#10b981; border-radius:50%; margin-right:5px; box-shadow: 0 0 5px #10b981; }

.workspace { display: flex; flex: 1; height: calc(100vh - 50px); }
.sidebar { width: 50px; background: #0b1120; border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding-top: 10px; }
.nav-item { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); cursor: pointer; margin-bottom: 8px; transition: 0.2s; }
.nav-item:hover, .nav-item.active { background: var(--accent); color: white; box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); }
.nav-spacer { flex: 1; }

.grid-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-dark); overflow: hidden; position: relative; }
.view-section { display: flex; flex-direction: column; height: 100%; width: 100%; }
.hidden { display: none !important; }

/* TABS */
.sheet-tabs-container { height: 36px; background: #0b1120; display: flex; align-items: flex-end; padding-left: 10px; border-bottom: 1px solid var(--border); overflow-x: auto; white-space: nowrap; }
.sheet-tab { 
    padding: 6px 15px; background: var(--bg-panel); border: 1px solid var(--border); border-bottom: none; border-radius: 6px 6px 0 0; 
    font-size: 12px; margin-right: 4px; cursor: pointer; opacity: 0.7; display: inline-flex; align-items: center; gap: 8px; height: 30px; flex-shrink: 0; 
}
.sheet-tab.active { background: var(--accent); color: white; border-color: var(--accent); opacity: 1; height: 32px; margin-bottom: -1px; z-index: 2; }
.close-tab:hover { color: #fee2e2; }
.add-sheet-btn { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-dim); }

/* TOOLBAR */
.toolbar { height: 44px; background: var(--bg-panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 10px; gap: 8px; }
.tool-btn { background: #334155; border: none; color: #e2e8f0; padding: 5px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; transition: 0.2s; }
.tool-btn:hover { background: #475569; color: white; }
.tool-btn.success { background: #059669; } .tool-btn.danger { background: #b91c1c; }
.tool-btn.small { padding: 4px 8px; font-size: 11px; }

/* SPREADSHEET */
.spreadsheet-wrapper { flex: 1; overflow: auto; background: #1e293b; position: relative; }
.spreadsheet { display: grid; gap: 1px; background: var(--border); padding-bottom: 40px; }
.header, .corner { background: #1e293b; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; display:flex; align-items:center; justify-content:center; color: var(--text-dim); font-size: 12px; font-weight: 600; padding: 4px; user-select: none; box-shadow: 0 2px 5px rgba(0,0,0,0.2); position: relative; transition: background 0.2s; }
.corner { left: 0; z-index: 25; background: #0f172a; border-right: 2px solid var(--accent); cursor: pointer; }
.header:first-child { left: 0; z-index: 25; }
.header:hover, .corner:hover { background: #334155; color: white; cursor: pointer; }

.resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 5px; cursor: col-resize; z-index: 30; }
.resizer:hover { background: var(--accent); }

.cell { background: #1e293b; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 6px; font-size: 13px; white-space: nowrap; overflow: hidden; min-height: 24px; color: var(--text-main); outline: none; }
.cell:focus { background: #0f172a; outline: 2px solid var(--accent); z-index: 5; }
.cell.selected { background: rgba(59, 130, 246, 0.2) !important; }
.cell.has-formula { font-style: italic; color: #93c5fd; }
.total-row-highlight { background: #0f172a !important; color: #60a5fa !important; font-weight: 800 !important; border-top: 2px solid var(--accent) !important; border-bottom: 2px double var(--accent) !important; }

/* STATUS BAR */
.status-bar { height: 30px; background: #0b1120; border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 15px; font-size: 11px; color: var(--text-dim); gap: 15px; }
.stat-item span { color: var(--text-main); font-weight: 600; margin-left: 4px; }
.stat-spacer { flex: 1; }

/* =========================================
   AI PANEL (GLASSMORPHISM & NEON)
   ========================================= */
.ai-panel { 
    width: 320px; 
    border-left: 1px solid var(--border); 
    background: rgba(17, 24, 39, 0.95); /* Semi-transparent */
    backdrop-filter: blur(10px); 
    display: flex; flex-direction: column; 
    box-shadow: -5px 0 20px rgba(0,0,0,0.3);
}
.ai-header { padding: 15px; border-bottom: 1px solid var(--border); font-weight: 600; color: #a5b4fc; display: flex; align-items: center; gap: 8px; text-shadow: 0 0 10px rgba(165, 180, 252, 0.3); }

.chat-box { 
    flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 15px; 
    background: linear-gradient(180deg, rgba(17,24,39,0) 0%, rgba(17,24,39,0.5) 100%);
}
.message { display: flex; gap: 10px; max-width: 100%; font-size: 13px; line-height: 1.5; animation: fadeIn 0.3s ease; }
.message.user-message { flex-direction: row-reverse; }

.bubble { 
    padding: 10px 14px; border-radius: 12px; border: 1px solid transparent; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); position: relative;
}
.system-message .bubble { 
    background: #1f2937; border-color: #374151; color: #e2e8f0; border-bottom-left-radius: 2px;
}
.user-message .bubble { 
    background: var(--accent); color: white; border-bottom-right-radius: 2px;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* INPUT AREA (TRANSPARENT & GLOWING) */
.chat-input-area { 
    padding: 15px; 
    border-top: 1px solid var(--border); 
    background: rgba(15, 23, 42, 0.8); 
    backdrop-filter: blur(5px);
    display: flex; gap: 8px; 
    transition: all 0.3s;
}

#ai-input { 
    flex: 1; background: rgba(30, 41, 59, 0.6); border: 1px solid #334155; 
    color: white; padding: 10px; border-radius: 8px; resize: none; height: 42px; outline: none; transition: 0.3s;
}
#ai-input:focus { border-color: var(--accent); background: rgba(30, 41, 59, 0.9); }

#send-btn { 
    width: 42px; background: var(--accent); border: none; color: white; 
    border-radius: 8px; cursor: pointer; transition: 0.2s; 
}
#send-btn:hover { background: #2563eb; transform: scale(1.05); }

/* TECH THINKING BOX (MINIMIZED) */
.thinking-box { 
    border: 1px solid #334155; border-radius: 6px; margin-bottom: 10px; 
    background: rgba(2, 6, 23, 0.5); overflow: hidden; 
}
.thinking-box summary { 
    padding: 6px 10px; cursor: pointer; font-size: 11px; color: #60a5fa; 
    background: rgba(30, 41, 59, 0.5); user-select: none; font-weight: 600;
    transition: color 0.2s;
}
.thinking-box summary:hover { color: #93c5fd; text-decoration: underline; }
.thinking-content { 
    padding: 10px; font-family: 'Consolas', monospace; font-size: 11px; color: #cbd5e1; 
    border-top: 1px solid #334155; white-space: pre-wrap; line-height: 1.4; 
}

/* NEON PULSE ANIMATION */
@keyframes neonBreath {
    0% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.2), inset 0 0 0 transparent; border-color: #3b82f6; }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.6), inset 0 0 10px rgba(59, 130, 246, 0.1); border-color: #60a5fa; }
    100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.2), inset 0 0 0 transparent; border-color: #3b82f6; }
}
.ai-processing { 
    animation: neonBreath 2s infinite ease-in-out; 
    border-radius: 8px;
}

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

/* WAREHOUSE & VIZ */
.warehouse-header { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #1e293b; }
.warehouse-grid { padding: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; overflow-y: auto; height: 100%; }
.data-item { background: #1e293b; border: 1px solid var(--border); border-radius: 8px; padding: 15px; cursor: pointer; text-align: center; transition: 0.2s; position: relative; }
.data-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.item-actions { margin-top: 10px; display: flex; justify-content: center; gap: 5px; opacity: 0.8; }
.data-item:hover .item-actions { opacity: 1; }

.viz-container { display: flex; height: 100%; }
.viz-sidebar { width: 250px; background: #111827; border-right: 1px solid var(--border); padding: 10px; }
.viz-item { padding: 10px; border: 1px solid var(--border); margin-bottom: 5px; border-radius: 6px; cursor: pointer; background: #1e293b; }
.viz-item.active { border-color: var(--accent); background: rgba(59, 130, 246, 0.1); }
.viz-main { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.viz-controls { display: flex; gap: 10px; background: #1e293b; padding: 10px; border-radius: 8px; border: 1px solid var(--border); flex-wrap: wrap; }
.viz-select { background: #0f172a; border: 1px solid var(--border); color: white; padding: 8px; border-radius: 4px; }
#chart-area { flex: 1; background: #1e293b; border: 1px solid var(--border); border-radius: 8px; }

/* MODALS */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; z-index: 100; backdrop-filter: blur(5px); }
.modal { background: rgba(30, 41, 59, 0.95); width: 400px; border-radius: 8px; border: 1px solid var(--accent); box-shadow: 0 0 30px rgba(59, 130, 246, 0.3); overflow: hidden; animation: modalSlide 0.3s ease-out; }
.modal-header { padding: 15px; background: #0f172a; font-weight: 600; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; color: #cbd5e1; font-size: 13px; }
.modal-input { width: 100%; background: #0f172a; border: 1px solid #334155; padding: 8px; color: white; border-radius: 4px; margin-top: 10px; }
.modal-footer { padding: 15px; background: #0f172a; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); }
@keyframes modalSlide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.context-menu { position: absolute; background: #1e293b; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); z-index: 200; display: none; width: 180px; }
.menu-item { padding: 8px 12px; font-size: 13px; cursor: pointer; color: #e2e8f0; display: flex; align-items: center; gap: 10px; }
.menu-item:hover { background: var(--accent); color: white; }
.kbd-shortcut { margin-left: auto; font-size: 10px; opacity: 0.5; }