/* =========================================================
   ElectGuide-AI — style.css
   ========================================================= */

/* --- Design tokens --- */
:root {
    --primary:        #2563eb;
    --primary-hover:  #1d4ed8;
    --primary-light:  rgba(37, 99, 235, 0.10);
    --accent:         #10b981;
    --accent-light:   rgba(16, 185, 129, 0.15);

    --bg-app:         #0f172a;
    --bg-sidebar:     linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    --bg-chat:        #f1f5f9;
    --bg-white:       #ffffff;
    --bg-input:       #f8fafc;

    --text-dark:      #1e293b;
    --text-muted:     #64748b;
    --text-light:     #f8fafc;

    --border:         #e2e8f0;
    --border-subtle:  rgba(255, 255, 255, 0.10);

    --radius-sm:      8px;
    --radius-md:      14px;
    --radius-lg:      20px;
    --radius-full:    9999px;

    --shadow-card:    0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-heavy:   0 20px 48px rgba(0, 0, 0, 0.40);
    --shadow-btn:     0 4px 14px rgba(37, 99, 235, 0.35);

    --transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    color: var(--text-dark);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* =========================================================
   App shell
   ========================================================= */
.app-container {
    display: flex;
    width: 96vw;
    max-width: 1260px;
    height: 92vh;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-heavy);
    overflow: hidden;
}

/* =========================================================
   Sidebar
   ========================================================= */
.sidebar {
    width: 270px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    color: var(--text-light);
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.brand i {
    font-size: 1.6rem;
    color: var(--primary);
    background: white;
    padding: 8px 9px;
    border-radius: 10px;
}

.brand h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.subtitle {
    font-size: 0.82rem;
    color: #94a3b8;
    margin-bottom: 2rem;
    padding-left: 2px;
}

/* Sidebar nav */
.suggested-topics {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.suggested-topics::-webkit-scrollbar { width: 3px; }
.suggested-topics::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.suggested-topics h3 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #475569;
    margin-bottom: 0.85rem;
}

.topic-btn {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-subtle);
    color: #cbd5e1;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-family: inherit;
}

.topic-btn i { color: var(--primary); font-size: 0.9rem; }

.topic-btn:hover {
    background: rgba(255,255,255,0.12);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    color: white;
}

/* Sidebar footer */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 1rem;
    font-size: 0.8rem;
    color: #475569;
    border-top: 1px solid var(--border-subtle);
}

.github-link {
    color: #64748b;
    display: flex;
    align-items: center;
    transition: color var(--transition), transform var(--transition);
}
.github-link:hover { color: white; transform: scale(1.15); }

/* =========================================================
   Chat main
   ========================================================= */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    min-width: 0;
    overflow: hidden;
}

/* Header */
.chat-header {
    padding: 1.1rem 1.75rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-info h2 {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-dark);
}
.header-info h2 i { color: var(--primary); }

.status {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
}

.dot {
    width: 7px;
    height: 7px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--accent);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* Mobile hamburger — hidden on desktop */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.menu-toggle:hover { background: var(--bg-chat); }

/* =========================================================
   Chat messages
   ========================================================= */
.chat-box {
    flex-grow: 1;
    padding: 1.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar { width: 6px; }
.chat-box::-webkit-scrollbar-track { background: transparent; }
.chat-box::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Message bubbles */
.message {
    display: flex;
    gap: 12px;
    max-width: 82%;
}

.bot-message { align-self: flex-start; }

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.bot-message .avatar { background: var(--primary); color: white; }
.user-message .avatar { background: #1e293b; color: white; }

/* Smaller 24×24 bot avatar used in message rows */
.bot-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.7rem;
}

.message-content {
    padding: 13px 18px;
    border-radius: var(--radius-md);
    font-size: 0.97rem;
    line-height: 1.6;
    box-shadow: var(--shadow-card);
}

.bot-message .message-content {
    background: var(--bg-white);
    color: var(--text-dark);
    border-top-left-radius: 4px;
    border: 1px solid var(--border);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    border-top-right-radius: 4px;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 5px;
    align-self: flex-start;
    margin-top: 10px;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
}

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

.copy-btn:hover {
    color: var(--primary);
}

/* Basic markdown inside messages */
.message-content p               { margin-bottom: 0.5rem; }
.message-content p:last-child    { margin-bottom: 0; }
.message-content strong          { font-weight: 600; }
.message-content em              { font-style: italic; }
.message-content ul              { margin-left: 1.4rem; margin-top: 0.4rem; }
.message-content ul li           { margin-bottom: 0.25rem; }

/* =========================================================
   Typing indicator
   ========================================================= */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    border-top-left-radius: 4px;
    border: 1px solid var(--border);
    width: fit-content;
    box-shadow: var(--shadow-card);
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Typing indicator label */
.typing-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    align-self: center;
    white-space: nowrap;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1;   }
}

