/* ============================================
   P.A.M. Command Center v2.1 — Main Stylesheet
   Theme: Premium Purple Glassmorphism
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-dark: #080510;
    --bg-card: rgba(12, 8, 24, 0.9);
    --bg-card-solid: #0c0818;
    --bg-input: rgba(139, 92, 246, 0.04);
    --bg-hover: rgba(139, 92, 246, 0.06);
    --border: rgba(139, 92, 246, 0.08);
    --border-hover: rgba(139, 92, 246, 0.2);
    --purple: #8b5cf6;
    --purple-light: #c4b5fd;
    --purple-dim: rgba(139, 92, 246, 0.4);
    --purple-glow: rgba(139, 92, 246, 0.15);
    --purple-subtle: rgba(139, 92, 246, 0.06);
    --pink: #ec4899;
    --pink-light: #f9a8d4;
    --pink-dim: rgba(236, 72, 153, 0.4);
    --pink-glow: rgba(236, 72, 153, 0.15);
    --pink-subtle: rgba(236, 72, 153, 0.06);
    --cyan: #06b6d4;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --text-primary: #d1cce6;
    --text-secondary: #7c6f9b;
    --text-dim: #3d3656;
    --text-muted: #2d2646;
    --font-title: 'Orbitron', monospace;
    --font-ui: 'Inter', 'Rajdhani', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
    --accent: var(--purple);
    --accent-light: var(--purple-light);
    --accent-dim: var(--purple-dim);
    --accent-glow: var(--purple-glow);
    --accent-subtle: var(--purple-subtle);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --sidebar-w: 250px;
    --topbar-h: 48px;
    --glass-bg: rgba(139, 92, 246, 0.04);
    --glass-border: rgba(139, 92, 246, 0.08);
    --glass-blur: blur(12px);
}

/* Unfiltered mode overrides */
body.mode-unfiltered {
    --accent: var(--pink);
    --accent-light: var(--pink-light);
    --accent-dim: var(--pink-dim);
    --accent-glow: var(--pink-glow);
    --accent-subtle: var(--pink-subtle);
    --glass-bg: rgba(236, 72, 153, 0.04);
    --glass-border: rgba(236, 72, 153, 0.08);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font-ui);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 10px; }
::selection { background: var(--accent-glow); color: var(--text-primary); }
.hidden { display: none !important; }

/* --- Loading Screen --- */
.loading-screen {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg-dark);
}
.loading-orb {
    width: 90px; height: 90px; border-radius: 50%;
    background: conic-gradient(from 0deg, #8b5cf6, #ec4899, #06b6d4, #8b5cf6);
    box-shadow: 0 0 40px var(--accent-glow), 0 0 80px rgba(139, 92, 246, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.4);
    animation: orb-spin 6s linear infinite;
    position: relative;
}
.loading-orb::before {
    content: ''; position: absolute; inset: 7px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(20, 10, 40, 0.4), #080510 70%);
}
.loading-orb::after {
    content: ''; position: absolute; inset: -4px; border-radius: 50%;
    background: conic-gradient(from 180deg, transparent 40%, rgba(139, 92, 246, 0.2) 50%, transparent 60%);
    animation: orb-spin 4s linear infinite reverse;
    filter: blur(8px);
}
.loading-text { text-align: center; margin-top: 24px; }
.loading-title {
    display: block; font-family: var(--font-title); font-size: 28px;
    color: var(--accent-light); letter-spacing: 8px;
}
.loading-sub {
    display: block; color: var(--text-secondary); font-size: 13px;
    margin-top: 8px; letter-spacing: 3px;
}
.loading-bar {
    width: 180px; height: 2px; background: var(--border);
    margin-top: 24px; border-radius: 2px; overflow: hidden;
}
.loading-fill {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--purple), var(--pink));
    animation: load-fill 2.4s ease forwards;
}

