/* NukNukNuk Dashboard -- brand: dark navy + lime green (compedgesolutions.us palette) */

/* === Variables === */
:root {
    --navy:         #0f172a;
    --navy-dark:    #080d17;
    --navy-card:    #1e293b;
    --lime:         #4ade80;
    --lime-dark:    #22c55e;
    --lime-light:   #86efac;
    --slate-border: #334155;
    --slate-muted:  #64748b;
    --slate-faint:  #94a3b8;
    --white:        #ffffff;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-pill:  9999px;
    --shadow-lime:  0 0 24px rgba(74, 222, 128, 0.18);
    --transition:   200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--navy-dark);
    color: var(--white);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    min-height: 100dvh;
}

/* Session page needs full-height flex column so the input sticks to the bottom */
body.session-layout {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    height: 100svh; /* Small viewport height -- correct on iOS Safari */
}

/* === Navigation === */
.app-nav {
    background: rgba(8, 13, 23, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--slate-border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}
.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.nav-brand {
    display: flex;
    align-items: baseline;
    text-decoration: none;
    gap: 0.5rem;
}
.nav-brand-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--lime);
    line-height: 1;
}
.nav-brand-sub {
    font-size: 0.6875rem;
    color: var(--slate-faint);
    display: none;
}
@media (min-width: 480px) { .nav-brand-sub { display: inline; } }

.nav-right { display: flex; align-items: center; gap: 0.75rem; }
.nav-back {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--slate-faint);
    text-decoration: none;
    transition: var(--transition);
}
.nav-back:hover { color: var(--white); }
.nav-back svg { flex-shrink: 0; }

/* === Nav tabs === */
.nav-tabs {
    display: flex;
    gap: 0.125rem;
    flex: 1;
    justify-content: center;
}
.nav-tab {
    padding: 0.3125rem 0.875rem;
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--slate-faint);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}
.nav-tab:hover { color: var(--white); }
.nav-tab.active {
    background: rgba(74, 222, 128, 0.12);
    color: var(--lime);
    font-weight: 600;
}

/* === Buttons === */
.btn-lime {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.5rem;
    background: var(--lime);
    color: var(--navy-dark);
    font-weight: 700;
    font-size: 0.9375rem;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(74, 222, 128, 0.3);
    white-space: nowrap;
}
.btn-lime:hover {
    background: var(--lime-dark);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
    transform: translateY(-1px);
}
.btn-lime-sm {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 1rem;
    background: var(--lime);
    color: var(--navy-dark);
    font-weight: 600;
    font-size: 0.8125rem;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-lime-sm:hover { background: var(--lime-dark); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    background: transparent;
    color: var(--slate-faint);
    font-size: 0.8125rem;
    border: 1px solid var(--slate-border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-ghost:hover { color: var(--white); border-color: var(--slate-muted); }

.btn-ghost-xs {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    background: transparent;
    color: var(--slate-faint);
    font-size: 0.75rem;
    border: 1px solid var(--slate-border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.btn-ghost-xs:hover { color: var(--white); border-color: var(--slate-muted); }

/* === Forms === */
.form-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--slate-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.375rem;
}
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--navy);
    border: 1px solid var(--slate-border);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}
.form-input:focus {
    border-color: var(--lime);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}
.form-input::placeholder { color: var(--slate-muted); }
.error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    color: #fca5a5;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* === Login page === */
.login-wrap {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--navy-card);
    border: 1px solid var(--slate-border);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--lime);
    margin: 0 auto 0.875rem;
    display: block;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.25);
}
.login-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.375rem;
    color: var(--white);
    margin: 0;
}
.login-sub {
    font-size: 0.8125rem;
    color: var(--slate-faint);
    margin: 0.25rem 0 0;
}
.login-form { margin-top: 0.25rem; }
.login-form .form-group { margin-bottom: 1rem; }
.login-form .btn-lime { width: 100%; margin-top: 0.5rem; }

/* === Page layout (non-session) === */
.page-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    width: 100%;
}
.page-header { margin-bottom: 1.5rem; }
.page-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0;
}
.page-subtitle { font-size: 0.875rem; color: var(--slate-faint); margin: 0.25rem 0 0; }

/* === Stooge grid (hosts page) === */
.stooge-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
}
@media (min-width: 520px) { .stooge-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 760px) { .stooge-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 960px) { .stooge-grid { grid-template-columns: repeat(5, 1fr); } }

.stooge-card {
    background: var(--navy-card);
    border: 1px solid var(--slate-border);
    border-radius: var(--radius);
    padding: 1.25rem 0.875rem 1rem;
    text-align: center;
    text-decoration: none;
    color: var(--white);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
}
.stooge-card:hover {
    border-color: var(--lime);
    box-shadow: var(--shadow-lime);
    transform: translateY(-2px);
}
.stooge-card.is-online { border-color: rgba(74, 222, 128, 0.3); }
.stooge-card.is-offline { opacity: 0.6; }

.stooge-avatar-wrap { position: relative; display: inline-block; }
.stooge-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--slate-border);
    background: var(--navy);
    display: block;
}
.stooge-card.is-online .stooge-avatar { border-color: var(--lime); }

