/* Ignify Marketing Strategist — Dark Glassmorphism Theme */

:root {
    --bg: #0f1117;
    --panel: rgba(22, 27, 34, 0.85);
    --panel-solid: #161b22;
    --border: #30363d;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --text-bright: #e6edf3;
    --accent: #58a6ff;
    --accent-dim: #1f6feb;
    --green: #3fb950;
    --yellow: #d29922;
    --red: #f85149;
    --purple: #d2a8ff;
    --orange: #f0883e;
    --sidebar-w: 280px;
}

/* --- Login screen --- */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    width: 360px;
}

.login-card h1 {
    color: var(--accent);
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.login-card p {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-bottom: 24px;
}

.login-card input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 12px;
}

.login-card input:focus { outline: none; border-color: var(--accent); }

.login-card button {
    width: 100%;
    padding: 10px;
    background: var(--accent-dim);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.login-card button:hover { background: var(--accent); }

.login-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 12px;
    min-height: 1.2em;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* --- Layout --- */

.app {
    display: flex;
    height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
    width: var(--sidebar-w);
    background: var(--panel);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 700;
}

.sidebar-header .subtitle {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.sidebar-tab {
    flex: 1;
    padding: 8px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* --- History --- */

.history-list { list-style: none; }

.history-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.history-item:hover { background: rgba(255,255,255,0.05); }
.history-item.active { background: rgba(88,166,255,0.1); }

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

.history-item .meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item .mode-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(88,166,255,0.15);
    color: var(--accent);
}

.history-item .delete-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.history-item:hover .delete-btn { opacity: 1; }
.history-item .delete-btn:hover { color: var(--red); }

.empty-state {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 24px 12px;
}

/* --- Pulse Feed --- */

.pulse-input { margin-bottom: 12px; }

.pulse-input textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

.pulse-input textarea:focus { outline: none; border-color: var(--accent); }

.pulse-input-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.pulse-input-row select,
.pulse-input-row input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 4px 6px;
    font-size: 0.75rem;
    font-family: inherit;
}

.pulse-input-row select:focus,
.pulse-input-row input:focus { outline: none; border-color: var(--accent); }

.btn-pulse {
    margin-top: 6px;
    width: 100%;
    padding: 6px;
    background: var(--accent-dim);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-pulse:hover { background: var(--accent); }
.btn-pulse:disabled { opacity: 0.5; cursor: not-allowed; }

.signal-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    font-size: 0.78rem;
}

.signal-card.threat { border-left: 3px solid var(--red); }

.signal-card .signal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.signal-card .signal-title {
    font-weight: 600;
    color: var(--text-bright);
    flex: 1;
}

.signal-card .freshness-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    margin-left: 8px;
}

.freshness-dot.active { background: var(--green); }
.freshness-dot.aging { background: var(--yellow); }
.freshness-dot.archived { background: var(--text-dim); }

.signal-card .signal-meta {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.signal-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 6px;
    font-weight: 600;
}

.signal-badge.category { background: rgba(210,168,255,0.15); color: var(--purple); }
.signal-badge.trend-declining { background: rgba(248,81,73,0.15); color: var(--red); }
.signal-badge.trend-rising { background: rgba(63,185,80,0.15); color: var(--green); }
.signal-badge.trend-emerging { background: rgba(88,166,255,0.15); color: var(--accent); }
.signal-badge.trend-peaked { background: rgba(210,153,34,0.15); color: var(--yellow); }
.signal-badge.implication-threat { background: rgba(248,81,73,0.15); color: var(--red); }
.signal-badge.implication-opportunity { background: rgba(63,185,80,0.15); color: var(--green); }
.signal-badge.implication-shift { background: rgba(210,153,34,0.15); color: var(--yellow); }
.signal-badge.implication-noise { background: rgba(139,148,158,0.15); color: var(--text-dim); }

.signal-card .signal-analysis {
    color: var(--text-dim);
    line-height: 1.4;
    margin-top: 4px;
}

.signal-card .signal-action {
    color: var(--accent);
    font-size: 0.75rem;
    margin-top: 4px;
}

.signal-card .signal-delete {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.7rem;
    float: right;
}

.signal-card .signal-delete:hover { color: var(--red); }

/* --- Main content --- */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- Top bar --- */

.topbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    backdrop-filter: blur(20px);
    gap: 8px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 6px 12px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.mode-btn:hover { border-color: var(--accent); color: var(--text); }
.mode-btn.active { background: rgba(88,166,255,0.15); border-color: var(--accent); color: var(--accent); }

.topbar-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover { border-color: var(--accent); color: var(--text); }

/* --- Chat area --- */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.message {
    max-width: 800px;
    margin: 0 auto 20px;
}

.message.user .message-content {
    background: rgba(88,166,255,0.1);
    border: 1px solid rgba(88,166,255,0.2);
    border-radius: 12px 12px 4px 12px;
    padding: 12px 16px;
    margin-left: auto;
    max-width: 80%;
    width: fit-content;
}

