* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --background: #f5f7fb;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
    background: var(--background);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}


/* =========================================================
   AUTH
========================================================= */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at top right, #dbeafe, transparent 40%),
        var(--background);
}

.auth-container {
    width: 100%;
    max-width: 430px;
}

.brand {
    text-align: center;
    margin-bottom: 24px;
}

.brand-logo {
    width: 58px;
    height: 58px;
    margin: 0 auto 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 20px;
}

.brand h1 {
    margin: 0;
    font-size: 30px;
}

.brand p {
    margin: 6px 0 0;
    color: var(--muted);
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.auth-card h2 {
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
    margin-top: 0;
}

.auth-card form {
    margin-top: 22px;
}

label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin: 16px 0 7px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 13px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 11px 18px;
    border: 0;
    border-radius: 11px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-full {
    width: 100%;
    margin-top: 22px;
}

.auth-footer {
    text-align: center;
    margin-top: 22px;
    color: var(--muted);
    font-size: 14px;
}


/* =========================================================
   ALERTS
========================================================= */

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin: 16px 0;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}


/* =========================================================
   APPLICATION
========================================================= */

.app-shell {
    min-height: 100vh;
}

.topbar {
    height: 68px;
    padding: 0 22px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-brand {
    font-weight: 800;
    font-size: 21px;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.logout-link {
    font-size: 14px;
    font-weight: 600;
}

.dashboard {
    width: 100%;
    max-width: 1100px;
    margin: auto;
    padding: 24px;
    padding-bottom: 100px;
}

.welcome {
    margin-bottom: 22px;
}

.welcome h1 {
    margin: 0;
    font-size: 26px;
}

.welcome p {
    margin: 7px 0 0;
    color: var(--muted);
}


/* =========================================================
   CARDS
========================================================= */

.dashboard-card,
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 17px;
    padding: 20px;
}

.dashboard-card {
    margin-bottom: 18px;
}

.card-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-label,
.stat-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
}

.card-heading h2 {
    margin: 5px 0 0;
    font-size: 22px;
}

.pilot-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-running {
    background: var(--success);
}

.status-stopped {
    background: #9ca3af;
}

.info-row {
    padding: 15px 0;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.info-row:first-of-type {
    margin-top: 18px;
}

.info-row span {
    color: var(--muted);
}

.info-row strong {
    text-align: right;
}

.empty-state {
    margin-top: 18px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
}

.empty-state p {
    color: var(--muted);
}


/* =========================================================
   STATS
========================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    font-size: 26px;
}

.stat-value {
    display: block;
    margin-top: 4px;
    font-size: 23px;
}


/* =========================================================
   ACTIONS
========================================================= */

.card-title {
    font-weight: 800;
    margin-bottom: 15px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.action-button {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 13px;
    color: var(--text);
}

.action-button > span {
    font-size: 24px;
}

.action-button strong {
    font-size: 14px;
}

.action-button small {
    color: var(--muted);
}


/* =========================================================
   MOBILE NAVIGATION
========================================================= */

.mobile-nav {
    display: none;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 700px) {

    .auth-page {
        align-items: flex-start;
        padding: 24px 16px;
    }

    .auth-container {
        margin-top: 20px;
    }

    .auth-card {
        padding: 20px;
        border-radius: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .dashboard {
        padding: 20px 15px 100px;
    }

    .welcome h1 {
        font-size: 23px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
    }

    .action-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mobile-nav {
        position: fixed;
        z-index: 1000;
        left: 0;
        right: 0;
        bottom: 0;
        height: 68px;
        background: rgba(255, 255, 255, 0.97);
        border-top: 1px solid var(--border);
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--muted);
        font-size: 18px;
    }

    .mobile-nav a small {
        font-size: 10px;
    }

    .mobile-nav a.active {
        color: var(--primary);
        font-weight: 700;
    }
}

/* =========================================================
   WEBSITE MODULE
========================================================= */

.page-header {
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0;
    font-size: 27px;
}

.page-header p {
    margin: 7px 0 0;
    color: var(--muted);
}

.website-empty {
    text-align: center;
    padding: 45px 20px;
}

.website-empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.website-empty h2 {
    margin: 0 0 8px;
}

.website-empty p {
    max-width: 500px;
    margin: 0 auto 20px;
    color: var(--muted);
    line-height: 1.6;
}

.website-card-top {
    display: flex;
    align-items: center;
    gap: 15px;
}

.website-platform-icon {
    width: 54px;
    height: 54px;
    border-radius: 15px;
    background: #eff6ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
}

.website-details h2 {
    margin: 0 0 5px;
    font-size: 20px;
}

.website-details a {
    font-size: 13px;
    word-break: break-all;
}

.website-status-row,
.website-info-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 0;
    margin-top: 18px;
    border-top: 1px solid var(--border);
}

.website-status-row span,
.website-info-row span {
    color: var(--muted);
}

.connected-status {
    color: var(--success);
}

.error-status {
    color: var(--danger);
}

.disconnected-status {
    color: var(--muted);
}

.website-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-secondary {
    background: #eef2f7;
    color: var(--text);
}

.danger-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--danger);
    font-weight: 700;
}