/* --- Login Screen --- */
.login-screen {
    position: fixed; inset: 0; z-index: 900;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-dark);
}
.login-box {
    width: 340px; padding: 40px 32px; text-align: center;
    background: rgba(20, 12, 40, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 80px var(--accent-glow);
}
.login-logo {
    font-family: var(--font-title); font-size: 28px;
    color: var(--accent-light); letter-spacing: 6px;
}
.login-subtitle {
    color: var(--text-secondary); font-size: 12px;
    margin: 4px 0 28px; letter-spacing: 2px;
}
.input-group { margin-bottom: 12px; }
.input-group input {
    width: 100%; padding: 13px 16px; border-radius: var(--radius-sm);
    background: var(--accent-subtle); border: 1px solid var(--border);
    color: var(--text-primary); font-family: var(--font-ui); font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s; outline: none;
}
.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 16px var(--accent-glow);
}
.btn-primary {
    width: 100%; padding: 13px; margin-top: 8px;
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    color: var(--accent-light); font-family: var(--font-title);
    font-size: 12px; letter-spacing: 4px; cursor: pointer;
    transition: all 0.3s;
}
.btn-primary:hover {
    background: var(--accent-glow);
    box-shadow: 0 0 30px var(--accent-glow);
}
.login-error { color: var(--error); font-size: 12px; margin-top: 12px; }

/* --- App Layout --- */
.app-main { display: flex; flex-direction: column; height: 100vh; }

/* --- Topbar --- */
.topbar {
    display: flex; align-items: center; gap: 10px;
    height: var(--topbar-h); padding: 0 14px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}
.topbar-logo { display: flex; align-items: center; gap: 8px; }
.logo-text {
    font-family: var(--font-title); font-size: 16px;
    color: var(--accent-light); letter-spacing: 3px;
    cursor: pointer; user-select: none; transition: color 0.4s;
}
.unfiltered-badge {
    display: none; padding: 2px 8px; border-radius: 6px;
    background: var(--pink-subtle);
    border: 1px solid rgba(236, 72, 153, 0.2);
    font-family: var(--font-code); font-size: 8px;
    color: var(--pink); letter-spacing: 1px;
}
body.mode-unfiltered .unfiltered-badge { display: inline-block; }
body.mode-unfiltered .logo-text { color: var(--pink-light); }

.mode-toggle-btn {
    transition: all 0.3s ease !important;
    font-size: 16px !important;
    border-radius: 8px !important;
}
.mode-toggle-btn:hover { transform: scale(1.15); }

.topbar-stats {
    display: flex; gap: 14px; margin-left: auto; align-items: center;
}
.stat-item {
    font-family: var(--font-code); font-size: 10px; color: var(--text-dim);
}
.topbar-clock {
    color: var(--accent); font-weight: 500;
    font-size: 11px; transition: color 0.4s;
}
.topbar-actions { display: flex; gap: 3px; margin-left: 10px; }
.topbar-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-dim); font-size: 14px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.topbar-btn:hover {
    border-color: var(--border-hover); color: var(--accent);
    background: var(--accent-subtle);
}
.menu-toggle {
    display: none; width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: transparent; border: 1px solid var(--border);
    align-items: center; justify-content: center; cursor: pointer;
    font-size: 14px; color: var(--text-secondary);
}

/* --- Logo orb indicator --- */
.topbar-logo::before {
    content: ''; width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-dim);
    transition: all 0.4s;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: rgba(12, 8, 24, 0.95);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 50;
    backdrop-filter: var(--glass-blur);
}
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h3 {
    font-family: var(--font-title); font-size: 9px; letter-spacing: 3px;
    color: var(--text-secondary); text-transform: uppercase;
}
.btn-icon {
    width: 28px; height: 28px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: transparent;
    color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; transition: all 0.2s;
}
.btn-icon:hover {
    border-color: var(--border-hover); color: var(--accent);
}
.conversation-list { flex: 1; overflow-y: auto; padding: 4px 6px; }

.conv-item {
    padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
    color: var(--text-secondary); font-size: 12px; transition: all 0.2s;
    border: 1px solid transparent; margin-bottom: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover {
    background: var(--accent-subtle); color: var(--accent-light);
}
.conv-item.active {
    background: var(--accent-glow);
    border-color: var(--border-hover);
    color: var(--accent-light);
}
.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid rgba(139, 92, 246, 0.04);
}
.sidebar-version {
    font-family: var(--font-code); font-size: 9px; color: var(--text-muted);
}