.message.assistant .message-content {
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 4px 12px 12px 12px;
    padding: 16px 20px;
    line-height: 1.65;
}

.message .sender {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.user .sender { text-align: right; }

/* Markdown content styles */
.message-content h1, .message-content h2, .message-content h3 {
    color: var(--accent);
    margin: 16px 0 8px;
}
.message-content h1 { font-size: 1.2rem; }
.message-content h2 { font-size: 1.05rem; }
.message-content h3 { font-size: 0.95rem; }
.message-content p { margin: 8px 0; }
.message-content ul, .message-content ol { padding-left: 20px; margin: 8px 0; }
.message-content li { margin: 4px 0; }
.message-content strong { color: var(--text-bright); }
.message-content em { color: var(--text-dim); }
.message-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85em;
    color: var(--orange);
}
.message-content pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85rem;
}
.message-content pre code {
    background: none;
    padding: 0;
    color: var(--text);
}
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.85rem;
}
.message-content th {
    background: rgba(33,38,45,0.8);
    text-align: left;
    padding: 8px;
    border: 1px solid var(--border);
    color: var(--text-bright);
}
.message-content td {
    padding: 8px;
    border: 1px solid var(--border);
}
.message-content blockquote {
    border-left: 3px solid var(--accent-dim);
    padding-left: 12px;
    color: var(--text-dim);
    margin: 8px 0;
}
.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    max-width: 800px;
    margin: 0 auto 20px;
}

.typing-indicator.visible { display: block; }

.typing-dots {
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 4px 12px 12px 12px;
    padding: 16px 20px;
    display: inline-flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: blink 1.4s infinite both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* Welcome message */
.welcome {
    max-width: 600px;
    margin: 60px auto;
    text-align: center;
}

.welcome h2 {
    color: var(--accent);
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.welcome-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.welcome-mode {
    padding: 10px 16px;
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.welcome-mode:hover { border-color: var(--accent); }

/* --- Input area --- */

.input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--panel);
    backdrop-filter: blur(20px);
}

.input-row {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 8px;
}

.input-row textarea {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    line-height: 1.4;
}

.input-row textarea:focus { outline: none; border-color: var(--accent); }

.btn-send {
    background: var(--accent-dim);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    align-self: flex-end;
    height: 44px;
}

.btn-send:hover { background: var(--accent); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Slide panels (Context Editor, Ledger) --- */

.slide-panel {
    position: fixed;
    top: 0;
    right: -480px;
    width: 480px;
    height: 100vh;
    background: var(--panel-solid);
    border-left: 1px solid var(--border);
    z-index: 100;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.slide-panel.open { right: 0; }

.slide-panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slide-panel-header h2 {
    font-size: 1rem;
    color: var(--accent);
}

.slide-panel-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
}

.slide-panel-close:hover { color: var(--text); }

.slide-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.panel-section {
    margin-bottom: 20px;
}

.panel-section label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.panel-section .hint {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.panel-section textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

.panel-section textarea:focus { outline: none; border-color: var(--accent); }

.constraints-card {
    border: 1px solid rgba(248,81,73,0.3);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    background: rgba(248,81,73,0.03);
}

.constraints-card h3 {
    font-size: 0.85rem;
    color: var(--red);
    margin-bottom: 8px;
}

/* Ledger panel */

.ledger-section {
    margin-bottom: 16px;
}

.ledger-section label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.ledger-section textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
}

.ledger-section textarea:focus { outline: none; border-color: var(--accent); }

.ledger-section.kill-list textarea {
    border-color: rgba(248,81,73,0.3);
}

/* --- Ledger suggestions overlay --- */

.ledger-suggestions {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-solid);
    border: 1px solid var(--accent-dim);
    border-radius: 12px;
    padding: 16px 20px;
    max-width: 600px;
    width: 90%;
    z-index: 50;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.ledger-suggestions.visible { display: block; }

.ledger-suggestions h3 {
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 12px;
}

.suggestion-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item .section-name {
    font-weight: 600;
    color: var(--purple);
}

.suggestion-item .action {
    color: var(--text-dim);
    font-size: 0.7rem;
    text-transform: uppercase;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

.btn-apply {
    padding: 6px 14px;
    background: var(--green);
    color: #0f1117;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-skip {
    padding: 6px 14px;
    background: none;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-skip:hover { color: var(--text); }

/* --- Overlay backdrop --- */

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

.overlay.visible { display: block; }

/* --- Mobile --- */

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        z-index: 200;
        transition: left 0.3s ease;
        height: 100vh;
    }
    .sidebar.open { left: 0; }
    .hamburger { display: block; }
    .slide-panel { width: 100%; right: -100%; }
    .topbar { padding: 8px; }
    .mode-btn { font-size: 0.65rem; padding: 4px 8px; }
    .chat-area { padding: 16px; }
    .input-area { padding: 12px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
