/* ==========================================================================
   Citypopulation Scraper – Moderne Light-Mode Ästhetik
   Design: Minimalistisch, Premium, Responsive
   ========================================================================== */

:root {
    /* Colors - Modern Indigo/Slate Palette */
    --bg-main: #F9FAFB;
    --bg-card: #FFFFFF;
    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --border-focus: #2563EB;

    /* Status Colors */
    --success: #10B981;
    --error: #EF4444;
    --warn: #F59E0B;
    --info: #3B82F6;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* Layout */
    --radius: 8px;
    --container-width: 640px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.app-wrapper {
    width: 100%;
    max-width: var(--container-width);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Header --- */
.app-header {
    text-align: center;
    margin-bottom: 40px;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow);
}

.card__label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.step {
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* --- Inputs --- */
.input-field {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #FFFFFF;
    color: var(--text-main);
    transition: all 0.2s;
    outline: none;
}

.input-field:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.file-upload-area {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px dashed var(--border);
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s;
}

.file-upload-area:hover {
    border-color: var(--accent);
}

.file-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-btn {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
}

.file-name {
    font-size: 0.875rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-clear-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 10;
}

.file-clear-btn.visible {
    display: block;
}

/* --- Buttons --- */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* --- Console & SSE Logs --- */
.console-wrapper {
    display: none;
    margin-top: 32px;
}

.console-wrapper.visible {
    display: block;
}

.console-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
}

.dot.idle {
    background: var(--text-muted);
}

.console {
    background: #FFFFFF;
    color: var(--text-main);
    padding: 16px;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.log-line {
    margin-bottom: 6px;
    word-break: break-all;
    padding-bottom: 4px;
    border-bottom: 1px f7f7f7;
}

.log-line.success {
    color: #059669;
    font-weight: 600;
}

/* Dunkleres Grün */
.log-line.error {
    color: #DC2626;
    font-weight: 600;
}

/* Kräftiges Rot */
.log-line.warn {
    color: #D97706;
}

/* Dunkleres Orange */
.log-line.info {
    color: var(--text-muted);
}

/* --- Download Bar --- */
.download-bar {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background: #ECFDF5;
    border: 1px solid #A7F3D0;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideUp 0.3s ease-out;
}

.download-bar:not(.visible) {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.download-bar__text {
    font-weight: 600;
    color: #065F46;
}

.download-bar__btn {
    background: var(--success);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.download-bar__btn:hover {
    opacity: 0.9;
}

/* --- Loading Spinner --- */
.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: rotate 0.8s linear infinite;
}

.btn-primary.loading .spinner {
    display: block;
}

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

/* --- Mobile --- */
@media (max-width: 480px) {
    body {
        padding: 20px 10px;
    }

    .card {
        padding: 20px;
    }

    .download-bar {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}