:root {
    --bg-dark: #0f172a;
    --bg-sidebar: #1e293b;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #10b981;
    --danger: #ef4444;
    --glass: rgba(30, 41, 59, 0.7);
    --border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 24px;
    color: var(--primary);
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    text-align: left;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn:hover,
.nav-btn.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-btn.active {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
}

/* Main Content */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

header h2 {
    font-size: 28px;
    font-weight: 700;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 30px;
    margin-bottom: 30px;
}

.detail-header>div:first-child {
    flex: 1;
}

.detail-header>div:last-child {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    max-width: 60%;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.w-full {
    width: 100%;
}

/* Grid / List Layouts */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 16px;
    transition: transform 0.2s;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.card h3 {
    margin-bottom: 8px;
}

.card p {
    color: var(--text-dim);
    font-size: 14px;
}

.card .meta {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

/* Modal */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-sidebar);
    width: 500px;
    max-height: 90vh;
    border-radius: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.close-btn,
.close-modal {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-btn:hover,
.close-modal:hover {
    color: var(--danger);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-dim);
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
}

.form-group textarea {
    height: 100px;
}

#export-json-content {
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 13px;
    background: #000;
    color: #a3e635;
    /* Lime green like a terminal */
    border-color: rgba(163, 230, 53, 0.2);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Dashboard Widgets */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--glass);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.stat-card .label {
    color: var(--text-dim);
    font-size: 14px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 8px;
}

/* Sections & Articles List */
.section-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 20px;
    transition: all 0.3s ease;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.article-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: 20px;
}

.article-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.article-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-planned {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.badge-ready_to_generate {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.badge-generating {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.badge-generated {
    background: rgba(245, 158, 11, 0.15);
    /* Amber/Yellow base */
    color: #f59e0b;
}

.badge-scheduled {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.badge-published {
    background: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.badge-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Status UI Elements */
.status-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-main) !important;
    white-space: nowrap;
}

.status-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    color: white !important;
}

.btn-action-gen {
    border-color: var(--accent) !important;
    background: rgba(16, 185, 129, 0.1) !important;
    color: var(--accent) !important;
    font-weight: 700 !important;
}

.btn-action-gen:hover {
    background: var(--accent) !important;
    color: white !important;
}

/* Phase 12 Highlighting */
.section-item.ready-publish {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.3);
}

.article-item.item-ready {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.1);
}

/* Modal v2 (Reuse for suggestions) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

#article-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-container {
    background: var(--bg-sidebar);
    width: 1400px !important;
    max-width: 98% !important;
    height: 94vh;
    max-height: 94vh;
    border-radius: 32px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.7);
}

#modal-body {
    padding: 0;
    /* Remove padding to handle scroll area better */
    overflow-y: hidden;
    /* Use the inner scroll area instead */
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 24px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    background: var(--bg-sidebar);
    z-index: 20;
}

.modal-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: var(--bg-dark);
}

#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    z-index: 3000;
}

#toast.success {
    background: var(--accent);
}

#toast.error {
    background: var(--danger);
}

/* Animations & Loader */
@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.loader-bar {
    width: 200px;
    height: 4px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 2px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.loader-bar::after {
    content: '';
    position: absolute;
    width: 40%;
    height: 100%;
    background: var(--primary);
    left: -40%;
    animation: loading 1.5s infinite ease-in-out;
}

@keyframes loading {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.pending-box {
    text-align: center;
    padding: 60px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px dashed var(--border);
}

.pending-text {
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
}

@keyframes pulse-animation {
    0% {
        box-shadow: 0 0 0 0px rgba(59, 130, 246, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0px rgba(59, 130, 246, 0);
    }
}

.pulse-animation {
    animation: pulse-animation 2s infinite;
    border-color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.1) !important;
}

/* Image Preview Tooltip */
.img-preview-container:hover .img-preview-tooltip {
    display: block !important;
}

.img-preview-tooltip {
    animation: fadeIn 0.2s ease-out;
    z-index: 10000 !important;
}

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

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

/* Article Preview Rendering */
.article-content-render h2 {
    font-size: 24px;
    margin: 30px 0 15px;
    color: var(--text-main);
    border-left: 4px solid var(--accent);
    padding-left: 15px;
}

.article-content-render h3 {
    font-size: 20px;
    margin: 25px 0 12px;
    color: var(--accent);
}

.article-content-render p {
    margin-bottom: 20px;
    line-height: 1.7;
    color: #cbd5e1;
}

.article-content-render ul,
.article-content-render ol {
    margin: 0 0 20px 25px;
}

.article-content-render li {
    margin-bottom: 8px;
}

.article-content-render table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow: hidden;
}

.article-content-render th {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    text-align: left;
    padding: 12px;
    font-weight: 700;
}

.article-content-render td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.article-content-render tr:last-child td {
    border-bottom: none;
}

.article-content-render blockquote,
.article-content-render .quote-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    font-style: italic;
    border-left: 4px solid var(--primary);
}

/* WordPress Simulation Mode */
.wp-simulation-container {
    background: #ffffff !important;
    color: #32373c !important;
    padding: 60px 80px;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.wp-simulation-container .article-content-render h2 {
    color: #1d2327;
    border-left: none;
    padding-left: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.wp-simulation-container .article-content-render p {
    color: #3c434a;
    font-size: 16px;
}

.raw-markdown-view {
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    background: #111 !important;
    color: #a3e635 !important;
    padding: 20px;
    border-radius: 8px;
    white-space: pre-wrap;
    border: 1px solid var(--border);
    line-height: 1.5;
    font-size: 13px;
}

.preview-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 8px;
}

.preview-tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.preview-tab-btn.active {
    background: var(--primary);
    color: white;
}