/* ===== VARIABLES ===== */

:root {
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-muted: #64748b;
    --color-border: #cbd5e1;
    --color-border-light: #e2e8f0;

    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-primary-soft: #eff6ff;

    --color-success: #166534;
    --color-success-light: #dcfce7;
    --color-success-soft: #f0fdf4;
    --color-success-border: #bbf7d0;

    --color-warning: #92400e;
    --color-warning-light: #fef3c7;
    --color-warning-soft: #fff7ed;
    --color-warning-border: #fed7aa;
    --color-warning-accent: #fb923c;

    --color-danger: #dc2626;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-pill: 999px;

    --shadow-card: 0 2px 18px rgba(0, 0, 0, 0.06);
}


/* ===== BASE ===== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

button,
textarea,
select,
input {
    font-family: inherit;
}


/* ===== LAYOUT ===== */

.page-wrapper {
    min-height: 100vh;
    padding: 1.5rem;
}

.home-layout,
.layout {
    display: grid;
    gap: 1.5rem;
    height: calc(100vh - 3rem);
}

.home-layout {
    grid-template-columns: 1.2fr 0.8fr;
}

.layout {
    grid-template-columns: 1fr 1fr;
}

.hero-card,
.sessions-card,
.chat-panel,
.story-panel {
    overflow-y: auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.hero-card,
.sessions-card,
.chat-panel {
    padding: 2rem;
}

.story-panel {
    padding: 1.25rem;
}


/* ===== HOME ===== */

.badge {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-pill);
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
}

.hero-card h1 {
    margin-bottom: 1rem;
    font-size: 2.4rem;
    line-height: 1.1;
}

.hero-text {
    margin-bottom: 2rem;
    color: #475569;
    font-size: 1.05rem;
    line-height: 1.6;
}


/* ===== SESSION LIST ===== */

.session-list,
.question-list,
.assistant-questions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.session-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: inherit;
    text-decoration: none;
}

.session-item:hover {
    border-color: #bfdbfe;
    background: var(--color-primary-soft);
}

.session-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-end;
}

.solution-info {
    display: block;
    margin-top: 0.35rem;
    color: var(--color-muted);
    line-height: 1.4;
}


/* ===== STATUS BADGES ===== */

.status {
    height: fit-content;
    white-space: nowrap;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
}

.status.submitted {
    background: var(--color-success-light);
    color: var(--color-success);
}

.status.draft {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.status.solution {
    background: #e0f2fe;
    color: #075985;
}


/* ===== CHAT ===== */

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 260px);
    margin-bottom: 1.5rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-message.customer {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-label {
    margin-bottom: 0.35rem;
    color: var(--color-muted);
    font-size: 0.8rem;
}

.chat-bubble {
    padding: 1rem;
    border-radius: 16px;
    line-height: 1.6;
    word-break: break-word;
}

.chat-message.customer .chat-bubble {
    background: var(--color-primary-light);
}

.chat-message.assistant .chat-bubble {
    background: #f1f5f9;
}

.initial-request-box {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid #86efac;
    border-left: 5px solid #22c55e;
    border-radius: var(--radius-md);
    background: #ecfdf5;
    line-height: 1.6;
}


/* ===== NINOX SOLUTION STATUS ===== */

.solution-banner {
    margin-bottom: 0.9rem;

    padding: 0.75rem 0.9rem;

    border: 1px solid #dbe4ee;
    border-radius: 12px;

    background: #fbfcfd;
}

.solution-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 0.75rem;
}

.solution-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;

    font-size: 0.88rem;
    font-weight: 700;

    color: #0f172a;
}

.solution-dot {
    width: 10px;
    height: 10px;

    border-radius: 999px;

    background: #22c55e;

    box-shadow: 0 0 10px rgba(34,197,94,0.4);
}

.solution-name {
    padding: 0.2rem 0.5rem;

    border: 1px solid #dbe4ee;
    border-radius: 999px;

    background: white;

    font-size: 0.72rem;
    font-weight: 600;

    color: #334155;
}

.solution-grid {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 0.45rem;
}

