/**
 * SiteRooster Content Map Styles
 * Scoped to .cm-wrap to avoid conflicts with other sections.
 */

/* ==========================================
   Wrap & Empty State
   ========================================== */
.cm-wrap {
    margin-left: 54px;
    margin-right: 54px;
    padding-top: 16px;
    padding-bottom: 32px;
}

.cm-empty-card {
    text-align: center;
    padding: 60px 40px;
}

.cm-empty-icon {
    color: var(--gray-300, #d1d5db);
    margin-bottom: 16px;
}

.cm-empty-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700, #374151);
    margin-bottom: 8px;
}

.cm-empty-card p {
    font-size: 13px;
    color: var(--gray-400, #9ca3af);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ==========================================
   Header
   ========================================== */
.cm-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.cm-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin: 0 0 3px 0;
}

.cm-subtitle {
    font-size: 13px;
    color: var(--gray-500, #6b7280);
    margin: 0;
}

.cm-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ==========================================
   Stats Row
   ========================================== */
.cm-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.cm-stat-card {
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cm-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400, #9ca3af);
    margin-bottom: 6px;
}

.cm-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    line-height: 1;
    margin-bottom: 3px;
}

.cm-stat-value.green { color: #059669; }
.cm-stat-value.amber { color: #d97706; }
.cm-stat-value.red   { color: #dc2626; }

.cm-stat-sub {
    font-size: 11px;
    color: var(--gray-400, #9ca3af);
}

/* ==========================================
   Bulk Action Bar
   ========================================== */
.cm-bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #a7f3d0;
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(5,150,105,0.1);
    margin-bottom: 12px;
    animation: cmBulkSlideIn 0.18s ease;
}

@keyframes cmBulkSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cm-bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: #059669;
    padding-right: 10px;
    border-right: 1px solid var(--gray-200, #e5e7eb);
    white-space: normal;
}

.cm-bulk-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.cm-bulk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    font-family: inherit;
    transition: all 0.15s;
    white-space: normal;
}

.cm-bulk-btn svg { width: 13px; height: 13px; }
.cm-bulk-btn:disabled { opacity: 0.5; pointer-events: none; }

.cm-bulk-btn-ai       { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
.cm-bulk-btn-ai:hover { background: #d1fae5; border-color: #059669; }

.cm-bulk-btn-recheck       { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.cm-bulk-btn-recheck:hover { background: #dbeafe; }

.cm-bulk-btn-rankings       { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.cm-bulk-btn-rankings:hover { background: #ede9fe; }

.cm-bulk-clear {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--gray-400, #9ca3af);
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    padding: 6px 8px;
    border-radius: 6px;
    margin-left: auto;
    transition: all 0.15s;
}
.cm-bulk-clear:hover { color: var(--gray-600, #4b5563); background: var(--gray-100, #f3f4f6); }
.cm-bulk-clear svg { width: 12px; height: 12px; }

/* ==========================================
   Toolbar
   ========================================== */
.cm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cm-toolbar-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cm-toolbar-right { display: flex; align-items: center; gap: 8px; }

.cm-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    padding: 7px 12px;
    width: 220px;
}
.cm-search svg { color: var(--gray-400, #9ca3af); flex-shrink: 0; width: 14px; height: 14px; }
.cm-search input {
    border: none;
    outline: none;
    font-size: 13px;
    color: var(--gray-700, #374151);
    width: 100%;
    font-family: inherit;
    background: transparent;
}
.cm-search input::placeholder { color: var(--gray-400, #9ca3af); }

.cm-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--gray-200, #e5e7eb);
    background: #fff;
    color: var(--gray-600, #4b5563);
    font-family: inherit;
    transition: all 0.15s;
    white-space: normal;
}
.cm-filter-btn:hover  { border-color: var(--gray-300, #d1d5db); background: var(--gray-50, #f9fafb); }
.cm-filter-btn.active { border-color: #059669; background: #ecfdf5; color: #059669; }

.cm-view-label { font-size: 11px; color: var(--gray-500, #6b7280); white-space: nowrap; }

.cm-toggle { display: flex; background: var(--gray-100, #f3f4f6); border-radius: 6px; padding: 2px; gap: 2px; }
.cm-toggle-btn {
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--gray-500, #6b7280);
    font-family: inherit;
    transition: all 0.15s;
}
.cm-toggle-btn.active { background: #fff; color: var(--gray-800, #1f2937); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ==========================================
   Table Container
   ========================================== */
.cm-table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cm-table-scroll { overflow-x: auto; min-width: 0; }

table.cm-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* ==========================================
   Table Header
   ========================================== */
.cm-table thead tr { border-bottom: 2px solid var(--gray-100, #f3f4f6); }

.cm-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: normal;
    background: var(--gray-50, #f9fafb);
    overflow: hidden;
}

.cm-th-check    { width: 36px; padding: 0 !important; }
.cm-col-url     { width: 9%; }
.cm-col-title   { width: 16%; }
.cm-col-h1      { width: 13%; }
.cm-col-desc    { width: 18%; }
.cm-col-kw      { width: 10%; }
.cm-col-sec     { width: 8%; }
.cm-col-rank    { width: 40px; text-align: center !important; }
.cm-col-score   { width: 54px; text-align: center !important; }
.cm-col-actions { width: 70px; text-align: right !important; }

.cm-rank-header { font-size: 10px; font-weight: 600; }

/* ==========================================
   Table Rows
   ========================================== */
.cm-table tbody tr {
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
    transition: background 0.1s;
}
.cm-table tbody tr:last-child { border-bottom: none; }
.cm-table tbody tr:hover { background: var(--gray-50, #f9fafb); }

.cm-table tbody tr.cm-row-ai       { background: #f0fdf4; }
.cm-table tbody tr.cm-row-edited   { background: #fffcf0; }
.cm-table tbody tr.cm-row-selected { background: #ecfdf5 !important; }
.cm-table tbody tr.cm-row-selected td:first-child { border-left: 3px solid #059669; }
.cm-table tbody tr.cm-row-dirty    { background: #fff7ed; }
.cm-table tbody tr.cm-row-saving   { opacity: 0.6; pointer-events: none; }

.cm-table td {
    padding: 8px 10px;
    vertical-align: middle;
    overflow: hidden;
}

/* ==========================================
   Checkbox
   ========================================== */
.cm-checkbox-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    padding: 0;
}
.cm-checkbox {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #059669;
    flex-shrink: 0;
}

/* ==========================================
   URL Cell
   ========================================== */
.cm-url {
    font-size: 12px;
    color: #059669;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: block;
    max-width: 130px;
}

/* ==========================================
   Editable Cells
   ========================================== */
.cm-cell-editable { position: relative; }

.cm-cell-input {
    width: 100%;
    font-size: 12px;
    color: var(--gray-700, #374151);
    line-height: 1.4;
    padding: 3px 4px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    font-family: inherit;
    resize: none;
    transition: border-color 0.15s, background 0.15s;
    min-height: 28px;
    box-sizing: border-box;
    overflow: hidden;
    display: block;
}
.cm-cell-input:hover  { border-color: var(--gray-200, #e5e7eb); background: var(--gray-50, #f9fafb); }
.cm-cell-input:focus  { outline: none; border-color: #059669; background: #fff; box-shadow: 0 0 0 3px rgba(5,150,105,0.1); }
.cm-cell-input.missing { color: var(--gray-400, #9ca3af); font-style: italic; }

/* ==========================================
   Flags
   ========================================== */
.cm-flag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    line-height: 1;
}
.cm-flag-ai     { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.cm-flag-edited { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.cm-flag svg    { width: 9px; height: 9px; }

/* ==========================================
   Keywords
   ========================================== */
.cm-kw-primary {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-800, #1f2937);
    background: var(--gray-100, #f3f4f6);
    padding: 3px 8px;
    border-radius: 20px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}
.cm-kw-primary.cm-kw-ai { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

.cm-kw-secondary { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cm-kw-tag {
    font-size: 11px;
    color: var(--gray-500, #6b7280);
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200, #e5e7eb);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: normal;
}
.cm-kw-tag.cm-kw-ai { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }

/* ==========================================
   Rankings
   ========================================== */
.cm-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    min-width: 28px;
    height: 24px;
    border-radius: 5px;
    padding: 0 4px;
}
.cm-rank-1-3   { background: #ecfdf5; color: #059669; }
.cm-rank-4-10  { background: #f0fdf4; color: #16a34a; }
.cm-rank-11-20 { background: #fffbeb; color: #d97706; }
.cm-rank-21p   { background: #fef2f2; color: #dc2626; }
.cm-rank-none  { background: var(--gray-100, #f3f4f6); color: var(--gray-400, #9ca3af); font-size: 11px; font-weight: 500; }

/* ==========================================
   Score Ring
   ========================================== */
.cm-score-wrap { display: flex; align-items: center; justify-content: center; }
.cm-score-ring { position: relative; width: 38px; height: 38px; flex-shrink: 0; }
.cm-score-ring svg { width: 38px; height: 38px; transform: rotate(-90deg); }
.cm-score-ring .track      { fill: none; stroke: var(--gray-100, #f3f4f6); stroke-width: 4; }
.cm-score-ring .fill-green { fill: none; stroke: #059669; stroke-width: 4; stroke-linecap: round; }
.cm-score-ring .fill-amber { fill: none; stroke: #f59e0b; stroke-width: 4; stroke-linecap: round; }
.cm-score-ring .fill-red   { fill: none; stroke: #ef4444; stroke-width: 4; stroke-linecap: round; }
.cm-score-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-800, #1f2937);
}

/* ==========================================
   Row Action Buttons (Save / Discard)
   ========================================== */
.cm-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.cm-row-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    font-family: inherit;
    transition: all 0.15s;
    white-space: normal;
}
.cm-row-btn svg { width: 11px; height: 11px; }

.cm-row-btn-save {
    background: #059669;
    color: #fff;
    border-color: #059669;
    display: none; /* shown when row is dirty */
}
.cm-row-btn-save:hover { background: #047857; }

.cm-row-btn-discard {
    background: #fff;
    color: var(--gray-500, #6b7280);
    border-color: var(--gray-200, #e5e7eb);
    display: none; /* shown when row is dirty */
}
.cm-row-btn-discard:hover { background: var(--gray-50, #f9fafb); color: var(--gray-700, #374151); }

/* Show save/discard when row is dirty */
.cm-table tbody tr.cm-row-dirty .cm-row-btn-save,
.cm-table tbody tr.cm-row-dirty .cm-row-btn-discard {
    display: inline-flex;
}

/* ==========================================
   Legend
   ========================================== */
.cm-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    border-top: 1px solid var(--gray-100, #f3f4f6);
    background: var(--gray-50, #f9fafb);
    flex-wrap: wrap;
}
.cm-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--gray-500, #6b7280); }
.cm-legend-dot  { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.cm-legend-dot-ai     { background: #f0fdf4; border: 1px solid #a7f3d0; }
.cm-legend-dot-edited { background: #fffcf0; border: 1px solid #fde68a; }
.cm-legend-dot-live   { background: #fff;    border: 1px solid var(--gray-200, #e5e7eb); }

/* ==========================================
   Footer / Pagination
   ========================================== */
.cm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-100, #f3f4f6);
    background: #fff;
}
.cm-footer-info { font-size: 12px; color: var(--gray-400, #9ca3af); }

.cm-pagination { display: flex; align-items: center; gap: 4px; }
.cm-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--gray-200, #e5e7eb);
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600, #4b5563);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.cm-page-btn:hover  { border-color: var(--gray-300, #d1d5db); background: var(--gray-50, #f9fafb); }
.cm-page-btn.active { background: #059669; border-color: #059669; color: #fff; }
.cm-page-btn:disabled { opacity: 0.4; pointer-events: none; }

/* ==========================================
   Notification Toast
   ========================================== */
.cm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: cmToastIn 0.2s ease;
}
.cm-toast-success { background: #059669; }
.cm-toast-error   { background: #dc2626; }
.cm-toast-info    { background: #2563eb; }

@keyframes cmToastIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}