.field-help {
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 600px) {

    .website-actions {
        flex-direction: column;
    }

    .website-actions .btn {
        width: 100%;
    }

    .website-status-row,
    .website-info-row {
        align-items: flex-start;
    }
}

/* =========================================================
   AI SETTINGS
========================================================= */

.settings-section {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.settings-section h3 {
    margin: 0 0 6px;
    font-size: 17px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    cursor: pointer;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.ai-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    font-weight: 700;
}

.ai-flow span {
    color: var(--primary);
}

/* =========================================================
   POSTS / ARTICLE GENERATION
========================================================= */

.generation-intro {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 28px;
}

.generation-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    font-size: 23px;
    flex-shrink: 0;
}

.generation-intro h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.generation-intro p {
    margin: 0;
    color: #6b7280;
    line-height: 1.6;
}

.generation-form {
    max-width: 700px;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.form-group small {
    display: block;
    margin-top: 7px;
    color: #6b7280;
    line-height: 1.5;
}

.optional {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-left: 5px;
}

.selected-website {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f9fafb;
}

.selected-website strong,
.selected-website span {
    display: block;
}

.selected-website span {
    margin-top: 4px;
    color: #6b7280;
    font-size: 14px;
    word-break: break-word;
}

.generation-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 26px 0;
}

.generation-info > div {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafafa;
}

.generation-info strong,
.generation-info span {
    display: block;
}

.generation-info strong {
    font-size: 13px;
    margin-bottom: 5px;
}

.generation-info span {
    color: #6b7280;
    font-size: 12px;
    line-height: 1.45;
}

.posts-list {
    display: grid;
    gap: 16px;
}

.post-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
}

.post-card-top h2 {
    margin: 10px 0 0;
    font-size: 18px;
    line-height: 1.4;
}

.post-excerpt {
    color: #6b7280;
    line-height: 1.6;
    margin: 14px 0;
}

.post-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.post-card-meta span {
    background: #f3f4f6;
    padding: 6px 9px;
    border-radius: 7px;
    color: #6b7280;
    font-size: 12px;
}

.post-card-actions {
    display: flex;
    gap: 8px;
}

.post-status {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.post-status-queued {
    background: #fff7ed;
    color: #c2410c;
}

.post-status-published {
    background: #ecfdf5;
    color: #047857;
}

.post-status-failed {
    background: #fef2f2;
    color: #b91c1c;
}

.post-status-draft {
    background: #f3f4f6;
    color: #4b5563;
}

.generated-article-card h2 {
    margin: 10px 0 0;
    line-height: 1.4;
}

.article-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 22px 0;
}

.article-meta-grid > div {
    padding: 14px;
    border-radius: 10px;
    background: #f9fafb;
}

.article-meta-grid span,
.article-meta-grid strong {
    display: block;
}

.article-meta-grid span {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 5px;
}

.article-meta-grid strong {
    font-size: 14px;
    word-break: break-word;
}

.article-excerpt,
.article-content-preview {
    margin-top: 24px;
}

.article-excerpt h3,
.article-content-preview h3 {
    margin-bottom: 10px;
}

.article-excerpt p {
    color: #4b5563;
    line-height: 1.7;
}

.article-content {
    line-height: 1.8;
    color: #1f2937;
}

.article-content h2 {
    margin-top: 30px;
    margin-bottom: 10px;
}

.article-content h3 {
    margin-top: 24px;
    margin-bottom: 8px;
}

