/* Cryptosystems Marketing Intel - Dashboard Styles */

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

html {
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--lh-normal);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  font-family: var(--font-sans);
}

input {
  font-family: var(--font-sans);
}

/* ==============================
   LOGIN PAGE
   ============================== */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-10);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--sp-20);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--sp-16);
}

.login-logo h1 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

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

.login-logo p {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-top: var(--sp-2);
}

.form-group {
  margin-bottom: var(--sp-9);
}

.form-group label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-9);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  width: 100%;
  padding: var(--sp-6) var(--sp-9);
}

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

.btn-sm {
  padding: var(--sp-2) var(--sp-6);
  font-size: var(--fs-sm);
}

.login-error {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-6);
  color: var(--error);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-9);
  display: none;
}

.login-error.visible {
  display: block;
}

/* Password change form */
.password-change-form {
  display: none;
}

.password-change-form.visible {
  display: block;
}

/* ==============================
   DASHBOARD LAYOUT
   ============================== */

.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: var(--sp-10);
  border-bottom: 1px solid var(--border-default);
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.sidebar-header h1 span {
  color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-6) 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-10);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--overlay-light);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(0, 153, 255, 0.08);
  border-right: 2px solid var(--accent);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--sp-9);
  border-top: 1px solid var(--border-default);
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info .username {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
}

.btn-logout:hover {
  color: var(--error);
  background: rgba(231, 76, 60, 0.1);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 240px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-6) var(--sp-12);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.topbar-left h2 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  font-family: var(--font-display);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--sp-2);
}

.hamburger svg {
  width: 24px;
  height: 24px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--sp-2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Content area */
.content {
  padding: var(--sp-12);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ==============================
   KPI CARDS
   ============================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-9);
  margin-bottom: var(--sp-12);
}

.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-10);
  box-shadow: var(--shadow-subtle);
}

.kpi-card .kpi-label {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--fw-medium);
  margin-bottom: var(--sp-3);
}

.kpi-card .kpi-value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
}

.kpi-card .kpi-sub {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: var(--sp-2);
}

/* ==============================
   TABLES
   ============================== */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-tertiary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: var(--sp-4) var(--sp-6);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-default);
}

tbody td {
  padding: var(--sp-4) var(--sp-6);
  font-size: var(--fs-base);
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--overlay-light);
}

tbody tr:last-child td {
  border-bottom: none;
}

.content-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-cell.expanded {
  white-space: normal;
  max-width: none;
}

/* ==============================
   STATUS BADGES
   ============================== */

.badge {
  display: inline-block;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-2xl);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-draft {
  background: rgba(0, 153, 255, 0.15);
  color: var(--accent);
}

.badge-approved {
  background: rgba(46, 189, 107, 0.15);
  color: var(--success);
}

.badge-published {
  background: rgba(46, 189, 107, 0.25);
  color: var(--success);
}

.badge-rejected {
  background: rgba(231, 76, 60, 0.15);
  color: var(--error);
}

/* ==============================
   FILTER BAR
   ============================== */

.filter-bar {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-9);
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar select,
.filter-bar input[type="date"] {
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}

.filter-bar select:focus,
.filter-bar input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-pill {
  padding: var(--sp-2) var(--sp-6);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-subtle);
  background: none;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-pill.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* ==============================
   CHARTS
   ============================== */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-12);
  margin-bottom: var(--sp-12);
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-10);
  box-shadow: var(--shadow-subtle);
}

.chart-card h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-9);
}

.chart-container {
  position: relative;
  height: 280px;
}

/* ==============================
   A/B ANALYSIS
   ============================== */

.ab-grid {
  display: grid;
  gap: var(--sp-12);
}

.ab-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-9);
}

.ab-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-10);
  box-shadow: var(--shadow-subtle);
  position: relative;
}

.ab-card .variant-label {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: var(--sp-4);
}

.ab-card .variant-content {
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-6);
}

.ab-card .variant-meta {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.ab-winner {
  border-color: var(--success);
}

.ab-winner::after {
  content: 'Published';
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  background: var(--success);
  color: #ffffff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

/* ==============================
   INSIGHTS
   ============================== */

.insight-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  margin-bottom: var(--sp-12);
}

.insight-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-9);
  box-shadow: var(--shadow-subtle);
}

.insight-card .insight-text {
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-3);
}

.insight-card .insight-meta {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.insight-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-10);
}

.insight-form h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-6);
}

.insight-form textarea {
  width: 100%;
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  resize: vertical;
  min-height: 80px;
  margin-bottom: var(--sp-6);
}

.insight-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ==============================
   ACTIVITY FEED
   ============================== */

.activity-feed {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.activity-feed h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  padding: var(--sp-9) var(--sp-9) var(--sp-4);
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-9);
  border-top: 1px solid var(--border-default);
}

.feed-item:first-of-type {
  border-top: none;
}

.feed-content {
  flex: 1;
  min-width: 0;
}

.feed-content .feed-text {
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-content .feed-time {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* ==============================
   EMPTY STATE
   ============================== */

.empty-state {
  text-align: center;
  padding: var(--sp-32) var(--sp-10);
  color: var(--text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp-6);
  opacity: 0.4;
}

.empty-state p {
  font-size: var(--fs-md);
  margin-bottom: var(--sp-3);
}

.empty-state .empty-sub {
  font-size: var(--fs-sm);
}

/* ==============================
   SECTION HEADERS
   ============================== */

.section-header {
  margin-bottom: var(--sp-9);
}

.section-header h3 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}

.section-header p {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-top: var(--sp-1);
}

/* ==============================
   LOADING
   ============================== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-20);
  color: var(--text-secondary);
}

.loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--sp-4);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==============================
   MOBILE OVERLAY
   ============================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* ==============================
   RESPONSIVE
   ============================== */

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .ab-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger {
    display: block;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: var(--sp-6);
  }

  .topbar {
    padding: var(--sp-4) var(--sp-6);
  }
}