.solution-item {
    padding: 0.45rem 0.55rem;

    border: 1px solid #edf2f7;
    border-radius: 8px;

    background: white;
}

.solution-label {
    display: block;

    margin-bottom: 0.18rem;

    color: #64748b;

    font-size: 0.6rem;

    letter-spacing: 0.05em;

    text-transform: uppercase;
}

.solution-value {
    font-size: 0.82rem;
    font-weight: 700;

    color: #0f172a;
}

.solution-ok {
    color: #16a34a;
}

.solution-error {
    color: #dc2626;
}


/* ===== LIVE STORY COMPACT ===== */

.story-panel h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.story-panel h3 {
    margin-bottom: 0.6rem;
    font-size: 1.15rem;
    line-height: 1.3;
}

.story-panel h4 {
    margin-top: 1.15rem;
    margin-bottom: 0.45rem;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 700;
}

.story-panel p {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.story-panel ul {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
    padding-left: 1rem;
}

.story-panel li {
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.35;
}

.story-box {
    margin-top: 0.4rem;
    margin-bottom: 0.75rem;
    padding: 0.85rem;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    background: var(--color-primary-soft);
    line-height: 1.5;
}

.submitted-note {
    color: var(--color-success);
    font-weight: 600;
}

/* ===== AI CONTEXT ===== */

.context-box {
    margin-bottom: 1rem;

    padding: 0.75rem 0.9rem;

    border: 1px solid #dbe4ee;
    border-radius: 12px;

    background: #fbfcfd;
}

.context-title {
    margin-bottom: 0.6rem;

    color: #64748b;

    font-size: 0.72rem;
    font-weight: 700;

    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.context-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.context-tag {
    padding: 0.3rem 0.55rem;

    border: 1px solid #dbe4ee;
    border-radius: 999px;

    background: white;

    color: #334155;

    font-size: 0.74rem;
    font-weight: 600;
}


.context-stats {
    margin-top: 0.65rem;

    color: #64748b;

    font-size: 0.72rem;

    line-height: 1.4;
}

/* ===== AI QUALITY ===== */


.top-context-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.ai-quality-box,
.context-box {
    height: 100%;
}
.ai-quality-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    line-height: 1.4;
}

.ai-quality-box p {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
}

.ai-quality-box.complete {
    border: 1px solid var(--color-success-border);
    background: var(--color-success-soft);
    color: var(--color-success);
}

.ai-quality-box.incomplete {
    border: 1px solid var(--color-warning-border);
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.confidence-pill {
    min-width: 56px;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-pill);
    background: white;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
}


/* ===== QUESTIONS ===== */

.question-box {
    margin-top: 1rem;
    padding: 0.8rem;
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-md);
    background: var(--color-warning-soft);
}

.question-card,
.assistant-question-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.7rem;
    border-radius: 12px;
    background: var(--color-surface);
}

.question-card {
    border: 1px solid #fdba74;
}

.assistant-question-card {
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
}

.question-number,
.assistant-question-number {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-pill);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
}

.question-number {
    background: var(--color-warning-accent);
}

.assistant-question-number {
    background: var(--color-primary);
}


/* ===== TYPING / LOADING ===== */

.typing-bubble {
    border: 1px solid var(--color-border-light);
    background: var(--color-bg);
}

.typing-row,
.loading-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.typing-spinner,
.spinner {
    flex-shrink: 0;
    border-radius: var(--radius-pill);
    animation: spin 0.8s linear infinite;
}

.typing-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
}

.loading-box {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    background: var(--color-primary-soft);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 4px solid #bfdbfe;
    border-top-color: var(--color-primary);
}

.hidden {
    display: none !important;
}


/* ===== FORMS / BUTTONS ===== */

textarea,
select {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: white;
    color: var(--color-text);
    font-size: 1rem;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

textarea:focus,
select:focus,
input:focus {
    outline: 2px solid var(--color-primary-light);
    border-color: var(--color-primary);
}

select {
    cursor: pointer;
}

select:hover {
    border-color: var(--color-primary);
}

.wish-form p {
    margin-bottom: 1.25rem;
}

.wish-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    font-weight: 700;
}

