/* ============================================================
   SpamJammer Dashboard — Bento Grid Style
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
  --font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  --bg: #fafafa;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #64648c;
  --text-muted: #9e9eb8;
  --accent: #7C3AED;
  --accent-light: #ede9fe;
  --accent-dark: #5b21b6;
  --accent-gradient: linear-gradient(135deg, #7C3AED 0%, #a78bfa 100%);
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --border: #e8e8f0;
  --border-light: #f0f0f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 12px 40px rgba(124, 58, 237, 0.1);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --gap: 14px;
  --sidebar-width: 260px;
  --topnav-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  background: none;
}

/* --- Layout Shell --- */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topnav-height) 1fr;
  grid-template-areas:
    "sidebar topnav"
    "sidebar main";
  min-height: 100vh;
}

/* --- Top Navigation --- */
.topnav {
  grid-area: topnav;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.topnav-breadcrumb {
  font-size: 0.87rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.topnav-breadcrumb span {
  color: var(--text-primary);
  font-weight: 600;
}

.topnav-search {
  position: relative;
}

.topnav-search input {
  font-family: var(--font-family);
  font-size: 0.85rem;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  width: 280px;
  transition: var(--transition);
}

.topnav-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.topnav-search input::placeholder {
  color: var(--text-muted);
}

.topnav-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav-icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}

.topnav-icon-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.topnav-icon-btn svg {
  width: 20px;
  height: 20px;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.topnav-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 8px;
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
}

.topnav-user:hover {
  background: var(--bg);
}

.topnav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
}

.topnav-user-info {
  display: flex;
  flex-direction: column;
}

.topnav-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

