/* ===========================
   RankFlow V4 Global Styling
   =========================== */

   :root {
    --rf-bg: #f7f9fc;
    --rf-card: #ffffff;
    --rf-glass: rgba(255,255,255,0.8);
    --rf-border: #e5e7eb;
    --rf-radius: 18px;
    --rf-shadow: 0 14px 30px rgba(0,0,0,0.07);
    --rf-primary: #2563eb;
    --rf-primary-light: #3b82f6;
    --rf-up: #FFFFFF;
    --rf-down: #FAFAFA;
    --rf-text-dark: #1e293b;
    --rf-text-muted: #64748b;
}

/* ===========================
   Core Cards
   =========================== */

.rf-card {
    background: var(--rf-card);
    padding: 24px;
    border-radius: var(--rf-radius);
    box-shadow: var(--rf-shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.5);
}

.rf-card:hover {
    box-shadow: var(--rf-shadow);
}

.rf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===========================
   Metric Cards
   =========================== */

.rf-metric {
    padding: 20px;
    border-radius: var(--rf-radius);
    background: linear-gradient(135deg, var(--rf-primary), var(--rf-primary-light));
    color: #fff;
    box-shadow: var(--rf-shadow);
}

.rf-metric h3 {
    font-size: 18px;
    margin: 0 0 5px;
}

.rf-metric .val {
    font-size: 32px;
    font-weight: 600;
}

/* ===========================
   Winners / Losers
   =========================== */

.rf-box {
    padding: 16px;
    background: var(--rf-glass);
    border-radius: var(--rf-radius);
    border: 1px solid var(--rf-border);
    box-shadow: var(--rf-shadow);
}

.rf-box ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rf-box li {
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #e5e7eb;
}

.rf-box li:last-child {
    border-bottom: 0;
}