/* =========================================================
   Structured responses (steps, timeline)
   ========================================================= */
.structured-response  { display: flex; flex-direction: column; gap: 10px; }

.structured-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
}

.steps-container { display: flex; flex-direction: column; gap: 8px; }

.step-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-chat);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: transform var(--transition), border-color var(--transition);
}
.step-card:hover {
    transform: translateX(4px);
    border-color: var(--primary);
}

.step-icon {
    background: var(--primary);
    color: white;
    width: 26px;
    height: 26px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.step-content { font-size: 0.95rem; color: var(--text-dark); line-height: 1.5; }

/* Timeline */
.timeline-container {
    border-left: 2px solid var(--border);
    margin-left: 8px;
    padding-left: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 8px;
}

.timeline-item { position: relative; }

.timeline-item::before {
    content: '●';
    position: absolute;
    left: -21px;
    top: -1px;
    color: var(--primary);
    font-size: 1.1rem;
    line-height: 1.2;
    background: white;
}

.timeline-content { font-size: 0.95rem; color: var(--text-dark); line-height: 1.5; }

/* =========================================================
   Input area
   ========================================================= */
.chat-input-container {
    padding: 1.1rem 1.75rem 1.25rem;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Suggestion chips */
.example-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 12px;
}

.example-prompt-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
    white-space: nowrap;
}

.example-prompt-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* Mode + form row */
.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Mode buttons */
.mode-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.mode-btn i { font-size: 0.78rem; }

.mode-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-btn);
}

/* Mode hint text */
.mode-hint {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 1rem;
    padding-left: 2px;
    transition: opacity var(--transition);
}

/* Active mode pill — compact badge shown above input row */
.mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--primary);
    color: white;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    animation: slideIn 0.2s ease both;
}

.mode-pill[hidden] { display: none; }

/* Chat form */
#chat-form {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    padding: 7px 10px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--border);
    transition: border-color var(--transition), box-shadow var(--transition);
}

#chat-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#user-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 6px 10px;
    font-size: 0.97rem;
    font-family: inherit;
    outline: none;
    color: var(--text-dark);
}

#user-input::placeholder { color: #94a3b8; }

#send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px) scale(1.06);
    box-shadow: var(--shadow-btn);
}

#send-btn:disabled {
    background: #cbd5e1;
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#stop-btn {
    background: #ef4444;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    flex-shrink: 0;
}

#stop-btn:hover {
    background: #dc2626;
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

/* =========================================================
   Animations
   ========================================================= */
.slide-in {
    animation: slideIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

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

/* =========================================================
   Responsive — Mobile
   ========================================================= */
@media (max-width: 768px) {
    body { align-items: stretch; }

    .app-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        flex-direction: column;
    }

    /* Sidebar hidden by default on mobile; toggled via JS */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 260px;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform var(--transition);
    }

    .sidebar.open { transform: translateX(0); }

    .menu-toggle { display: flex; }

    .chat-main { flex-grow: 1; }

    .chat-box { padding: 1.1rem; gap: 1rem; }

    .message { max-width: 92%; }

    .chat-input-container { padding: 0.85rem 1rem 1rem; }

    /* Stack mode buttons + form vertically on very small screens */
    .input-row { flex-wrap: wrap; gap: 8px; }

    .mode-controls { width: 100%; }

    .mode-btn { flex: 1; justify-content: center; }

    #chat-form { min-width: 0; }
}

@media (max-width: 480px) {
    .example-prompts { display: none; } /* hide chips on very small phones */
}
