/* ========================================== */
/* 1. BASE VARIABLES & CSS RESET              */
/* ========================================== */
:root {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --border: #e5e7eb;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column; 
    align-items: center;    
    padding: 20px;
    min-height: 100vh;
    line-height: 1.5;
}

/* ========================================== */
/* 2. MAIN LAYOUT & HEADERS                   */
/* ========================================== */
.container {
    width: 100%;
    max-width: 800px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.site-header {
    text-align: center;
    background: transparent;
    box-shadow: none;
    margin-bottom: 20px;
    padding: 10px 0;
}

.site-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.site-header p {
    font-size: 16px;
    color: var(--text-muted);
}

.editor-header h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.editor-header p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ========================================== */
/* REFERRAL BANNER (SEO FUNNEL)               */
/* ========================================== */
.referral-banner {
    width: 100%;
    background-color: #fde047;
    padding: 12px 20px;
    text-align: center;
    border-bottom: 2px solid #eab308;
    color: #854d0e;
    font-size: 15px;
    font-weight: 500;
}

.referral-banner a {
    color: #b91c1c;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
    margin-left: 5px;
}

.referral-banner a:hover {
    color: #dc2626;
}

@media (prefers-color-scheme: dark) {
    .referral-banner {
        background-color: #422006;
        border-bottom-color: #713f12;
        color: #fef08a;
    }
    .referral-banner a {
        color: #fca5a5;
    }
    .referral-banner a:hover {
        color: #f87171;
    }
}

/* ========================================== */
/* 3. TYPING AREA & RELATIVE WRAPPER          */
/* ========================================== */
.editor-relative-wrapper {
    position: relative; /* Essential for floating suggestions */
    width: 100%;
}

textarea {
    width: 100%;
    height: 250px;
    min-height: 150px; /* Prevents user from shrinking it to nothing */
    font-size: 20px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    transition: all 0.2s;
    outline: none; /* Removed default styling to replace with custom glow below */
    display: block;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); /* Soft blue accessibility glow */
}

.stats-bar {
    display: flex;
    gap: 15px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 4px;
}

.save-status {
    margin-left: auto;
    color: #10b981; 
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* ========================================== */
/* 4. FLOATING SUGGESTIONS UI                 */
/* ========================================== */
.floating-suggestions {
    position: absolute;   /* Removes from flow to hover */
    display: none;        /* Controlled by JavaScript */
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    flex-direction: row;
    gap: 6px;
    pointer-events: auto;
}

.suggestion-item {
    background: #f9fafb;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 17px;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    font-weight: 500;
    color: var(--text-main);
}

.suggestion-item:hover {
    background: #eff6ff;
    border-color: var(--primary);
    color: var(--primary);
}

.suggestion-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========================================== */
/* 5. BUTTONS & CONTROLS                      */
/* ========================================== */
.controls {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    gap: 15px;
}

button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

button:active {
    transform: scale(0.97); 
}

button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    flex: 1; 
    justify-content: center;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: #fee2e2;
    color: var(--danger);
}

.btn-danger:hover {
    background-color: #fecaca;
}

/* ========================================== */
/* 6. TOAST NOTIFICATION (Popups)             */
/* ========================================== */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    transition: bottom 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 2000;
}

.toast.show {
    bottom: 30px;
}

/* ========================================== */
/* 7. SEO CONTENT & ARTICLE STYLING           */
/* ========================================== */
.seo-content {
    margin-top: 30px;
    background: var(--card-bg);
    padding: 30px;
}

.seo-content h3 {
    font-size: 22px;
    color: var(--text-main);
    margin-bottom: 15px;
}

.seo-content h4 {
    font-size: 18px;
    color: var(--text-main);
    margin: 25px 0 10px 0;
}

.seo-content p, .seo-content li {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 15px;
}

.seo-content ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

/* ========================================== */
/* 8. FOOTER & KEYWORD CLUSTER                */
/* ========================================== */
.site-footer {
    width: 100%;
    max-width: 800px;
    margin-top: 40px;
    text-align: center;
}

.keyword-cluster {
    background-color: #f8fafc; 
    border-radius: 8px;
    border-left: 4px solid var(--primary); 
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.keyword-cluster p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.8;
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding: 30px 0 60px 0;
    color: var(--text-muted);
    font-size: 14px;
    box-shadow: none;
    background: transparent;
}

.footer-links {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 25px;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ========================================== */
/* 9. MOBILE RESPONSIVENESS                   */
/* ========================================== */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container, .seo-content {
        padding: 20px;
    }

    .site-header h1 {
        font-size: 26px;
    }

    textarea {
        height: 200px; 
        font-size: 18px; 
    }

    /* --- THE MOBILE DOCK FIX --- */
    .floating-suggestions {
        /* 1. Override the JavaScript's Left/Right math */
        left: 0 !important; 
        width: 100% !important; 
        transform: none !important;
        
        /* 2. Visual styling for the dock */
        box-sizing: border-box;
        padding: 8px 10px !important; 
        border-radius: 8px;
        
        /* 3. Enable smooth horizontal swiping */
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch; 
        scrollbar-width: none; 
    }

    .floating-suggestions::-webkit-scrollbar {
        display: none; 
    }

    /* Stop buttons from squishing */
    .floating-suggestions > .suggestion-item {
        flex-shrink: 0 !important; 
        margin-right: 8px; 
    }
    
    /* Remove the margin on the very last button so it doesn't add fake space */
    .floating-suggestions > .suggestion-item:last-child {
        margin-right: 0; 
    }

    /* The ultimate scroll gap hack: an invisible 16px block at the end */
    .floating-suggestions::after {
        content: '';
        display: block;
        flex: 0 0 16px; 
    }

    /* Hide the box when empty */
    #suggestionBox.floating-suggestions:empty {
        display: none !important; 
    }

    .controls {
        flex-direction: column;
        gap: 12px;
    }
    
    button {
        width: 100%;
        justify-content: center;
    }

    .footer-links {
        flex-wrap: wrap;
        gap: 15px;
    }
}

/* ========================================== */
/* 10. DARK MODE SUPPORT                      */
/* ========================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #111827;
        --card-bg: #1f2937;
        --text-main: #f9fafb;
        --text-muted: #9ca3af;
        --border: #374151;
    }

    .suggestion-item {
        background: #374151;
    }

    .suggestion-item:hover {
        background: #4b5563;
        color: white;
    }

    .keyword-cluster {
        background-color: #111827; 
    }
    
    .btn-danger {
        background-color: #7f1d1d;
        color: #fca5a5;
    }
    
    .btn-danger:hover {
        background-color: #991b1b;
    }
}