/* === Canadian Landlord-Tenant News Dashboard === */
:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #242836;
    --border: #2d3148;
    --text: #e4e6f0;
    --text-muted: #8b8fa3;
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --success: #00cec9;
    --warning: #fdcb6e;
    --danger: #e17055;
    --blue: #74b9ff;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.agent-badge {
    display: inline-block;
    background: rgba(0, 206, 201, 0.15);
    color: var(--success);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    margin-left: 0.8rem;
    animation: pulse 2s infinite;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stats-mini {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-copy {
    background: var(--success);
    color: #000;
    font-weight: 600;
}
.btn-copy:hover { opacity: 0.85; }

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1.2rem 2rem;
    background: var(--bg);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    text-align: center;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filters */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-box { flex: 1; min-width: 200px; }

/* Articles Container */
.articles-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.2rem;
    padding: 1.5rem 2rem;
}

/* Article Card */
.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.25s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--bg-hover);
}

.card-body {
    padding: 1rem 1.2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-source {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-summary {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.2rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-tags {
    display: flex;
    gap: 0.4rem;
}

.tag {
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 500;
}

.tag-category {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
}
.tag-province {
    background: rgba(116, 185, 255, 0.15);
    color: var(--blue);
}
.tag-bookmarked {
    color: var(--warning);
}
.tag-posted {
    color: var(--success);
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); }

select {
    padding: 0.6rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.bookmark-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}



/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 680px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.modal-content h2 {
    font-size: 1.2rem;
    line-height: 1.4;
    margin-bottom: 0.6rem;
    padding-right: 2rem;
}

.modal-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.storyline-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}

.storyline-box h3 {
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
    color: var(--success);
}

.storyline-box pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 0.8rem;
}

.modal-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.5rem 2rem 3rem;
}

.pagination button {
    padding: 0.5rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
}
.pagination button:hover { background: var(--bg-hover); }
.pagination button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Loading */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: #000;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state h2 { font-size: 1.3rem; margin-bottom: 0.5rem; color: var(--text); }

/* ── Instagram Post Section ─────────────────────────────────────────────── */
:root {
    --ig-accent: #5253FF;        /* liviohomes brand blue */
    --ig-accent2: #ffd166;       /* warm yellow secondary */
    --ig-bg: #0a0a0f;
    --ig-card: #111118;
    --ig-border: #1e1e2e;
}

.ig-section {
    margin-top: 1.6rem;
    border-top: 1px solid var(--border);
    padding-top: 1.4rem;
}

.ig-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ig-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ig-accent);
    letter-spacing: 0.3px;
}

.ig-actions { display: flex; gap: 0.5rem; }

