/* ================== Perusasetukset ================== */
* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family:'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height:100vh;
    display:flex;
    justify-content:center;
    align-items:flex-start;
    background:radial-gradient(circle at 20% 20%, rgba(76,110,245,0.25), transparent 25%),
               radial-gradient(circle at 80% 0%, rgba(9,175,230,0.2), transparent 25%),
               linear-gradient(135deg,#0d1b2a,#0f2742);
    color:#0a0f1a;
    padding:40px 20px 60px;
}

.shell {
    width:100%;
    max-width:1080px;
    display:flex;
    flex-direction:column;
    gap:18px;
    height:calc(100vh - 80px);
    overflow:hidden;
}

.topbar {
    display:flex;
    align-items:center;
    justify-content:space-between;
    background:rgba(12,22,40,0.75);
    color:white;
    padding:16px 20px;
    border-radius:14px;
    border:1px solid rgba(255,255,255,0.08);
    box-shadow:0 12px 35px rgba(0,0,0,0.35);
    backdrop-filter: blur(12px);
    gap:12px;
}
.brand { display:flex; align-items:center; gap:12px; }
.logo-icon { font-size:2.1rem; }
.titles h1 { font-size:1.6rem; margin:0; }
.subtitle { margin:2px 0 0; color:rgba(255,255,255,0.85); font-size:0.95rem; }

.header-actions {
    display:flex;
    gap:8px;
    align-items:center;
}
.header-actions select, .header-actions button {
    background:rgba(255,255,255,0.08);
    border:1px solid rgba(255,255,255,0.12);
    color:white;
    padding:6px 10px;
    border-radius:8px;
    cursor:pointer;
    transition:all 0.15s;
}
.header-actions select { font-size:0.95rem; }
.header-actions button { font-size:1.05rem; }
.header-actions button:hover, .header-actions select:hover {
    background:rgba(255,255,255,0.18);
    transform:scale(1.03);
}