/* --- Content Area --- */
.content-area {
    flex: 1; margin-left: var(--sidebar-w); margin-top: 0;
    display: flex; flex-direction: column; overflow: hidden;
    position: relative;
}
.view { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* --- Chat --- */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 16px 0; }

.welcome-screen {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; opacity: 0.9; gap: 8px;
}
.welcome-orb {
    width: 90px; height: 90px; border-radius: 50%;
    background: conic-gradient(from 0deg, #8b5cf6, #ec4899, #06b6d4, #8b5cf6);
    box-shadow: 0 0 40px var(--accent-glow), 0 0 80px rgba(139, 92, 246, 0.1),
                inset 0 0 30px rgba(0, 0, 0, 0.4);
    animation: orb-spin 6s linear infinite;
    position: relative; margin-bottom: 12px;
}
.welcome-orb::before {
    content: ''; position: absolute; inset: 7px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(20, 10, 40, 0.4), #080510 70%);
}
.welcome-orb::after {
    content: ''; position: absolute; inset: -4px; border-radius: 50%;
    background: conic-gradient(from 180deg, transparent 40%, rgba(139, 92, 246, 0.2) 50%, transparent 60%);
    animation: orb-spin 4s linear infinite reverse; filter: blur(8px);
}
.welcome-screen h2 {
    font-family: var(--font-title); color: var(--accent-light);
    font-size: 18px; letter-spacing: 3px; transition: color 0.4s;
}
.welcome-screen p { color: var(--text-dim); margin-top: 4px; font-size: 13px; }

/* Messages */
.msg {
    display: flex; gap: 8px; margin-bottom: 14px;
    max-width: 88%; animation: msg-in 0.35s ease;
}
.msg.user { margin-left: auto; flex-direction: row-reverse; }

.msg-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
}
.msg.assistant .msg-avatar {
    background: var(--accent-glow);
    border: 1px solid var(--border-hover);
}
.msg.user .msg-avatar {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-bubble {
    padding: 12px 16px; border-radius: var(--radius);
    font-size: 13px; line-height: 1.65;
    backdrop-filter: blur(8px);
}
.msg.assistant .msg-bubble {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.04);
}
.msg.user .msg-bubble {
    background: var(--accent-glow);
    border: 1px solid var(--border-hover);
}
.msg-bubble strong { color: var(--accent-light); }

.msg-bubble pre {
    background: rgba(0, 0, 0, 0.3); padding: 12px; border-radius: var(--radius-sm);
    overflow-x: auto; margin: 8px 0; font-family: var(--font-code); font-size: 12px;
    border: 1px solid var(--border);
}
.msg-bubble code {
    font-family: var(--font-code); font-size: 12px;
    background: var(--accent-subtle); padding: 1px 5px; border-radius: 4px;
}
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }

.chat-media-img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    margin: 8px 0;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-media-img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px var(--purple-glow);
}

.chat-media-video {
    max-width: 100%;
    border-radius: 12px;
    margin: 8px 0;
    border: 1px solid var(--border);
}

.msg-actions { display: flex; gap: 4px; margin-top: 6px; }
.msg-action-btn {
    padding: 2px 8px; border-radius: 6px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-dim); font-size: 10px; cursor: pointer;
    transition: all 0.2s;
}
.msg-action-btn:hover {
    border-color: var(--border-hover); color: var(--accent);
}

/* Typing indicator */
.typing-indicator { display: flex; gap: 5px; padding: 6px 0; }
.typing-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent-dim); animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* --- Chat Input Bar --- */
.chat-input-bar {
    padding: 8px 16px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-dark); flex-shrink: 0;
}
.input-wrapper {
    display: flex; align-items: flex-end; gap: 4px;
    padding: 7px 10px; border-radius: var(--radius);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    transition: border-color 0.3s, box-shadow 0.3s;
    backdrop-filter: blur(8px);
}
.input-wrapper:focus-within {
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 0 16px var(--accent-glow);
}
body.mode-unfiltered .input-wrapper:focus-within {
    border-color: rgba(236, 72, 153, 0.25);
    box-shadow: 0 0 16px var(--pink-glow);
}
#chatInput {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text-primary); font-family: var(--font-ui); font-size: 13px;
    resize: none; max-height: 100px; line-height: 1.5;
}
#chatInput::placeholder { color: var(--text-dim); }
.input-btn {
    width: 32px; height: 32px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-dim); font-size: 15px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; flex-shrink: 0;
}
.input-btn:hover { color: var(--accent); background: var(--accent-subtle); }
.send-btn { color: var(--accent); }