.btn-ig {
    background: linear-gradient(135deg, #5253FF, #7b8cff);
    color: #000;
    font-weight: 700;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    transition: opacity 0.2s;
}
.btn-ig:hover { opacity: 0.85; }
.btn-ig:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ig-outline {
    background: transparent;
    border: 1px solid var(--ig-accent);
    color: var(--ig-accent);
    padding: 0.45rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-ig-outline:hover { background: rgba(255,107,53,0.1); }
.btn-ig-outline:disabled { opacity: 0.45; cursor: not-allowed; }

/* Loading */
.ig-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.ig-spinner {
    width: 28px; height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--ig-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Block labels */
.ig-block-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 0.7rem;
}

/* ── Carousel slides ─────────────────────────────────────────────────────── */
.ig-carousel {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ig-slide {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    background: var(--ig-card);
    border: 1px solid var(--ig-border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    transition: border-color 0.2s;
}
.ig-slide:hover { border-color: var(--ig-accent); }

.ig-slide-number {
    flex-shrink: 0;
    width: 28px; height: 28px;
    background: linear-gradient(135deg, #5253FF, #7b8cff);
    color: #000;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ig-slide-inner { flex: 1; }

.ig-slide-label {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.1rem 0.45rem;
    border-radius: 20px;
    margin-bottom: 0.3rem;
    background: rgba(82,83,255,0.15);
    color: var(--ig-accent);
}
.ig-slide-label--hook    { background: rgba(82,83,255,0.2); color: #5253FF; }
.ig-slide-label--impact  { background: rgba(255,209,102,0.2); color: #ffd166; }
.ig-slide-label--cta     { background: rgba(0,206,201,0.2); color: var(--success); }

.ig-slide-text {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
    margin: 0;
}

/* The highlighted words inside slide text */
mark.ig-highlight {
    background: linear-gradient(135deg, #5253FF, #7b8cff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    /* Fallback for browsers that don't support text gradient */
    color: #5253FF;
}

.ig-slide-highlights {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}
.ig-slide-highlights strong { color: var(--ig-accent2); }

/* ── Image prompts ───────────────────────────────────────────────────────── */
.ig-prompts { display: flex; flex-direction: column; gap: 0.5rem; }

.ig-prompt {
    background: var(--ig-card);
    border: 1px solid var(--ig-border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    position: relative;
}
.ig-prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}
.ig-prompt-num {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ig-accent2);
}
.ig-prompt-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.btn-ig-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    border: 1px solid var(--ig-accent);
    background: transparent;
    color: var(--ig-accent);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}
.btn-ig-sm:hover {
    background: var(--ig-accent);
    color: #fff;
}
.btn-ig-sm:disabled {
    opacity: 0.5;
    cursor: wait;
}
.ig-prompt-textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.6rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
    box-sizing: border-box;
    font-style: italic;
}
.ig-prompt-textarea:focus {
    outline: none;
    border-color: var(--ig-accent);
    box-shadow: 0 0 0 2px rgba(255,107,53,0.12);
    font-style: normal;
    color: var(--text);
}
.ig-prompt-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 0.5rem;
    font-style: italic;
}
.ig-copy-small {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.ig-copy-small:hover { border-color: var(--ig-accent); color: var(--ig-accent); }

/* ── Caption box ─────────────────────────────────────────────────────────── */
.ig-caption-box {
    background: var(--ig-card);
    border: 1px solid var(--ig-border);
    border-radius: 8px;
    padding: 1rem;
}
.ig-caption-text {
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 0 0 0.6rem;
    color: var(--text);
}
.ig-hashtags {
    font-size: 0.78rem;
    color: #74b9ff;
    line-height: 1.6;
    margin: 0 0 0.6rem;
    word-break: break-word;
}

/* ── Audio pill ──────────────────────────────────────────────────────────── */
.ig-audio-pill {
    display: inline-block;
    background: rgba(108,92,231,0.15);
    border: 1px solid rgba(108,92,231,0.3);
    color: var(--accent);
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
}

/* Responsive */
/* ── Generated Slide Images ────────────────────────────────────────── */
.ig-images-section {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}
.ig-images-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}
.ig-images-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}
.ig-image-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ig-image-card img {
    width: 100%;
    height: auto;
    display: block;
}
.ig-image-actions {
    display: flex;
    gap: 0;
}
.ig-image-actions .btn-ig-regen {
    flex: 0 0 auto;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    background: none;
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}
.ig-image-actions .btn-ig-regen:hover {
    background: rgba(0, 0, 225, 0.08);
}
.ig-image-actions .btn-ig-regen:disabled {
    opacity: 0.5;
    cursor: wait;
}
.ig-download-btn {
    display: block;
    text-align: center;
    padding: 0.5rem;
    flex: 1;
    font-size: 0.8rem;
    color: var(--ig-accent);
    text-decoration: none;
    border-top: 1px solid var(--border);
    transition: background 0.2s;
}
.ig-download-btn:hover {
    background: rgba(255, 107, 53, 0.1);
}

/* ── Slide copy button ────────────────────────────────────────────────── */
.ig-slide-copy {
    margin-top: 0.5rem;
    align-self: flex-start;
}

@media (max-width: 768px) {
    .header { flex-direction: column; gap: 0.8rem; padding: 1rem; }
    .filters-bar { padding: 0.8rem 1rem; }
    .articles-container { grid-template-columns: 1fr; padding: 1rem; }
    .stats-bar { padding: 0.8rem 1rem; }
    .modal-content { padding: 1.2rem; }
    .ig-images-grid { grid-template-columns: 1fr; }
}