/* Import Lexend Deca */
@import url('https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@300;400;500;600&display=swap');

:root {
  --primary:        #1A73E8;
  --primary-dark:   #1557B0;
  --primary-light:  #E8F0FE;
  --surface:        #FFFFFF;
  --background:     #F8F9FA;
  --border:         #DADCE0;
  --text-primary:   #202124;
  --text-secondary: #5F6368;
  --text-muted:     #9AA0A6;
  --success:        #1E8E3E;
  --warning:        #F29900;
  --danger:         #D93025;
  --live:           #34A853;
  --sidebar-w:      240px;
  --topbar-h:       64px;
  --radius:         8px;
  --shadow-card:    0 1px 2px rgba(0,0,0,.1), 0 1px 3px rgba(0,0,0,.08);
  --shadow-hover:   0 2px 6px rgba(0,0,0,.15);
  --shadow-popover: 0 4px 12px rgba(0,0,0,.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Lexend Deca', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* --- App Shell --- */
.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  gap: 10px;
}
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 16px 24px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  margin: 4px 12px;
  height: 40px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--background); color: var(--text-primary); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}
.nav-item .material-symbols-outlined { font-size: 20px; color: inherit; }


/* --- Topbar --- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 500; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
}

/* --- Main Content --- */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.page-content { padding: 24px; }

/* --- Page Headers --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: 500; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  border-color: #DADCE0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 500;
  background: var(--surface);
  color: var(--text-primary);
}
.card-body { padding: 20px; }

/* --- Metric Cards --- */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { padding: 22px 20px; }
.metric-label { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.metric-label .material-symbols-outlined { font-size: 16px; color: var(--primary); }
.metric-value { font-size: 32px; font-weight: 600; color: var(--text-primary); line-height: 1; margin-bottom: 8px; letter-spacing: -0.02em; }
.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 100px;
  width: fit-content;
}
.metric-delta .material-symbols-outlined { font-size: 14px !important; }
.delta-up   { background: #E6F4EA; color: var(--success); }
.delta-down { background: #FCE8E6; color: var(--danger); }
.delta-neutral { background: var(--background); color: var(--text-secondary); }


/* --- Live Dot --- */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--live);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 168, 83, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(52, 168, 83, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 168, 83, 0); }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: 4px;
  font-family: 'Lexend Deca', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--background); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c5221f; }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn .material-symbols-outlined { font-size: 18px; }
.btn-icon-only { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn-icon-only.btn-sm { width: 28px; height: 28px; }
.btn-icon-only .material-symbols-outlined { margin: 0; font-size: 16px; }

/* --- Segmented Button Group --- */
.btn-group {
  display: inline-flex;
  border-radius: 6px;
  background: #F1F3F4;
  padding: 3px;
  border: 1px solid #DADCE0;
  gap: 2px;
}
.btn-group .btn {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}
.btn-group .btn:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.04);
}
.btn-group .btn.btn-primary {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-weight: 600;
}
.btn-group .btn.btn-primary:hover {
  background: var(--surface);
  color: var(--primary);
}



/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #E6F4EA; color: var(--success); }
.badge-warning { background: #FEF3E2; color: var(--warning); }
.badge-danger  { background: #FCE8E6; color: var(--danger); }
.badge-neutral { background: var(--background); color: var(--text-secondary); border: 1px solid var(--border); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead th {
  background: #F8F9FA;
  padding: 14px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 14px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-primary); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0, 0, 0, 0.015); }


/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Lexend Deca', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%235F6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }

/* --- Tabs --- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 12px 16px;
  font-family: 'Lexend Deca', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  text-decoration: none;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* --- Grid Systems --- */
.chart-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; margin-bottom: 24px; }
.chart-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; margin-bottom: 24px; }
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }

/* --- Site Card --- */
.site-card {
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s;
}
.site-card:hover { box-shadow: var(--shadow-hover); }
.site-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.site-card-name { font-weight: 500; font-size: 15px; color: var(--text-primary); }
.site-card-domain { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.site-card-sparkline { height: 40px; margin-bottom: 16px; }
.site-card-stats { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 12px; }
.site-stat { display: flex; flex-direction: column; }
.site-stat-value { font-weight: 600; font-size: 15px; }
.site-stat-label { font-size: 11px; color: var(--text-muted); }

/* --- Date Range Picker --- */
.date-range-picker { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--surface); }
.date-range-picker .btn { height: 30px; border-radius: 0; border: none; font-size: 12px; font-weight: 500; }
.date-range-picker .btn:not(:last-child) { border-right: 1px solid var(--border); }
.date-range-picker .btn.btn-primary { background: var(--primary); color: #fff; }
.date-range-picker .btn.btn-secondary { background: var(--surface); color: var(--text-secondary); }
.date-range-picker .btn.btn-secondary:hover { background: var(--background); }

/* --- Code Block --- */
.code-block {
  position: relative;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-top: 8px;
}
.code-block pre { margin: 0; font-family: Courier, monospace; font-size: 12px; overflow-x: auto; line-height: 1.5; color: var(--text-primary); }
.copy-btn {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s;
}
.copy-btn:hover { background: var(--background); }
.code-inline { background: var(--primary-light); color: var(--primary); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; }

/* --- Guide Cards --- */
.guide-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 12px; }
.guide-card { background: var(--background); border: 1px solid var(--border); border-radius: 6px; padding: 12px; }
.guide-card strong { font-size: 12px; text-transform: uppercase; color: var(--text-primary); display: block; margin-bottom: 4px; }
.guide-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

/* --- Donut Chart Custom Legend --- */
.chart-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.legend-item { display: flex; align-items: center; font-size: 12px; color: var(--text-secondary); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; flex-shrink: 0; }
.legend-label { flex: 1; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.legend-value { font-weight: 500; color: var(--text-primary); margin-left: 8px; }

/* --- Mini Progress Bars --- */
.progress-bar-mini { width: 60px; height: 6px; background: var(--border); border-radius: 100px; overflow: hidden; flex-shrink: 0; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 100px; }

/* --- Funnel Visualization --- */
.funnel-visualization { display: flex; flex-direction: column; gap: 16px; }
.funnel-step-row { display: flex; align-items: center; gap: 16px; }
.funnel-step-info { width: 160px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.funnel-step-num { width: 24px; height: 24px; background: var(--primary-light); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.funnel-bar-wrap { flex: 1; height: 24px; background: var(--background); border-radius: 4px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--primary-light); border-right: 3px solid var(--primary); transition: width .5s ease-out; }
.funnel-step-stats { width: 140px; display: flex; flex-direction: column; font-size: 13px; text-align: right; flex-shrink: 0; }

/* --- Alerts --- */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.alert-error { background: #FCE8E6; color: var(--danger); border: 1px solid #FCE8E6; }
.alert-success { background: #E6F4EA; color: var(--success); border: 1px solid #E6F4EA; }

/* --- Realtime Feed Row --- */
.recent-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.recent-event:last-child { border-bottom: none; }

/* --- Profile Settings Avatar --- */
.avatar-circle { width: 32px; height: 32px; background: var(--primary-light); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.avatar-large { width: 80px; height: 80px; background: var(--primary-light); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; overflow: hidden; border: 1px solid var(--border); }

/* --- Auth layout --- */
.auth-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--background); }
.auth-wrapper { width: 420px; padding: 24px 16px; }
.auth-card {
  background: var(--surface);
  border: 1px solid #E8EAED;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 16px -6px rgba(0,0,0,0.05);
  padding: 40px 32px;
}
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; }
.auth-logo-text { font-size: 22px; font-weight: 600; color: var(--primary); }
.auth-title { font-size: 22px; font-weight: 600; color: var(--text-primary); text-align: center; margin-bottom: 8px; letter-spacing: -0.02em; }
.auth-subtitle { font-size: 13.5px; color: var(--text-secondary); text-align: center; margin-bottom: 28px; line-height: 1.4; }
.auth-form .form-group { margin-bottom: 20px; }
.auth-card .form-control { height: 44px; border-radius: 6px; font-size: 14px; border-color: #DADCE0; }
.auth-card .btn { height: 44px; border-radius: 6px; font-size: 14.5px; transition: background 0.15s, box-shadow 0.15s; }
.auth-card .btn:hover { box-shadow: 0 4px 12px rgba(26, 115, 232, 0.2); }

.form-link { font-size: 12px; color: var(--primary); text-decoration: none; float: right; font-weight: 500; }
.form-link:hover { text-decoration: underline; }
.auth-alt { text-align: center; margin-top: 24px; font-size: 13.5px; color: var(--text-secondary); border-top: 1px solid var(--border); padding-top: 20px; }
.auth-alt a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-alt a:hover { text-decoration: underline; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 12px; color: var(--text-muted); }


/* --- Billing plan table highlighted row --- */
.billing-active-row { background: var(--primary-light) !important; }

/* --- Text Truncate Helper --- */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { width: 240px; transform: translateX(-240px); transition: transform .3s ease-in-out; }
  .sidebar.sidebar-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .public-header { flex-direction: column; align-items: flex-start; gap: 16px; }
}
