/* Modulards Content Monitor v3 - Sidebar Layout */

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --link: #4f6ef7;

    /* Competitor colors */
    --c-managewp: #3b82f6;
    --c-wpumbrella: #8b5cf6;
    --c-mainwp: #10b981;
    --c-solidwp: #f59e0b;
    --c-cmscommander: #ef4444;
    --c-infinitewp: #ec4899;
    --c-blogvault: #06b6d4;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);

    --sidebar-width: 220px;
    --topbar-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: var(--sidebar-width);
}

.logo-img {
    flex-shrink: 0;
    height: 32px;
    width: auto;
}

.logo-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.2px;
}

.topbar-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.global-search {
    position: relative;
    width: 100%;
}

.global-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.global-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: all 0.2s;
}

.global-search input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.global-search input::placeholder { color: var(--text-muted); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-scan-info {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    cursor: default;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-scan {
    background: var(--primary);
    color: #fff;
}

.btn-scan:hover { background: var(--primary-hover); }
.btn-scan:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-page {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-page:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== APP LAYOUT ========== */
.app-layout {
    display: flex;
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 20px 16px 10px;
}

.sidebar-list {
    flex: 1;
    padding: 0 8px;
}

.competitor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
    position: relative;
}

.competitor-item:hover {
    background: var(--bg);
}

.competitor-item.active {
    background: var(--primary-light);
}

.competitor-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.competitor-item .name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.competitor-item .count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.competitor-item.active .count {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

/* Colored dots */
.dot-managewp { background: var(--c-managewp); }
.dot-wp-umbrella { background: var(--c-wpumbrella); }
.dot-mainwp { background: var(--c-mainwp); }
.dot-solidwp { background: var(--c-solidwp); }
.dot-cmscommander { background: var(--c-cmscommander); }
.dot-infinitewp { background: var(--c-infinitewp); }
.dot-blogvault { background: var(--c-blogvault); }
.dot-all { background: var(--primary); }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.sidebar-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========== CONTENT ========== */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px 24px;
    min-width: 0;
}

/* ========== FILTERS BAR ========== */
.content-filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-select {
    padding: 7px 28px 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s;
}

.filter-select:focus { border-color: var(--primary); }

.custom-dates {
    display: none;
    align-items: center;
    gap: 6px;
}

.custom-dates.visible { display: flex; }

.custom-dates input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    outline: none;
}

.custom-dates input[type="date"]:focus { border-color: var(--primary); }

.date-separator {
    color: var(--text-muted);
    font-size: 12px;
}

/* ========== SECTION TITLES ========== */
.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.panel-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

/* ========== QUICK METRICS ========== */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.metric-value-sm {
    font-size: 20px;
}

/* ========== CHARTS ========== */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-card canvas {
    width: 100% !important;
    max-height: 280px;
}

/* ========== CONTENT COLUMNS (leaderboard + feed) ========== */
.content-columns {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: start;
}

.leaderboard-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    position: sticky;
    top: calc(var(--topbar-height) + 20px);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}

.leaderboard-item:last-child { border-bottom: none; }
.leaderboard-item:hover { background: var(--bg); border-radius: var(--radius-sm); }

.leaderboard-author {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.leaderboard-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 26px;
    padding: 0 8px;
    border-radius: 13px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .leaderboard-count { background: #10b981; }
.leaderboard-item:nth-child(2) .leaderboard-count { background: #3b82f6; }
.leaderboard-item:nth-child(3) .leaderboard-count { background: #8b5cf6; }

.leaderboard-empty {
    padding: 20px 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.feed-panel {
    min-width: 0;
}

/* ========== CATEGORY BAR ========== */
.category-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cat-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.cat-btn.active .cat-count {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

.cat-count {
    font-size: 10px;
    font-weight: 700;
    background: var(--bg);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 10px;
}

/* ========== FEED TABS ========== */
.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.feed-tabs {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border);
}

.feed-tab {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.feed-tab:hover {
    color: var(--text);
}

.feed-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ========== CATEGORY BADGES ========== */
.category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-badge-none {
    background: transparent;
    color: var(--text-muted);
    font-weight: 400;
}

.category-more {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
    margin-left: 4px;
    cursor: help;
}

/* ========== TABLE ========== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--surface);
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.th-date { width: 110px; }
.th-competitor { width: 120px; }
.th-category { width: 150px; }
.th-author { width: 130px; }

tbody td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #fafbfd; }

.td-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.td-title {
    max-width: 0;
    width: 100%;
}

.td-title a {
    color: var(--link);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.td-title a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.td-category {
    white-space: nowrap;
}

.td-competitor {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.td-author {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    gap: 6px;
}

.pagination .btn { padding: 5px 12px; font-size: 12px; }

/* ========== PROGRESS BAR ========== */
.scan-progress {
    display: none;
    background: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.scan-progress.active { display: block; }

.scan-progress .progress-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.progress-bar-track {
    height: 5px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state p { font-size: 14px; margin-top: 8px; }

/* ========== LOG PANEL ========== */
.log-panel {
    margin-top: 24px;
}

.log-panel summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 0;
}

.log-entries {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.log-entry {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
}

.log-entry:last-child { border-bottom: none; }
.log-entry .log-time { color: var(--text-muted); white-space: nowrap; }
.log-entry .log-status-ok { color: #10b981; }
.log-entry .log-status-error { color: #ef4444; }
.log-entry .log-name { font-weight: 600; }


/* ========== CHART MODE TOGGLE ========== */
.charts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chart-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-date-range input[type="month"] {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s;
    width: 130px;
}

.chart-date-range input[type="month"]:focus {
    border-color: var(--primary);
}

.btn-chart-reset {
    padding: 5px 8px !important;
    min-width: auto;
    color: var(--text-muted);
}

.btn-chart-reset:hover:not(:disabled) {
    color: var(--text);
}

.chart-mode-toggle {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border);
}

.chart-mode-btn {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.chart-mode-btn:hover {
    color: var(--text);
}

.chart-mode-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .content {
        margin-left: 0;
    }

    .topbar-left {
        min-width: auto;
    }

    .topbar-center {
        display: none;
    }

    .last-scan-info {
        display: none;
    }

    .content-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .metrics-row {
        grid-template-columns: 1fr;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .content-columns {
        grid-template-columns: 1fr;
    }

    .leaderboard-panel {
        position: static;
    }

    .th-author, .td-author,
    .th-category, .td-category,
    .th-competitor, .td-competitor {
        display: none;
    }

    .content {
        padding: 12px;
    }
}
