/* ══════════════════════════════════════
   REWARD HUB GLOBAL STYLE
══════════════════════════════════════ */

:root {
  --bg-body:       #f5f5f5;
  --primary:       #e8392d;
  --primary-light: #fdecea;
  --sidebar-w:     200px;
  --card-radius:   4px;
  --card-shadow:   0 1px 4px rgba(0,0,0,.07);

  /* Platform Colors */
  --ch-ig:         #E1306C;
  --ch-fb:         #1877F2;
  --ch-yt:         #FF0000;
  --ch-tt:         #333333;

  --text-dark:     #222222;
  --text-muted:    #888888;

  /* Legacy variable mapping for compatibility */
  --purple:        var(--primary);
  --purple-light:  #ff6b5b;
  --ic-purple:     var(--primary);
  --ic-teal:       #26a69a;
  --ic-yellow:     #f59e0b;
  --ic-pink:       var(--primary);
  --ic-blue:       #1877F2;
  --ic-orange:     #E1306C;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Rubik', sans-serif;
  background: var(--bg-body);
  color: var(--text-dark);
  font-size: 14px;
}

/* ── Layout ── */
#page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid #e8e8e8;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 16px 18px 12px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand-icon i { color: #fff; font-size: 1.1rem; }
.sidebar-brand-text {
  font-size: 1.1rem; font-weight: 700;
  color: var(--primary) !important; letter-spacing: -.5px;
}

.sidebar-user {
  padding: 14px 18px 12px;
  display: flex; align-items: center;
  gap: 10px; border-bottom: 1px solid #f0f0f0;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #ff6b5b);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .82rem; flex-shrink: 0;
  position: relative;
}

/* ── Avatar Dropdown ── */
.avatar-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.avatar-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 180px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.avatar-dropdown.show {
  display: flex;
}

.avatar-dropdown-header {
  padding: 14px 16px;
  background: #f9f9f9;
  border-bottom: 1px solid #f0f0f0;
}

.avatar-dropdown-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.avatar-dropdown-role {
  font-size: .72rem;
  color: var(--text-muted);
}

.avatar-dropdown-body {
  padding: 6px 0;
}

.avatar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-dark);
  font-size: .82rem;
  text-decoration: none !important;
  transition: background .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.avatar-dropdown-item:hover {
  background: var(--bg-body);
}

.avatar-dropdown-item i {
  font-size: 1rem;
  color: var(--text-muted);
}

.avatar-dropdown-item.logout {
  color: var(--primary);
}

.avatar-dropdown-item.logout i {
  color: var(--primary);
}
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: var(--text-dark); line-height: 1.2; }
.sidebar-user-role { font-size: .72rem; color: var(--text-muted); }

.sidebar-nav { padding: 10px 0; flex: 1; }
.nav-section-title {
  padding: 8px 20px 4px;
  font-size: .66rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted);
}
.sidebar-nav .nav-item { margin: 1px 10px; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 4px;
  color: var(--text-dark); font-size: .82rem; font-weight: 400;
  transition: all .18s;
}
.sidebar-nav .nav-link i { font-size: 1rem; color: var(--text-muted); transition: color .18s; }
.sidebar-nav .nav-link:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.sidebar-nav .nav-link:hover i { color: var(--primary); }
.sidebar-nav .nav-link.active {
  background: rgba(232,57,45,.08); color: var(--primary);
  font-weight: 600; border-left: 3px solid var(--primary);
}
.sidebar-nav .nav-link.active i { color: var(--primary); }

.sidebar-add-btn {
  margin: 8px 14px 14px; display: block;
  background: var(--primary); color: #fff !important;
  border-radius: 4px; padding: 9px; font-size: .82rem;
  font-weight: 500; text-align: center; text-decoration: none !important;
  transition: background .18s;
}
.sidebar-add-btn:hover { background: #c62f24; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}

.top-navbar {
  background: #fff; border-bottom: 1px solid #e8e8e8;
  height: 56px; display: flex; align-items: center;
  padding: 0 24px; position: sticky; top: 0; z-index: 90; gap: 14px;
}
.top-navbar-left { display: flex; align-items: center; gap: 14px; flex: 1; }
.top-navbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-toggle { background: none; border: none; padding: 4px; cursor: pointer; color: var(--text-muted); font-size: 1.1rem; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-body); border-radius: 20px;
  padding: 6px 14px; font-size: .82rem; color: var(--text-muted);
}
.topbar-search i { font-size: .9rem; }
.topbar-icon-btn {
  background: none; border: none; padding: 6px;
  font-size: 1.05rem; color: var(--text-muted); cursor: pointer;
  border-radius: 50%; transition: background .15s;
}
.topbar-icon-btn:hover { background: var(--bg-body); }
.topbar-badge {
  position: absolute; top: 2px; right: 2px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--ic-orange);
  border: 2px solid #fff;
}
.campaign-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(232,57,45,.08); border-radius: 20px;
  padding: 4px 12px; font-size: .78rem; color: var(--primary); font-weight: 500;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #dc3545; flex-shrink: 0; }

.page-body { padding: 22px 26px 40px; }
.page-header { margin-bottom: 18px; }
.page-header h4 { font-size: 1.05rem; font-weight: 700; color: var(--text-dark); margin: 0 0 4px; }
.page-header h4 span { font-size: .82rem; font-weight: 400; color: var(--text-muted); margin-left: 6px; }
.breadcrumb { background: none; padding: 0; margin: 0; font-size: .74rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.breadcrumb-item a { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-muted); }

/* ── Cards & Section Titles ── */
.section-title {
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: 14px;
}
.card {
  border: 1px solid #e8e8e8 !important;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  background: #fff;
}
.card-body { padding: 20px 22px; }