/* --- Camera Preview --- */
.camera-preview {
    position: fixed; bottom: 100px; right: 20px;
    width: 240px; border-radius: var(--radius);
    overflow: hidden; border: 1px solid var(--accent);
    box-shadow: 0 0 30px var(--accent-glow); z-index: 80;
}
.camera-preview video { width: 100%; display: block; }
.camera-snap-btn, .camera-close-btn {
    position: absolute; top: 8px; padding: 4px 8px;
    border: 1px solid var(--accent-dim); border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.6); color: white; cursor: pointer; font-size: 14px;
}
.camera-snap-btn { right: 40px; }
.camera-close-btn { right: 8px; }

/* --- Dashboard --- */
.orb-container {
    width: 100%; height: 200px; position: relative;
    display: flex; align-items: center; justify-content: center;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px; padding: 20px; overflow-y: auto;
}
.dash-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 18px;
    transition: all 0.3s;
    backdrop-filter: blur(8px);
}
.dash-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
}
.dash-card-title {
    font-family: var(--font-title); font-size: 9px; letter-spacing: 2px;
    color: var(--accent); margin-bottom: 10px; text-transform: uppercase;
    transition: color 0.4s;
}
.dash-card-value {
    font-family: var(--font-title); font-size: 26px; color: var(--text-primary);
}
.dash-card-sub {
    font-size: 11px; color: var(--text-dim); margin-top: 3px;
}

/* --- Mode Flash --- */
.mode-flash {
    position: fixed; inset: 0; z-index: 300;
    pointer-events: none; opacity: 0; transition: opacity 0.15s;
}
.mode-flash.active { opacity: 1; }
.mode-flash.to-pro {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.25), transparent 70%);
}
.mode-flash.to-unfiltered {
    background: radial-gradient(circle, rgba(236, 72, 153, 0.25), transparent 70%);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { left: -260px; transition: left 0.3s; }
    .sidebar.open { left: 0; }
    .content-area { margin-left: 0; }
    .menu-toggle { display: flex !important; }
    .msg { max-width: 95%; }
    .topbar-stats { display: none; }
    .attachment-preview-bar { gap: 6px; padding: 6px 8px; }
    .attachment-thumb img { width: 50px; height: 50px; }
}

/* --- Attachment Preview Bar (above input) --- */
.attachment-preview-bar {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--purple-dim) transparent;
}

.attachment-thumb {
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border-radius: 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.attachment-thumb:hover {
    border-color: var(--purple-dim);
}

.attachment-thumb img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
}

.attachment-doc-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--bg-input);
    border-radius: 8px;
}

.attachment-name {
    font-size: 10px;
    color: var(--text-secondary);
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--error);
    color: white;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
}

.attachment-thumb:hover .attachment-remove {
    opacity: 1;
}

/* --- Drag & Drop Overlay --- */
.drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(139, 92, 246, 0.12);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--purple);
    border-radius: 16px;
    transition: opacity 0.2s;
}

.drop-overlay.hidden {
    display: none;
}

.drop-overlay-content {
    font-size: 24px;
    color: var(--purple-light);
    font-weight: 600;
    padding: 24px 40px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--purple-dim);
    box-shadow: 0 0 40px var(--purple-glow);
}

/* --- Message Attachment Thumbnails --- */
.msg-attachment-thumb {
    display: inline-block;
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    margin: 4px 4px 4px 0;
    cursor: pointer;
    transition: transform 0.15s;
    object-fit: cover;
}

.msg-attachment-thumb:hover {
    transform: scale(1.03);
}

.msg-attachment-doc {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 4px 4px 0;
}