.article-content p {
    margin-bottom: 16px;
}

.article-content ul,
.article-content ol {
    margin: 0 0 18px 22px;
}

.article-content li {
    margin-bottom: 7px;
}

.article-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}

.empty-state {
    text-align: center;
    padding: 35px 15px;
}

.empty-state-icon {
    font-size: 38px;
    margin-bottom: 12px;
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    color: #6b7280;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto 20px;
}

@media (max-width: 700px) {

    .generation-info,
    .article-meta-grid {
        grid-template-columns: 1fr;
    }

    .generation-intro {
        gap: 12px;
    }

    .generated-article-card h2 {
        font-size: 20px;
    }

    .post-card {
        padding: 16px;
    }

}

/* =========================================================
   ARTICLE VIEW
========================================================= */

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: #6b7280;
    font-size: 14px;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.article-detail-card {
    margin-bottom: 16px;
}

.article-detail-status {
    margin-bottom: 10px;
}

.article-detail-title {
    margin: 0;
    font-size: 30px;
    line-height: 1.3;
}

.article-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.article-detail-meta span {
    padding: 7px 10px;
    background: #f3f4f6;
    border-radius: 8px;
    color: #6b7280;
    font-size: 12px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.section-heading p {
    margin: 0;
    color: #6b7280;
    line-height: 1.5;
}

.featured-image-preview {
    overflow: hidden;
    border-radius: 14px;
    background: #f3f4f6;
}

.featured-image-preview img {
    display: block;
    width: 100%;
    max-height: 500px;
    object-fit: cover;
}

.image-information {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.image-information span {
    padding: 7px 10px;
    background: #f3f4f6;
    border-radius: 8px;
    color: #6b7280;
    font-size: 12px;
}

.image-empty-state {
    text-align: center;
    padding: 35px 15px;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    background: #fafafa;
}

.image-empty-icon {
    font-size: 34px;
    margin-bottom: 10px;
}

.image-empty-state h3 {
    margin: 0 0 7px;
}

.image-empty-state p {
    margin: 0;
    color: #6b7280;
    line-height: 1.6;
}

.article-reading-card {
    padding: 28px;
}

.article-content {
    max-width: 850px;
    margin: 0 auto;
    font-size: 17px;
    line-height: 1.85;
}

.article-content h2 {
    margin-top: 35px;
    margin-bottom: 12px;
    font-size: 24px;
    line-height: 1.35;
}

.article-content h3 {
    margin-top: 28px;
    margin-bottom: 10px;
    font-size: 20px;
}

.article-content p {
    margin: 0 0 18px;
}

.article-content ul,
.article-content ol {
    margin: 0 0 20px;
    padding-left: 25px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-content blockquote {
    margin: 25px 0;
    padding: 15px 20px;
    border-left: 4px solid #d1d5db;
    background: #f9fafb;
}

.inline-images-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.inline-image-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.inline-image-card img {
    display: block;
    width: 100%;
    height: 190px;
    object-fit: cover;
}

.inline-image-caption {
    padding: 10px 12px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.5;
}

.seo-information {
    display: grid;
    gap: 15px;
}

.seo-field {
    padding: 15px;
    background: #f9fafb;
    border-radius: 10px;
}

.seo-field > span {
    display: block;
    margin-bottom: 6px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
}

.seo-field strong,
.seo-field p {
    margin: 0;
    line-height: 1.6;
}

.seo-field code {
    display: block;
    overflow-wrap: anywhere;
    color: #374151;
}

.article-actions-card {
    margin-bottom: 100px;
}

.queue-note {
    margin-top: 18px;
    padding: 14px;
    border-radius: 10px;
    background: #fff7ed;
    color: #92400e;
    line-height: 1.6;
}

.queue-note p {
    margin: 5px 0 0;
    font-size: 13px;
}

@media (max-width: 700px) {

    .article-detail-title {
        font-size: 23px;
    }

    .article-reading-card {
        padding: 20px 16px;
    }

    .article-content {
        font-size: 16px;
        line-height: 1.75;
    }

    .article-content h2 {
        font-size: 21px;
    }

    .article-content h3 {
        font-size: 18px;
    }

    .inline-images-grid {
        grid-template-columns: 1fr;
    }

    .inline-image-card img {
        height: 220px;
    }

}