/* ── Components ── */
.stat-mini { display: flex; align-items: center; gap: 16px; }
.stat-mini-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1.15rem;
}
.stat-mini-label { font-size: .78rem; color: var(--text-muted); margin-bottom: 2px; }
.stat-mini-value { font-size: 1.35rem; font-weight: 700; color: var(--text-dark); line-height: 1.1; }
.stat-mini-sub { font-size: .72rem; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 4px; }

.card-gradient {
  background: #fff; border: 1px solid #e8e8e8; border-top: 3px solid;
  border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  color: var(--text-dark); padding: 22px 24px 18px;
  position: relative; min-height: 120px;
}
.card-gradient .grad-title { font-size: .75rem; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.card-gradient .grad-value { font-size: 2.1rem; font-weight: 700; line-height: 1; margin-bottom: 10px; color: inherit; }
.card-gradient .grad-sub { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.card-gradient .grad-icon { position: absolute; top: 18px; right: 20px; font-size: 1.6rem; color: inherit; opacity: .18; }

.plat-card-body { padding: 18px 20px; }
.plat-icon-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.plat-circle { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.plat-name  { font-size: .82rem; color: var(--text-muted); }
.plat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-dark); line-height: 1; }
.plat-delta-pos { color: #26a69a; font-weight: 600; font-size: .82rem; }
.plat-delta-neg { color: #e8392d; font-weight: 600; font-size: .82rem; }
.plat-delta-neu { color: var(--text-muted); font-size: .82rem; }
.plat-metric-row { display: flex; justify-content: space-between; font-size: .78rem; padding: 4px 0; border-bottom: 1px solid #f5f4f9; }
.plat-metric-row:last-child { border-bottom: none; }
.plat-metric-label { color: var(--text-muted); }
.plat-metric-val   { font-weight: 500; color: var(--text-dark); }
.progress-sm { height: 4px; border-radius: 2px; background: #f0f0f0; margin-top: 12px; overflow: hidden; }
.progress-sm .prog-bar { height: 100%; border-radius: 2px; transition: width .5s; }

.icon-stat-card { display: flex; align-items: center; gap: 16px; padding: 20px 22px; }
.icon-stat-circle { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.icon-stat-title  { font-size: .78rem; color: var(--text-muted); margin-bottom: 2px; }
.icon-stat-value  { font-size: 1.4rem; font-weight: 700; color: var(--text-dark); line-height: 1.1; }
.icon-stat-sub    { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }

/* ── Table & Chart Header ── */
.table-card-header, .chart-card-header, .detail-table-header {
  padding: 16px 20px 12px; border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
}
.table-card-title, .chart-card-title, .detail-table-title { font-size: .88rem; font-weight: 700; color: var(--text-dark); }
.tbl-scroll { overflow-x: auto; }
.chart-card-body { padding: 10px 8px 8px; }

/* ── Detail Page Specific ── */
.month-tabs { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; }
.month-tabs-label { font-size: .85rem; font-weight: 600; color: var(--text-dark); }
#month-select {
  padding: 6px 12px; border: 1px solid #ddd; border-radius: 8px;
  background: #fff; font-size: .82rem; cursor: pointer; color: var(--text-dark);
  transition: all .15s; outline: none;
}
#month-select:hover, #month-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(232,57,45,.1); }

.channel-header { padding: 18px 20px 14px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid #f0f0f0; }
.channel-icon-lg { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
/* .channel-name-lg { font-size: .95rem; font-weight: 700; color: var(--text-dark); margin-bottom: 3px; } */
.channel-meta { font-size: .74rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge-status { display: inline-block; font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.badge-done { background: #26a69a; color: #fff; }
.badge-ing  { background: #f59e0b; color: #fff; }

.summary-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 1px; background: #f0f0f0; border-bottom: 1px solid #f0f0f0; }
.summary-item { background: #fff; padding: 13px 18px; }
.summary-label { font-size: .7rem; color: var(--text-muted); margin-bottom: 3px; }
.summary-value { font-size: 1.25rem; font-weight: 700; color: var(--text-dark); line-height: 1.1; }
.summary-sub { font-size: .68rem; color: var(--text-muted); margin-top: 2px; }

.btn-csv {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: calc(100% - 24px); margin: 12px; padding: 11px;
  background: var(--primary); color: #fff; border: none; border-radius: 4px;
  font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.btn-csv:hover { background: #c62f24; color: #fff; }

.chart-section { padding: 14px 18px 14px; }
.chart-section-title { font-size: .82rem; font-weight: 600; color: var(--text-dark); margin-bottom: 10px; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; font-size: .74rem; color: var(--text-muted); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

/* ── Global Tables ── */
table { width: 100%; border-collapse: collapse; }
table thead th {
  font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  padding: 10px 14px; background: #f9f9f9; white-space: nowrap;
  border-bottom: 1px solid #f0f0f0 !important;
}
table tbody td {
  padding: 9px 14px; border-bottom: 1px solid #f5f5f5 !important;
  vertical-align: middle; white-space: nowrap; color: var(--text-dark);
}
table tbody tr:hover { background: #fafafa; }
table tfoot td {
  padding: 10px 14px; font-weight: 700;
  border-top: 2px solid #e8e8e8 !important; font-size: .82rem;
}

/* ── Footer ── */
.page-footer {
  margin-top: 8px; font-size: .73rem; color: var(--text-muted);
  text-align: center; padding: 14px 0 0; border-top: 1px solid #e8e8e8;
}

/* ── Helpers ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-3 { margin-top: 1rem; }
.mr-1 { margin-right: 0.25rem; }
.delta-pos { color: #26a69a; font-weight: 600; }
.delta-neg { color: #e8392d; font-weight: 600; }
.delta-neu { color: var(--text-muted); }