.topnav-user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- Sidebar --- */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  height: var(--topnav-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.sidebar-logo-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sidebar-logo-text span {
  color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.3;
}

.sidebar-badge.warning {
  background: var(--warning);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-plan {
  background: var(--accent-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.sidebar-plan-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}

.sidebar-plan-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.sidebar-usage-bar {
  height: 6px;
  background: rgba(124, 58, 237, 0.15);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.sidebar-usage-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 1s ease;
}

.sidebar-usage-text {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.sidebar-usage-text strong {
  color: var(--text-primary);
}

/* --- Main Content --- */
.main-content {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.main-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.time-filter {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.time-filter button {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 8px;
  transition: var(--transition);
}

.time-filter button.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.time-filter button:hover:not(.active) {
  color: var(--text-primary);
}

/* --- Bento Grid --- */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(160px, auto);
  gap: var(--gap);
}

/* --- Bento Card Base --- */
.bento-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 22px;
  transition: var(--transition);
  opacity: 0;
  transform: translateY(16px);
  animation: cardAppear 0.5s ease forwards;
}

.bento-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

@keyframes cardAppear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bento-card:nth-child(1)  { animation-delay: 0.05s; }
.bento-card:nth-child(2)  { animation-delay: 0.10s; }
.bento-card:nth-child(3)  { animation-delay: 0.15s; }
.bento-card:nth-child(4)  { animation-delay: 0.20s; }
.bento-card:nth-child(5)  { animation-delay: 0.25s; }
.bento-card:nth-child(6)  { animation-delay: 0.30s; }
.bento-card:nth-child(7)  { animation-delay: 0.35s; }
.bento-card:nth-child(8)  { animation-delay: 0.40s; }
.bento-card:nth-child(9)  { animation-delay: 0.45s; }

/* Span classes */
.span-2-col { grid-column: span 2; }
.span-2-row { grid-row: span 2; }
.span-2x2   { grid-column: span 2; grid-row: span 2; }
.span-1x2   { grid-row: span 2; }

/* --- Stat Card (1x1) --- */
.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-icon.violet  { background: var(--accent-light); color: var(--accent); }
.stat-icon.green   { background: var(--success-light); color: var(--success); }
.stat-icon.red     { background: var(--danger-light); color: var(--danger); }
.stat-icon.blue    { background: var(--info-light); color: var(--info); }

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
}

.stat-trend.up   { background: var(--success-light); color: var(--success); }
.stat-trend.down { background: var(--danger-light); color: var(--danger); }
.stat-trend.flat { background: var(--bg); color: var(--text-muted); }

.stat-trend svg {
  width: 12px;
  height: 12px;
}

.stat-card-body {
  margin-top: 14px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-sublabel {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Activity Chart Card (2x2) --- */
.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card-title {
  font-size: 1rem;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  gap: 16px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chart-area {
  flex: 1;
  position: relative;
  min-height: 0;
}

.chart-canvas {
  width: 100%;
  height: 100%;
}

/* --- Threats Table Card (2x2) --- */
.threats-card {
  display: flex;
  flex-direction: column;
}

.threats-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.threats-card-title {
  font-size: 1rem;
  font-weight: 700;
}

.threats-card-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  transition: var(--transition);
}

.threats-card-link:hover {
  text-decoration: underline;
}

.threats-table-wrapper {
  flex: 1;
  overflow-y: auto;
}

.threats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.threats-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.threats-table tbody tr {
  transition: var(--transition);
}

.threats-table tbody tr:hover {
  background: var(--bg);
}

.threats-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.threat-sender {
  display: flex;
  flex-direction: column;
}

.threat-sender-email {
  font-weight: 600;
  color: var(--text-primary);
}

.threat-sender-domain {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.threat-type-badge {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.threat-type-badge.phishing  { background: var(--danger-light); color: var(--danger); }
.threat-type-badge.malware   { background: #fce7f3; color: #db2777; }
.threat-type-badge.spam      { background: var(--warning-light); color: #d97706; }
.threat-type-badge.scam      { background: #fef3c7; color: #b45309; }
.threat-type-badge.spoofing  { background: #e0e7ff; color: #4338ca; }

.threat-score {
  font-weight: 700;
  font-size: 0.82rem;
}

.threat-score.high   { color: var(--danger); }
.threat-score.medium { color: var(--warning); }

.threat-action {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.threat-time {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* --- Categories Card (1x2 span) --- */
.categories-card {
  display: flex;
  flex-direction: column;
}

.categories-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.categories-card-title {
  font-size: 1rem;
  font-weight: 700;
}

.categories-chart-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.categories-donut-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
}

.donut-canvas {
  width: 100%;
  height: 100%;
}

.donut-center-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-center-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.donut-center-text {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

.categories-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.category-name {
  flex: 1;
  color: var(--text-secondary);
  font-weight: 500;
}

.category-value {
  font-weight: 700;
  color: var(--text-primary);
}

.category-pct {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  width: 38px;
  text-align: right;
}

/* --- Blocked Domains Card (1x1) --- */
.domains-card {
  display: flex;
  flex-direction: column;
}

.domains-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.domains-card-title {
  font-size: 1rem;
  font-weight: 700;
}

.domains-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.domain-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.domain-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.domain-info {
  flex: 1;
  min-width: 0;
}

.domain-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.domain-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.domain-bar-wrapper {
  width: 50px;
  height: 5px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.domain-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
}

/* --- Quick Actions Card (1x1) --- */
.actions-card {
  display: flex;
  flex-direction: column;
}

.actions-card-header {
  margin-bottom: 14px;
}

.actions-card-title {
  font-size: 1rem;
  font-weight: 700;
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: var(--transition);
  text-align: center;
}

.action-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.action-btn:hover .action-btn-icon {
  background: var(--accent);
  color: #fff;
}

.action-btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.action-btn-icon svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.action-btn:hover .action-btn-icon svg {
  color: #fff;
}

.action-btn-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.action-btn:hover .action-btn-label {
  color: var(--accent);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .bento-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 960px) {
  :root {
    --sidebar-width: 0px;
  }
  .sidebar {
    display: none;
  }
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topnav-search input {
    width: 200px;
  }
}

@media (max-width: 640px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
  .span-2-col,
  .span-2x2 {
    grid-column: span 1;
  }
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .topnav-search {
    display: none;
  }
  .topnav-user-info {
    display: none;
  }
}