button,
.secondary-button,
.primary-link-button {
    display: inline-block;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
}

button {
    margin-top: 1rem;
    border: none;
    background: var(--color-primary);
    color: white;
    cursor: pointer;
}

button:hover,
.primary-link-button:hover {
    background: var(--color-primary-dark);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.secondary-button {
    border: 1px solid var(--color-border);
    background: white;
    color: var(--color-text);
}

.primary-link-button {
    background: var(--color-primary);
    color: white;
}


/* ===== SUBMITTED STATE ===== */

.submitted-box {
    margin-top: 1rem;
    padding: 0.9rem;
    border: 1px solid var(--color-success-border);
    border-radius: var(--radius-md);
    background: var(--color-success-soft);
    color: var(--color-success);
}

.submitted-box p {
    margin: 0.35rem 0 0;
}

.submitted-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}


/* ===== Effort estimation ===== */
.effort-box {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #dbe4ee;
    border-radius: 12px;
    background: #fbfcfd;
}

.effort-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.effort-label {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--color-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.effort-confidence {
    min-width: 56px;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-pill);
    background: white;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.effort-box p {
    margin: 0.55rem 0 0;
    color: #334155;
    font-size: 0.9rem;
    line-height: 1.45;
}

.effort-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.65rem;
}

.effort-tags span {
    padding: 0.25rem 0.5rem;
    border: 1px solid #dbe4ee;
    border-radius: var(--radius-pill);
    background: white;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 600;
}


.app-header {
    height: 64px;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-bottom: 1px solid var(--color-border-light);
}

.app-logo {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 800;
}

.app-nav {
    display: flex;
     align-items: center;
    gap: 1rem;
}

.app-nav a,
.back-link {
    color: var(--color-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.app-nav a:hover,
.back-link:hover {
    color: var(--color-primary);
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
}

.page-wrapper {
    min-height: calc(100vh - 64px);
    padding: 1.5rem;
}

.home-layout,
.layout {
    height: calc(100vh - 64px - 3rem);
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background:
        radial-gradient(circle at top, #dbeafe 0, transparent 32%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    padding: 2.25rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 24px 70px rgba(15, 23, 42, 0.12),
        0 2px 10px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(12px);
}

.auth-card h1 {
    margin-bottom: 0.6rem;
    font-size: 1.8rem;
    line-height: 1.15;
}

.auth-subtitle {
    margin-bottom: 1.75rem;
    color: var(--color-muted);
    line-height: 1.55;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-field label {
    display: block;
    margin-bottom: 0.45rem;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.auth-input {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid #dbe4ee;
    border-radius: 14px;
    background: #fbfcfd;
    color: var(--color-text);
    font-size: 1rem;
}

.auth-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.auth-button {
    width: 100%;
    margin-top: 0.5rem;
}


.auth-error {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    margin-bottom: 1rem;
    padding: 0.85rem 1rem;

    border: 1px solid #fecaca;
    border-left: 4px solid var(--color-danger);
    border-radius: 14px;

    background: #fef2f2;
    color: #991b1b;

    font-size: 0.9rem;
}

.auth-error strong {
    font-size: 0.9rem;
}

.auth-error span {
    color: #7f1d1d;
}


.logout-form {
    display: flex;
    align-items: center;
    margin: 0;
}

.logout-button {
    margin: 0;
    padding: 0;

    border: none;
    background: none;

    appearance: none;
    -webkit-appearance: none;

    color: var(--color-muted);

    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;

    cursor: pointer;

    transition: color 0.2s ease;
}

.logout-button:hover {
    color: var(--color-primary);
    background: none;
}

.logout-button:focus,
.logout-button:active {
    outline: none;
    box-shadow: none;
    background: none;
}


/* ===== ANIMATIONS ===== */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ===== RESPONSIVE ===== */

@media (max-width: 1100px) {
    .home-layout,
    .layout {
        grid-template-columns: 1fr;
        height: auto;
    }
 .top-context-grid {
        grid-template-columns: 1fr;
    }
    .chat-history {
        max-height: none;
    }
}