/* Badges */
.rf-badge {
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.rf-up {
    background: var(--rf-up);
    box-shadow: 0 0 10px rgba(16,185,129,0.5);
}

.rf-down {
    background: var(--rf-down);
    box-shadow: 0 0 10px rgba(239,68,68,0.5);
}

/* ===========================
   Table styling (Global)
   =========================== */

.rf-table-wrapper {
    overflow: hidden;
    border-radius: var(--rf-radius);
    border: 1px solid var(--rf-border);
    margin-top: 20px;
}

.rf-table {
    width: 100%;
    border-collapse: collapse;
}

.rf-table thead {
    background: #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 20;
}

.rf-table th {
    padding: 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.rf-table th:last-child {
    text-align: right;
    width: 180px;
    min-width: 180px;
    padding-right: 12px;
}

.rf-table td {
    padding: 14px;
    border-top: 1px solid #f1f5f9;
    font-size: 13px;
    color: var(--rf-text-dark);
}

.rf-table td:last-child {
    text-align: right;
    width: 180px;
    min-width: 180px;
    padding-right: 12px;
    vertical-align: middle;
}

/* Reduce spacing for Δ column (4th) to bring Clicks/Impr closer */
.rf-table th:nth-child(4),
.rf-table td:nth-child(4) {
    padding-right: 4px;
}

/* Reduce spacing for Clicks and Impr columns to make room for Trend chart */
.rf-table th:nth-child(5),
.rf-table th:nth-child(6),
.rf-table td:nth-child(5),
.rf-table td:nth-child(6) {
    padding: 14px 2px 14px 0px;
    width: 60px;
    text-align: right;
    margin-left: -8px;
}

.rf-table tr:hover td {
    background: #F0EADF;
}

/* Trend bars */
.rf-bar {
    display: flex;
    height: 8px;
    gap: 2px;
}

.rf-bar div {
    flex: 1;
    background: #93c5fd;
    border-radius: 4px;
    animation: grow .4s ease;
}

@keyframes grow {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

/* ===========================
   Global Filters + Inputs
   =========================== */

.rf-toolbar {
    margin: 20px 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.rf-input,
.rf-select {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    box-shadow: var(--rf-shadow);
    font-size: 13px;
}

/* Buttons */
.rf-btn,
.rf-head-actions .button{
    padding: 8px 16px;
    border-radius: 10px;
    background: #D8B15A !important;
    border: none !important;
    color: #1a1a1a !important;
    font-weight: 600 !important;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(216, 177, 90, 0.3) !important;
    transition: background 0.2s ease !important;
}

/* Pagination Prev/Next - compact height */
.rf-pagination .rf-btn{
    padding: 5px 12px;
    height: auto;
    min-height: 0;
    font-size: 13px;
    border-radius: 8px;
    line-height: 1.3;
    background: #D8B15A !important;
    border: none !important;
    color: #1a1a1a !important;
    font-weight: 600 !important;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(216, 177, 90, 0.3) !important;
    transition: background 0.2s ease !important;
}

.rf-btn:hover,
.rf-pagination .rf-btn:hover,
.rf-head-actions .button:hover {
    background: #C49A4A !important;
    color: #1a1a1a !important;
}

.rf-btn:active,
.rf-pagination .rf-btn:active,
.rf-head-actions .button:active {
    transform: translateY(1px);
}

/* Pagination */
.rf-pagination {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.rf-page,
.rf-page-active {
    padding: 5px 11px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

.rf-page {
    background: #fff;
    color: var(--rf-text-dark);
}

.rf-page-active {
    background: #D8B15A;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(216, 177, 90, 0.3);
}

/* ===========================
   Sparkline charts
   =========================== */

.rf-spark-wrap {
    position: relative;
    width: 160px;
    height: 40px;
    display: inline-block;
    vertical-align: middle;
}

.rf-spark {
    width: 160px;
    height: 40px;
    display: block;
    overflow: visible;
}

.rf-spark path {
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: rfDraw 1.2s ease forwards;
    transition: stroke .3s ease, opacity .3s ease;
}

@keyframes rfDraw {
    from { stroke-dashoffset: 400; }
    to   { stroke-dashoffset: 0; }
}

/* Tooltip */
.rf-tip {
    position: absolute;
    padding: 4px 8px;
    font-size: 12px;
    background: #111;
    color: #fff;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -120%);
    transition: opacity .12s ease;
    z-index: 20;
    white-space: nowrap;
}

/* Sparkline hover tooltip (date + position, like Overview/Rank tabs) */
.rf-spark-tooltip {
    display: none;
    position: fixed;
    min-width: 180px;
    max-width: 280px;
    background: #ffffff;
    border: 1px solid var(--rf-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--rf-text-dark);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1);
    pointer-events: none;
    z-index: 999999;
    font-weight: 500;
    line-height: 1.6;
    isolation: isolate;
}

/* ===========================
   Rank Tracker SPECIFIC UI
   =========================== */

.rf-rank-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 15px 0 20px;
    flex-wrap: wrap;
}

.rf-rank-controls select,
.rf-rank-controls input {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--rf-border);
    background: #fff;
    font-size: 13px;
    box-shadow: var(--rf-shadow);
}

.rf-rank-controls button {
    padding: 8px 18px;
    border-radius: 10px;
    background: #D8B15A;
    border: none;
    color: #1a1a1a;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
    box-shadow: 0 2px 8px rgba(216, 177, 90, 0.3);
}

.rf-rank-controls button:hover {
    background: #C49A4A;
    color: #1a1a1a;
}

/* Rank Tracker table enhancements */
.rf-rank td {
    vertical-align: middle;
}

.rf-pos-up {
    color: var(--rf-up);
    font-weight: 600;
}

.rf-pos-down {
    color: var(--rf-down);
    font-weight: 600;
}

.rf-trend-mini {
    width: 90px;
    height: 26px;
    opacity: .9;
}

.rf-del-btn {
    padding: 6px 10px;
    border-radius: 6px;
    background: #f87171;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: .12s;
}

.rf-del-btn:hover {
    background: #dc2626;
}

/* --- Pagination fixes --- */
.rf-pagination{
  flex-wrap: wrap;
  align-items: center;
}

.rf-pagination .rf-page,
.rf-pagination .rf-btn{
  border: 1px solid var(--rf-border);
  user-select: none;
}

.rf-pagination .rf-btn{
  border: none !important;
}

.rf-pagination .rf-btn.rf-disabled{
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.rf-pagination .rf-dots{
  padding: 5px 6px;
  color: var(--rf-text-muted);
}

/* --- Table wrapper UX fix (and sticky header sanity) --- */
.rf-table-wrapper{
  overflow-x: auto;     /* was hidden */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.rf-table thead{
  position: sticky;
  top: 0;
  background: #f1f5f9;
}
/* RankFlow PRO toolbar + pagination polish */
.rf-toolbar-pro{
  align-items:center;
}
.rf-mini{
  font-size:12px;
  color:var(--rf-text-muted);
  margin-left:-6px;
  margin-right:10px;
}
.rf-check{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  color:var(--rf-text-dark);
  background:#fff;
  border:1px solid var(--rf-border);
  padding:8px 10px;
  border-radius:10px;
  box-shadow: var(--rf-shadow);
}
.rf-footer{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-top:14px;
  flex-wrap:wrap;
  align-items:center;
}
.rf-ellipsis{
  padding:8px 6px;
  color:var(--rf-text-muted);
}
.rf-btn.is-disabled{
  opacity:.5;
  cursor:not-allowed;
}
.rf-badge.rf-zero{
  background:#628CE8;
  box-shadow:none;
}
/* ===== RankFlow UI polish (drop at END of file) ===== */

.rf-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:14px;
  margin-bottom:14px;
}
.rf-title{ margin:0; font-size:18px; color:var(--rf-text-dark); }
.rf-sub{ margin:6px 0 0; color:var(--rf-text-muted); font-size:13px; }
.rf-head-actions .button{ height:34px; padding:0 12px; }

.rf-kpis{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  margin:12px 0 16px;
}
.rf-kpi{
  border:1px solid var(--rf-border);
  border-radius:14px;
  padding:12px 14px;
  background:#fff;
  box-shadow:0 8px 18px rgba(0,0,0,.05);
}
.rf-kpi-label{ font-size:12px; color:var(--rf-text-muted); }
.rf-kpi-value{ font-size:22px; font-weight:700; color:var(--rf-text-dark); margin-top:6px; }
.rf-kpi-sub{ font-size:12px; color:var(--rf-text-muted); margin-top:2px; }

.rf-overview-grid{
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  gap:12px;
}
.rf-box{ grid-column:span 4; }
.rf-box-wide{ grid-column:span 12; }

.rf-box-title{
  font-weight:700;
  color:var(--rf-text-dark);
  margin-bottom:8px;
}

.rf-list{ list-style:none; padding:0; margin:0; }
.rf-list li{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 0;
  border-bottom:1px dashed #e5e7eb;
}
.rf-list li:last-child{ border-bottom:0; }

.rf-list-2col{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:6px 18px;
}
.rf-list-2col li{
  border-bottom:0;
  padding:6px 0;
}

.rf-filters{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  padding:12px;
  border:1px solid var(--rf-border);
  border-radius:14px;
  background:#fff;
  margin:12px 0;
}
.rf-input, .rf-select{
  height:36px;
  border-radius:10px;
  box-shadow:none; /* cleaner */
}
.rf-btn{ 
    height:36px; 
    border-radius:10px; 
    font-weight: 600;
}

.rf-pagination .rf-ellipsis{
  padding:5px 6px;
  opacity:.6;
  cursor:default;
}

@media (max-width: 1100px){
  .rf-kpis{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .rf-box{ grid-column:span 12; }
  .rf-list-2col{ grid-template-columns:1fr; }
}