.status-dot {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--navy-card);
}
.status-dot.online  { background: var(--lime); box-shadow: 0 0 6px var(--lime); }
.status-dot.offline { background: var(--slate-muted); }

.stooge-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1rem;
}
.stooge-status-label { font-size: 0.75rem; font-weight: 600; }
.stooge-status-label.online  { color: var(--lime); }
.stooge-status-label.offline { color: var(--slate-muted); }
.stooge-lastseen { font-size: 0.6875rem; color: var(--slate-faint); }

/* === Project list === */
.project-list { display: flex; flex-direction: column; gap: 0.75rem; }
.project-card {
    background: var(--navy-card);
    border: 1px solid var(--slate-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}
.project-card:hover { border-color: var(--lime); box-shadow: var(--shadow-lime); }
.project-card-body { flex: 1; min-width: 0; }
.project-name { font-weight: 600; font-size: 0.9375rem; }
.project-path {
    font-size: 0.75rem;
    color: var(--slate-faint);
    margin-top: 0.25rem;
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-repo {
    font-size: 0.6875rem;
    color: var(--lime);
    margin-top: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
    align-items: flex-end;
}
@media (min-width: 480px) {
    .project-actions { flex-direction: row; align-items: center; }
}

/* === Session chat layout === */
.session-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--slate-border);
    background: rgba(15, 23, 42, 0.8);
    flex-shrink: 0;
    gap: 0.75rem;
}
.session-header-info { display: flex; align-items: center; gap: 0.625rem; min-width: 0; }
.session-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--lime);
    flex-shrink: 0;
}
.session-header-name {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-header-sub { font-size: 0.6875rem; color: var(--slate-faint); }

/* === Messages === */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    scroll-behavior: smooth;
    min-height: 0;
}
.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--slate-border); border-radius: 2px; }

.msg-row { display: flex; gap: 0.5rem; max-width: 88%; }
@media (min-width: 600px) { .msg-row { max-width: 75%; } }
.msg-user-row      { align-self: flex-end; flex-direction: column; align-items: flex-end; }
.msg-assistant-row { align-self: flex-start; }
.msg-system {
    align-self: center;
    font-size: 0.75rem;
    color: var(--slate-faint);
    background: rgba(51, 65, 85, 0.5);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill);
}
.msg-bubble {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}
.msg-user-bubble {
    background: var(--lime);
    color: var(--navy-dark);
    border-bottom-right-radius: 4px;
    font-weight: 500;
}
.msg-assistant-bubble {
    background: var(--navy-card);
    border: 1px solid var(--slate-border);
    border-bottom-left-radius: 4px;
    color: var(--white);
}
.msg-meta { font-size: 0.6875rem; color: var(--slate-faint); padding: 0.125rem 0.25rem; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; margin-top: 0.25rem; }

/* === Thinking indicator === */
.thinking-bubble {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 0.75rem 1rem;
    min-height: 42px;
}
.thinking-dot {
    width: 7px;
    height: 7px;
    background: var(--slate-muted);
    border-radius: 50%;
    animation: pulse-dot 1.4s infinite ease-in-out;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse-dot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30%           { opacity: 1;   transform: scale(1);   }
}

/* === Prompt form === */
.prompt-form {
    border-top: 1px solid var(--slate-border);
    background: var(--navy);
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}
.prompt-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 960px;
    margin: 0 auto;
}
.prompt-textarea {
    flex: 1;
    background: var(--navy-card);
    border: 1px solid var(--slate-border);
    border-radius: 22px;
    color: var(--white);
    font-family: inherit;
    font-size: 0.9375rem;
    padding: 0.625rem 1rem;
    resize: none;
    outline: none;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.4;
    transition: var(--transition);
    display: block;
}
.prompt-textarea:focus {
    border-color: var(--lime);
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.15);
}
.prompt-textarea::placeholder { color: var(--slate-muted); }
.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--lime);
    border: none;
    color: var(--navy-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.send-btn:hover  { background: var(--lime-dark); transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { background: var(--slate-border); cursor: not-allowed; transform: none; }

/* === All-projects filter === */
.filter-wrap { margin-bottom: 1rem; }
.filter-input {
    width: 100%;
    padding: 0.625rem 1.125rem;
    background: var(--navy-card);
    border: 1px solid var(--slate-border);
    border-radius: var(--radius-pill);
    color: var(--white);
    font-family: inherit;
    font-size: 0.9375rem;
    outline: none;
    transition: var(--transition);
}
.filter-input:focus {
    border-color: var(--lime);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}
.filter-input::placeholder { color: var(--slate-muted); }

/* Agent badge (project list -- shows which Stooge owns the project) */
.project-agent {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}
.agent-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--slate-border);
    flex-shrink: 0;
}
.agent-name {
    font-size: 0.75rem;
    color: var(--lime-light);
    font-weight: 500;
    white-space: nowrap;
}
.agent-path {
    font-size: 0.6875rem;
    color: var(--slate-faint);
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--slate-faint);
}
.empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--slate-border);
}

/* === Utility === */
.text-lime  { color: var(--lime);        }
.text-muted { color: var(--slate-muted); }
.text-faint { color: var(--slate-faint); }
.font-display { font-family: 'Space Grotesk', sans-serif; }
