/* --- Root Variables: Modern Color Palette --- */
:root {
    /* Neutrals & Surfaces */
    --bg-main: #F8FAFC; /* Sangat terang, abu-abu kebiruan halus */
    --bg-surface: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --border-subtle: #E2E8F0;
    --border-focus: #4F46E5; /* Indigo */

    /* Text & Hierarchy */
    --text-primary: #1E293B; /* Hampir hitam, tapi lebih lembut */
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    /* Accents & Brand */
    --accent-primary: #4F46E5; /* Modern Indigo */
    --accent-hover: #4338CA;
    --accent-soft: rgba(79, 70, 229, 0.1);
    
    /* Semantic Colors */
    --success: #10B981; /* Emerald */
    --warning: #F59E0B; /* Amber */
    --danger: #EF4444; /* Red */
    --neutral: #64748B; /* Slate */

    /* Shadows & Radii */
    --shadow-subtle: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    /* Transition */
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-main: #0F172A;
    --bg-surface: #1E293B;
    --bg-sidebar: #1E293B;
    --border-subtle: #334155;
    --border-focus: #818CF8;

    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;

    --accent-primary: #818CF8;
    --accent-hover: #A5B4FC;
    --accent-soft: rgba(129, 140, 248, 0.1);

    --shadow-subtle: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.2);
}

/* --- Welcome Overlay Styles --- */
.editor-section {
    position: relative; /* Penting agar overlay bisa menempel di sini */
}

.welcome-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px; /* Jarak agar tidak menutupi tombol bawah */
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Agar user bisa klik tembus ke textarea di bawahnya */
    transition: opacity 0.4s var(--ease-in-out), transform 0.4s var(--ease-in-out);
    padding: 40px;
    z-index: 10;
}

.overlay-content {
    max-width: 600px;
    text-align: center;
    background: var(--bg-surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.overlay-header h2 {
    color: var(--accent-primary);
    margin-bottom: 10px;
}

.overlay-header p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.overlay-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    text-align: left;
}

.info-item h4 {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.info-item p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.info-icon {
    font-size: 1.5rem;
    margin-bottom: 10px;
    display: block;
}

.start-typing {
    margin-top: 30px;
    font-weight: 600;
    color: var(--accent-primary);
    animation: pulse 2s infinite;
}

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

/* Class untuk menyembunyikan overlay */
.overlay-hidden {
    opacity: 0;
    transform: translateY(-20px);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: background 0.3s var(--ease-in-out), color 0.3s var(--ease-in-out);
}

/* --- Header & Navigation --- */
.main-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-subtle);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.optimizer-text {
    color: var(--accent-primary);
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.pilot-project {
    background: var(--accent-soft);
    color: var(--accent-primary);
}

.btn-theme {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg-main);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s var(--ease-in-out);
}

.btn-theme:hover {
    background: var(--border-subtle);
    color: var(--text-primary);
}

/* --- Main Layout --- */
.main-container {
    flex: 1;
    display: flex;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    gap: 24px;
    overflow: hidden;
}

/* --- Editor Section --- */
.editor-section {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

textarea {
    flex: 1;
    padding: 24px;
    font-family: 'Inter', monospace; /* Modern monospace */
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-subtle);
}

textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-action {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-action:hover {
    background: var(--accent-hover);
}

.btn-icon {
    opacity: 0.8;
}

/* --- Sidebar --- */
.sidebar {
    flex: 1;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

/* --- Stat Cards --- */
.stat-card {
    padding: 16px;
    background: rgba(var(--text-muted), 0.05);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
}

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

.stat-icon {
    color: var(--accent-primary);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 700;
    line-height: 1.2;
}

.main-value {
    font-size: 2rem;
    color: var(--text-primary);
}

.secondary-value {
    font-size: 1rem;
    color: var(--text-muted);
}

.unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* --- Modern Keyword Input --- */
.keyword-finder-card {
    background: var(--accent-soft);
    border-color: rgba(79, 70, 229, 0.1);
}

.keyword-input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 10px;
    font-family: inherit;
    font-size: 0.875rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.keyword-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* --- Semantic Alerts --- */
.alert {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}

.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border-color: rgba(16, 185, 129, 0.2); }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border-color: rgba(245, 158, 11, 0.2); }
.alert-neutral { background: rgba(148, 163, 184, 0.1); color: var(--neutral); border-color: rgba(148, 163, 184, 0.2); }

/* --- Progress Indicators --- */
.indicator-container {
    margin-top: 10px;
}

.indicator-track {
    height: 6px;
    background: rgba(var(--text-muted), 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.indicator-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.3s var(--ease-in-out), background 0.3s;
}

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

@media (max-width: 768px) {

    body {
        height: auto;
    }

    .main-header {
        padding: 14px 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    h1 {
        font-size: 1.1rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .btn-theme {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .main-container {
        flex-direction: column;
        padding: 14px;
        gap: 16px;
        overflow: visible;
    }

    .editor-section {
        width: 100%;
    }

    textarea {
        min-height: 420px;
        padding: 18px;
        font-size: 0.95rem;
        line-height: 1.7;
        border-radius: 18px;
    }

    .editor-actions {
        justify-content: stretch;
    }

    .btn-action {
        width: 100%;
        justify-content: center;
        padding: 14px;
        border-radius: 14px;
        font-size: 0.9rem;
    }

    /* SIDEBAR JADI GRID MOBILE */
    .sidebar {
        width: 100%;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;

        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .stat-card {
        padding: 16px;
        border-radius: 18px;
        background: var(--bg-surface);
        border: 1px solid var(--border-subtle);
        box-shadow: var(--shadow-subtle);
    }

    .keyword-finder-card {
        grid-column: span 2;
    }

    .main-value {
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    /* OVERLAY MOBILE */
    .welcome-overlay {
        padding: 16px;
        bottom: -300px;
    }

    .overlay-content {
        padding: 24px 18px;
        border-radius: 20px;
    }

    .overlay-header h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .overlay-header p {
        font-size: 0.9rem;
    }

    .overlay-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .info-item {
        text-align: left;
    }

    .start-typing {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

/* EXTRA SMALL DEVICES */
@media (max-width: 480px) {

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

    .keyword-finder-card {
        grid-column: span 1;
    }

    textarea {
        min-height: 380px;
    }

    .main-value {
        font-size: 1.6rem;
    }

    .overlay-content {
        padding: 20px 16px;
    }

    .overlay-header h2 {
        font-size: 1.3rem;
    }
}

.fill-neutral { background: var(--neutral); }
.fill-success { background: var(--success); }
.fill-warning { background: var(--warning); }