/* ===== BASE THEME ===== */
body {
    margin: 0;
    background: #050b10;
    color: #f5f5f5;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== HEADER ===== */
header h1 {
    margin: 0;
    padding: 0;
    font-size: 1.5rem;
}

.subtitle {
    color: #9ca3af;
    font-size: 0.9rem;
}

/* ===== MINI STATUSBALK ===== */
#mini-status {
    margin-top: 6px;
    padding: 4px 0;
    font-size: 0.78rem;
    color: #8fa3b1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.light.green { background: #16d45c; }
.light.orange { background: #f5a623; }
.light.grey { background: #6b7280; }

#repair-msg {
    color: #16d45c;
    font-size: 0.75rem;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.chat-panel {
    flex: 1;
}

/* ===== CHAT ===== */
.chat-log {
    border: 1px solid #111827;
    border-radius: 8px;
    padding: 8px;
    background: #020617;
    overflow-y: auto;
    min-height: 300px;
    max-height: 500px;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.chat-line {
    margin-bottom: 6px;
    padding: 4px 8px;
    border-radius: 4px;
}

.chat-line.user strong { color: #38bdf8; }
.chat-line.soul strong { color: #a855f7; }

/* Auth states */
.chat-line.hidden-answer {
    background: rgba(56, 189, 248, 0.1);
    color: #64748b;
    font-style: italic;
}
.chat-line.hidden-answer::before { content: "🔒 "; }
.chat-line.challenge {
    background: rgba(245, 166, 35, 0.15);
    border-left: 3px solid #f5a623;
}
.chat-line.auth-success {
    background: rgba(22, 212, 92, 0.15);
    border-left: 3px solid #16d45c;
}

/* Links in chat berichten */
.chat-line a {
    color: #60a5fa;
    text-decoration: underline;
    word-break: break-all;
}
.chat-line a:hover {
    color: #93c5fd;
    text-decoration: none;
}
.chat-line a:visited {
    color: #a78bfa;
}

/* ===== INPUT ===== */
#chat-input {
    width: 100%;
    background: #020617;
    border: 1px solid #111827;
    padding: 8px;
    border-radius: 8px;
    color: #f9fafb;
    resize: vertical;
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
}

#chat-input.password-mode {
    border-color: #f5a623;
    background: #0a0a0f;
}

#chat-input:focus {
    outline: none;
    border-color: #38bdf8;
}

/* ===== CHAT ACTIONS ===== */
.chat-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

button {
    background: #38bdf8;
    border: none;
    color: #020617;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

button:hover { background: #0ea5e9; }
button:disabled { background: #4b5563; cursor: not-allowed; }

/* Icon button (screenshot) */
.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    padding: 0;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.icon-btn:hover {
    background: #334155;
    border-color: #38bdf8;
}

/* Badge */
.badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== PASTE PREVIEW ===== */
.paste-preview {
    margin-top: 12px;
    padding: 12px;
    background: #0f172a;
    border: 2px dashed #334155;
    border-radius: 8px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: #94a3b8;
    font-size: 0.9rem;
}

.cancel-btn, .close-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: 4px;
}

.cancel-btn:hover, .close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

#paste-image {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
    margin-bottom: 8px;
    display: block;
}

.paste-actions {
    display: flex;
    gap: 8px;
}

#paste-question {
    flex: 1;
    padding: 8px;
    background: #020617;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #f9fafb;
    font-size: 0.9rem;
}

#paste-question:focus {
    outline: none;
    border-color: #38bdf8;
}

.send-paste-btn {
    background: #8b5cf6;
    white-space: nowrap;
}

.send-paste-btn:hover { background: #7c3aed; }

/* ===== SCREENSHOT PANEL ===== */
.screenshot-panel {
    width: 400px;
    max-height: 600px;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #1e293b;
    background: #1e293b;
}

.panel-header h2 {
    margin: 0;
    font-size: 1rem;
}

.panel-actions {
    padding: 8px 16px;
    border-bottom: 1px solid #1e293b;
}

.danger-btn {
    background: #dc2626;
    font-size: 0.8rem;
    padding: 4px 10px;
}

.danger-btn:hover { background: #b91c1c; }

/* Screenshot list */
.screenshot-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.empty-state, .error-state {
    text-align: center;
    color: #64748b;
    padding: 24px;
    font-size: 0.9rem;
}

.error-state { color: #ef4444; }

/* Screenshot item */
.screenshot-item {
    background: #1e293b;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}

.screenshot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.screenshot-thumb {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    background: #020617;
}

.screenshot-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.screenshot-time {
    font-size: 0.75rem;
    color: #94a3b8;
}

.screenshot-status {
    font-size: 0.8rem;
}

.screenshot-status.completed { color: #16d45c; }
.screenshot-status.processing { color: #f5a623; }
.screenshot-status.error { color: #ef4444; }

.delete-screenshot-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.6;
}

.delete-screenshot-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.2);
    border-radius: 4px;
}

.screenshot-question {
    font-size: 0.85rem;
    color: #38bdf8;
    margin-bottom: 8px;
    padding: 4px 8px;
    background: rgba(56, 189, 248, 0.1);
    border-radius: 4px;
}

.screenshot-analysis {
    font-size: 0.85rem;
    color: #e2e8f0;
    line-height: 1.4;
    white-space: pre-wrap;
}

.screenshot-processing {
    font-size: 0.85rem;
    color: #f5a623;
    font-style: italic;
}

.screenshot-ocr {
    margin-top: 8px;
}

.screenshot-ocr summary {
    font-size: 0.8rem;
    color: #8b5cf6;
    cursor: pointer;
}

.screenshot-ocr summary:hover { color: #a78bfa; }

.screenshot-ocr pre {
    font-size: 0.75rem;
    background: #020617;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

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

/* Tablet */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }
    
    .screenshot-panel {
        width: 100%;
        max-height: 400px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    #app {
        padding: 8px;
        padding-bottom: 80px; /* Ruimte voor input */
    }
    
    header h1 {
        font-size: 1.2rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    #mini-status {
        font-size: 0.7rem;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* Chat neemt hele scherm */
    .chat-panel {
        width: 100%;
    }
    
    .chat-panel h2 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    /* Chat log vult beschikbare ruimte */
    .chat-log {
        min-height: 200px;
        max-height: calc(100vh - 280px);
        font-size: 0.85rem;
        padding: 6px;
    }
    
    .chat-line {
        padding: 6px;
        margin-bottom: 8px;
    }
    
    /* Input area fixed aan onderkant */
    #chat-form {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #050b10;
        padding: 8px;
        border-top: 1px solid #1e293b;
        z-index: 50;
    }
    
    #chat-input {
        font-size: 16px; /* Voorkomt zoom op iOS */
        padding: 12px;
        min-height: 44px;
        border-radius: 12px;
    }
    
    .chat-actions {
        margin-top: 6px;
        gap: 6px;
    }
    
    /* Grotere buttons voor touch */
    button {
        min-height: 44px;
        padding: 10px 18px;
        font-size: 1rem;
    }
    
    .icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
    
    /* Paste preview responsive */
    .paste-preview {
        position: fixed;
        bottom: 70px;
        left: 8px;
        right: 8px;
        z-index: 60;
        max-height: 200px;
        overflow-y: auto;
    }
    
    #paste-image {
        max-height: 80px;
    }
    
    .paste-actions {
        flex-direction: column;
        gap: 6px;
    }
    
    #paste-question {
        font-size: 16px;
        padding: 10px;
    }
    
    .send-paste-btn {
        width: 100%;
        min-height: 44px;
    }
    
    /* Screenshot panel fullscreen op mobiel */
    .screenshot-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: none;
        border-radius: 0;
        z-index: 100;
    }
    
    .panel-header {
        padding: 16px;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .panel-header h2 {
        font-size: 1.1rem;
    }
    
    .close-btn {
        font-size: 1.5rem;
        padding: 8px 12px;
    }
    
    .panel-actions {
        padding: 12px 16px;
    }
    
    .danger-btn {
        min-height: 40px;
        font-size: 0.9rem;
    }
    
    .screenshot-list {
        padding: 12px;
    }
    
    .screenshot-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .screenshot-thumb {
        width: 70px;
        height: 50px;
    }
    
    .screenshot-analysis {
        font-size: 0.9rem;
    }
    
    .delete-screenshot-btn {
        padding: 8px;
        font-size: 1.2rem;
    }
}

/* Extra kleine schermen */
@media (max-width: 380px) {
    #app {
        padding: 4px;
    }
    
    header h1 {
        font-size: 1rem;
    }
    
    .chat-log {
        max-height: calc(100vh - 300px);
        font-size: 0.8rem;
    }
    
    #chat-input {
        padding: 10px;
    }
    
    button {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
}

/* Landscape mode op mobiel */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-log {
        min-height: 100px;
        max-height: calc(100vh - 150px);
    }
    
    #chat-form {
        position: relative;
        border-top: none;
    }
    
    .paste-preview {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
    }
}

/* Safe area insets voor notch devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #chat-form {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    
    .screenshot-panel {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===== STATUS MESSAGES (SSE) ===== */
.status-message {
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 8px;
    font-style: italic;
    animation: pulse 2s infinite;
}

.status-message em {
    font-style: normal;
}

.status-message small {
    display: block;
    margin-top: 4px;
    opacity: 0.8;
    font-size: 0.85em;
}

.status-warmup {
    background: linear-gradient(135deg, #1e3a5f 0%, #0d2137 100%);
    border-left: 3px solid #f5a623;
    color: #ffd78a;
}

.status-success {
    background: linear-gradient(135deg, #1a3d2e 0%, #0d2118 100%);
    border-left: 3px solid #16d45c;
    color: #7eeaa8;
    animation: none;
}

.status-error {
    background: linear-gradient(135deg, #3d1a1a 0%, #210d0d 100%);
    border-left: 3px solid #e74c3c;
    color: #f5a5a5;
    animation: none;
}

.status-processing {
    background: linear-gradient(135deg, #2d1e5f 0%, #170d37 100%);
    border-left: 3px solid #9b59b6;
    color: #d4a5f5;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