.hero {
    background:linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.86));
    border-radius:16px;
    padding:24px;
    box-shadow:0 12px 30px rgba(0,0,0,0.18);
    display:flex;
    justify-content:space-between;
    gap:16px;
    border:1px solid rgba(12,22,40,0.08);
}
.hero-text h2 { margin:0 0 8px; font-size:1.4rem; color:#0d2742; }
.hero-text p { margin:0; color:#243447; line-height:1.5; }
.privacy-cta {
    display:inline-block;
    margin-top:12px;
    padding:10px 14px;
    background:#0d2742;
    color:#fff;
    border-radius:10px;
    font-weight:700;
    text-decoration:none;
    box-shadow:0 6px 16px rgba(0,0,0,0.22);
}
.privacy-cta:hover { opacity:0.92; transform:translateY(-1px); }
.hero-badges { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.hero-badges span {
    background:#0f2742;
    color:white;
    padding:8px 12px;
    border-radius:12px;
    font-size:0.9rem;
    box-shadow:0 4px 12px rgba(0,0,0,0.18);
}

.panel {
    background:rgba(255,255,255,0.95);
    border-radius:16px;
    box-shadow:0 16px 40px rgba(0,0,0,0.25);
    border:1px solid rgba(12,22,40,0.08);
    overflow:hidden;
    display:flex;
    flex-direction:column;
    flex:1;
    min-height:0;
}

.chat {
    flex:1;
    overflow-y:auto;
    overflow-x:hidden;
    padding:20px;
    background:#f7f9fc;
    color:#000;
    display:flex;
    flex-direction:column;
    gap:10px;
    min-height:0;
}

.controls {
    display:grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap:12px;
    background:rgba(255,255,255,0.9);
    border:1px solid rgba(12,22,40,0.08);
    border-radius:12px;
    padding:12px;
    box-shadow:0 10px 24px rgba(0,0,0,0.15);
}
.controls label { display:block; font-weight:600; margin-bottom:4px; color:#0d2742; }
.controls input, .controls select { width:100%; padding:8px 10px; border:1px solid #d8deea; border-radius:8px; font-size:0.95rem; }
.controls button { border-radius:10px; padding:10px 12px; background:var(--accent, #4c6ef5); color:#fff; border:none; cursor:pointer; font-weight:600; }
.controls button:hover { opacity:0.95; }
.message {
    padding:14px 18px;
    border-radius:20px;
    max-width:80%;
    line-height:1.5;
    word-wrap:break-word;
    opacity:0;
    transform:translateY(10px);
    transition: all 0.3s;
    display:flex;
    flex-direction:column;
    gap:8px;
}
.message.show { opacity:1; transform:translateY(0); }
.user {
    background: rgba(25,118,210,0.85);
    color:white;
    margin-left:auto;
    border-bottom-right-radius:4px;
    box-shadow:0 2px 6px rgba(0,0,0,0.2);
}
.kalle {
    background:#e0f7fa;
    color:#0d47a1;
    margin-right:auto;
    border-bottom-left-radius:4px;
    box-shadow:0 2px 6px rgba(0,0,0,0.2);
}
.message:hover { box-shadow:0 4px 10px rgba(0,0,0,0.2); }
.message strong { margin-right:6px; }
.message .text {
    display:block;
    word-break:break-word;
    white-space:pre-wrap;
}

/* Code blocks */
.message .text pre {
    background:#0b1e3b;
    color:#e6f1ff;
    padding:12px;
    border-radius:8px;
    overflow-x:auto;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.message .text code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size:0.92rem;
    line-height:1.5;
}
.message .text a {
    color:#1976d2;
    text-decoration:underline;
}

/* Code block with copy button */
.code-block-wrapper {
    position:relative;
    margin:8px 0;
}
.copy-code-btn {
    position:absolute;
    top:8px;
    right:8px;
    background:rgba(255,255,255,0.9);
    border:1px solid rgba(0,0,0,0.1);
    padding:6px 10px;
    border-radius:6px;
    cursor:pointer;
    font-size:1rem;
    transition:all 0.2s;
    opacity:0.7;
}
.copy-code-btn:hover {
    opacity:1;
    background:white;
    transform:scale(1.05);
}

/* Loading animation */
.typing-indicator {
    display:inline-flex;
    gap:4px;
    align-items:center;
}
.typing-indicator span {
    width:8px;
    height:8px;
    background:#0d47a1;
    border-radius:50%;
    animation:typing-bounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) {
    animation-delay:0.2s;
}
.typing-indicator span:nth-child(3) {
    animation-delay:0.4s;
}
@keyframes typing-bounce {
    0%, 60%, 100% { transform:translateY(0); }
    30% { transform:translateY(-10px); }
}

/* Dark mode */
body.dark-mode {
    background:linear-gradient(135deg,#0a0e1a,#1a1f2e);
}
body.dark-mode .panel {
    background:rgba(30,35,50,0.95);
}
body.dark-mode .chat {
    background:#1a1f2e;
}
body.dark-mode .kalle {
    background:#2a3f5f;
    color:#e0f7fa;
}
body.dark-mode form {
    background:#1a1f2e;
    border-top:1px solid #2a3f5f;
}
body.dark-mode input[type="text"] {
    background:#2a3f5f;
    color:white;
    border-color:#3a5f8f;
}
body.dark-mode .controls {
    background:rgba(30,35,50,0.9);
}
body.dark-mode .hero {
    background:rgba(30,35,50,0.9);
    color:#e0e7ff;
}
body.dark-mode .hero-text h2 {
    color:#e0e7ff;
}
body.dark-mode .hero-text p {
    color:#b8c5d0;
}

form {
    display:flex;
    padding:15px;
    background:#fff;
    border-top:1px solid #eee;
    gap:12px;
}
input[type="text"] {
    flex:1;
    padding:14px 18px;
    border:2px solid #d8deea;
    border-radius:14px;
    font-size:1rem;
    outline:none;
    transition:border 0.3s, box-shadow 0.3s;
}
input[type="text"]:focus {
    border-color:#4c6ef5;
    box-shadow:0 0 0 3px rgba(76,110,245,0.2);
}
button {
    padding:14px 20px;
    background:linear-gradient(135deg,#4c6ef5,#2fb7ec);
    color:white;
    border:none;
    border-radius:12px;
    font-weight:bold;
    cursor:pointer;
    transition:background 0.3s, transform 0.1s;
}
button:hover { background:#1565c0; }
button:active { transform:translateY(1px); }

/* Footer */
footer {
    text-align:center;
    padding:10px;
    font-size:0.9rem;
    color:#333;
    border-top:1px solid #eee;
    background:#f0f0f0;
}
footer a {
    color:#1976d2;
    text-decoration:none;
}
footer a:hover {
    text-decoration:underline;
}

/* Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1976d2;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
    align-self:flex-start;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Settings paneeli */
.settings {
    position:absolute;
    top:20px;
    left:20px;
    background: rgba(255,255,255,0.9);
    border:1px solid #ddd;
    border-radius:10px;
    padding:10px;
    display:flex;
    flex-direction:column;
    gap:8px;
    box-shadow:0 4px 15px rgba(0,0,0,0.2);
}
.settings label { 
    font-size:0.9rem; 
    font-weight:bold;
    margin-top:8px;
}
.settings input[type="color"],
.settings input[type="number"] {
    width:100%;
    padding:6px;
    border:1px solid #ddd;
    border-radius:4px;
}

.chat::-webkit-scrollbar { width:8px; }
.chat::-webkit-scrollbar-track { background:#f0f0f0; }
.chat::-webkit-scrollbar-thumb { background:#1976d2; border-radius:4px; }

.knowledge-indicator {
    display:flex;
    align-items:center;
    gap:6px;
    font-size:0.95rem;
    padding:6px 12px;
    background:rgba(255,255,255,0.16);
    border-radius:12px;
    animation:pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity:1; }
    50% { opacity:0.7; }
}

/* Responsive */
@media (max-width: 768px) {
    body { 
        padding:10px 5px;
    }
    
    .shell {
        gap:8px;
        height:calc(100vh - 20px);
    }
    
    /* Pienennä header mobiilissa */
    .topbar { 
        padding:10px 12px;
        flex-wrap:wrap;
        gap:8px;
    }
    
    .brand {
        flex:1;
        min-width:0;
    }
    
    .logo-icon { 
        font-size:1.5rem; 
    }
    
    .titles h1 { 
        font-size:1.1rem; 
    }
    
    .subtitle { 
        font-size:0.8rem;
        display:none;
    }
    
    .knowledge-indicator { 
        font-size:0.75rem;
        width:100%;
        order:3;
    }
    
    .header-actions {
        gap:6px;
    }
    
    .header-actions button {
        padding:6px 10px;
        font-size:1rem;
    }
    
    /* Näytä hero-osio mobiilissa jotta chat ei täytä koko ruutua */
    .hero {
        display:block;
    }
    
    /* Chatti täyttää lähes koko ruudun */
    .panel {
        flex:0 0 auto;
        min-height:60vh;
        border-radius:12px;
        max-width:600px;
        width:100%;
        margin:0 auto;
    }
    
    .chat {
        padding:10px;
        gap:8px;
    }
    
    /* Viestit isommat */
    .message {
        max-width:95%;
        padding:10px 12px;
        font-size:14px;
        line-height:1.55;
    }
    
    .message strong {
        font-size:13px;
    }
    
    /* Input-kenttä isompi */
    form {
        padding:10px;
        gap:8px;
    }
    
    input[type="text"] {
        padding:10px 12px;
        font-size:16px; /* pidä 16px estääksesi iOS-zoomin */
        border-radius:12px;
    }
    
    button {
        padding:10px 14px;
        font-size:14px;
        border-radius:10px;
    }
    
    /* Piilota kontrollit mobiilissa */
    .controls {
        display:none;
    }
    
    footer {
        padding:8px;
        font-size:0.75rem;
    }
    
    .message .text pre {
        font-size:13px;
        padding:10px;
        overflow-x:auto;
    }
    
    .copy-code-btn {
        font-size:0.9rem;
        padding:4px 8px;
    }
}
