/* ============================================================================
   NexusMD Chat Premium Styling (Dark Mode / Glassmorphism)
   ============================================================================ */

:root {
    --bg-main: #070b19;
    --bg-gradient: linear-gradient(135deg, #070b19 0%, #0d1226 100%);
    --panel-bg: rgba(20, 27, 54, 0.45);
    --panel-border: rgba(255, 255, 255, 0.06);
    --glass-accent: rgba(255, 255, 255, 0.03);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --color-accent: #00e5af; /* Neon Emerald */
    --color-accent-hover: #008767;
    --color-purple: #00d2ff; /* Pulse Cyan */
    --color-purple-glow: rgba(0, 210, 255, 0.15);
    
    --msg-user-bg: linear-gradient(135deg, rgba(0, 210, 255, 0.12) 0%, rgba(0, 210, 255, 0.02) 100%);
    --msg-ai-bg: linear-gradient(135deg, rgba(20, 27, 54, 0.65) 0%, rgba(20, 27, 54, 0.35) 100%);
    
    --status-online: #10b981;
    --status-offline: #ff2a5f; /* Crimson Laser */
    --status-checking: #f59e0b;
}

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

body {
    font-family: 'Inter', 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* App Layout Structure */
.app-shell {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar Component */
.sidebar {
    width: 320px;
    background: rgba(10, 15, 26, 0.85);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
    height: 70px;
}

.sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
}

.btn-primary-new {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
}

.btn-primary-new:hover {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.btn-primary-new svg {
    width: 16px;
    height: 16px;
    color: #00d2ff;
}

.btn-toggle-sidebar {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 0.55rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-toggle-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.06);
}

.history-section {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

.history-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

.history-item.active {
    background: rgba(14, 165, 233, 0.08);
    border-color: rgba(14, 165, 233, 0.2);
}

.history-item-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    flex: 1;
}

.history-icon {
    font-size: 1rem;
    color: var(--text-secondary);
}

.history-item.active .history-icon {
    color: var(--color-accent);
}

.history-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item.active .history-title {
    color: var(--text-primary);
    font-weight: 500;
}

.btn-delete-session {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
}

.history-item:hover .btn-delete-session {
    opacity: 1;
}

.btn-delete-session:hover {
    color: var(--status-offline);
    background: rgba(239, 68, 68, 0.1);
}

/* Sidebar Footer & Settings */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--panel-border);
    background: rgba(8, 12, 21, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sidebar-footer h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.settings-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-control label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-control input[type="range"] {
    width: 100%;
    accent-color: var(--color-accent);
    background: rgba(255, 255, 255, 0.08);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

.status-panel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}

.status-dot.online {
    background-color: var(--status-online);
    box-shadow: 0 0 8px var(--status-online);
}

.status-dot.offline {
    background-color: var(--status-offline);
    box-shadow: 0 0 8px var(--status-offline);
}

.status-dot.checking {
    background-color: var(--status-checking);
    box-shadow: 0 0 8px var(--status-checking);
}

#status-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Workspace */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    position: relative;
}

.header {
    height: 70px;
    padding: 0 2rem;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(10px);
    background: rgba(11, 15, 25, 0.5);
    z-index: 10;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-info h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.model-badge {
    background: rgba(14, 165, 233, 0.1);
    color: var(--color-accent);
    border: 1px solid rgba(14, 165, 233, 0.25);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    font-family: 'Outfit', sans-serif;
}

/* Chat Workspace */
.chat-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Chat Message Styling */
.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant {
    justify-content: flex-start;
}

.message-bubble {
    position: relative;
    max-width: 80%;
    padding: 1.25rem 1.5rem 2.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
}

.message-row.user .message-bubble {
    background: var(--msg-user-bg);
    border: 1px solid rgba(0, 210, 255, 0.3);
    color: var(--text-primary);
    border-bottom-right-radius: 2px;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.08);
}

.message-row.assistant .message-bubble {
    background: var(--msg-ai-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Markdown Rendering Custom Styles */
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.message-bubble h1 { font-size: 1.35rem; }
.message-bubble h2 { font-size: 1.2rem; }
.message-bubble h3 { font-size: 1.05rem; }

.message-bubble p {
    margin-bottom: 0.75rem;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul, .message-bubble ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.message-bubble li {
    margin-bottom: 0.35rem;
}

.message-bubble code {
    background: rgba(255, 255, 255, 0.08);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    color: #e2e8f0;
}

.message-bubble pre {
    position: relative;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.message-bubble pre code {
    background: transparent;
    padding: 0;
    font-size: 0.8rem;
    color: #cbd5e1;
    display: block;
}

.message-bubble strong {
    color: #38bdf8;
    font-weight: 600;
}

.message-bubble em {
    font-style: italic;
    color: #cbd5e1;
}

/* Welcome Card (Empty State) */
.welcome-card {
    margin: auto;
    max-width: 600px;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    animation: fadeIn 0.4s ease-out;
}

/* Input Panel & Controls */
.input-panel {
    padding: 1.5rem 2rem 2rem 2rem;
    border-top: 1px solid var(--panel-border);
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 10;
}

.input-container {
    position: relative;
    display: flex;
    background: rgba(20, 27, 54, 0.65);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 0.6rem 1rem;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.input-container:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 12px rgba(0, 229, 175, 0.2);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 0.5rem 0;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    font-family: inherit;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
    color: #070b19;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 229, 175, 0.2);
    cursor: pointer;
}

.btn-send:disabled {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none !important;
}

.btn-send:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-accent-hover) 0%, var(--color-accent) 100%);
    box-shadow: 0 0 14px rgba(0, 229, 175, 0.4);
    color: #070b19 !important;
}

.btn-attach {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 0.25rem;
}

.btn-attach:hover {
    color: var(--color-accent);
    background: rgba(255, 255, 255, 0.05);
}

.quick-prompts-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
}
.quick-prompts-row::-webkit-scrollbar {
    display: none;
}
.btn-quick-prompt {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 0.45rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.btn-quick-prompt:hover {
    background: rgba(14, 165, 233, 0.1);
    color: var(--color-accent);
    border-color: rgba(14, 165, 233, 0.3);
}

.btn-attach.recording {
    color: var(--status-offline) !important;
    background: rgba(239, 68, 68, 0.15) !important;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.attachment-indicator-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.attachment-indicator-row.hidden {
    display: none;
}

.pdf-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.25);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    animation: fadeIn 0.2s ease-out;
}

.chip-icon {
    color: var(--color-accent);
    font-size: 0.95rem;
}

.chip-filename {
    color: var(--text-primary);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.btn-chip-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-chip-remove:hover {
    color: var(--status-offline);
    background: rgba(239, 68, 68, 0.1);
}

.disclaimer-row {
    display: flex;
    justify-content: center;
}

.disclaimer-row span {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

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

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ============================================================================
   Clipboard Copy Button Styles
   ============================================================================ */

.btn-copy-message {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.message-bubble:hover .btn-copy-message {
    opacity: 1;
}

.btn-copy-message:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-copy-message.copied {
    color: var(--status-online);
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    opacity: 1 !important;
}

.btn-copy-code {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-bubble pre:hover .btn-copy-code {
    opacity: 1;
}

.btn-copy-code:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-copy-code.copied {
    color: var(--status-online);
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    opacity: 1 !important;
}

.icon-check.hidden {
    display: none;
}

.btn-copy-message.copied .icon-copy,
.btn-copy-code.copied .icon-copy {
    display: none;
}

.btn-copy-message.copied .icon-check,
.btn-copy-code.copied .icon-check {
    display: block !important;
}

.btn-send.generating {
    background: transparent !important;
    border: 1px solid var(--status-offline) !important;
    color: var(--status-offline) !important;
    box-shadow: none !important;
}

.btn-send.generating:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* --- Sidebar Collapsible & Restore --- */
.sidebar.collapsed {
    width: 0px !important;
    border-right: none !important;
    overflow: hidden !important;
}

.btn-show-sidebar {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 0.45rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.75rem;
}

.btn-show-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--color-accent) !important;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.15);
}

/* Drag and Drop Overlay Styling */
.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 11, 25, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.drop-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.drop-overlay-content {
    border: 2px dashed var(--color-accent);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    background: rgba(20, 27, 54, 0.4);
    box-shadow: 0 0 30px rgba(0, 229, 175, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    max-width: 400px;
    width: 90%;
    pointer-events: none;
}

.drop-overlay.active .drop-overlay-content {
    transform: scale(1);
}

.drop-icon {
    color: var(--color-accent);
    margin-bottom: 1.5rem;
    animation: float 2s ease-in-out infinite;
}

.drop-text {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}


