/* =========================================================
   APP LAYOUT
   ========================================================= */

.app {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-bottom: 22px;
  position: relative;
  z-index: 20;
}

.topbar-right {
  order: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-width: 0;
  flex-wrap: wrap;
}

.topbar-left {
  order: 2;
  min-width: 0;
  max-width: 100%;
}

.topbar-left h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.topbar-left p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

.topbar-page-actions {
  order: 3;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.topbar-page-actions.is-empty {
  display: none;
}

.topbar-actions {
  display: contents;
}

/* =========================================================
   USER PANEL
   ========================================================= */

.topbar-user-panel {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  min-width: 0;
  flex-wrap: wrap;
}

.topbar-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-balance-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.88);
  flex-shrink: 0;
}

.topbar-balance-icon svg {
  width: 21px;
  height: 21px;
}

.topbar-balance-value {
  font-size: 17px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-balance-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.95);
  color: #ff5b5b;
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   OLD PROFILE BLOCKS OFF
   ========================================================= */

.topbar-profile-wrap,
.topbar-profile-trigger,
.topbar-profile-menu {
  display: none !important;
}

/* =========================================================
   CHATS / PAGE ACTIONS FIX
   ========================================================= */

.topbar-page-actions .search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  max-width: 320px;
  width: 100%;
  flex: 1 1 240px;
}

.topbar-page-actions .search input {
  width: 100%;
  min-width: 0;
}

.topbar-page-actions .button {
  flex-shrink: 0;
  white-space: nowrap;
}

/* =========================================================
   PAGE WRAPPERS
   ========================================================= */

.stats-main-card,
.autofunnel-main-card,
.history-main-card,
.learning-main-card,
.sales-main-card,
.products-main-card,
.profile-main-card {
  width: 100%;
  max-width: 760px;
  min-width: 0;
}

.sales-main-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* =========================================================
   PROFILE PAGE
   ========================================================= */

.profile-main-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  box-shadow: 0 14px 28px rgba(59, 130, 246, 0.25);
}

.profile-avatar-large svg {
  width: 30px;
  height: 30px;
  color: #eff6ff;
}

.profile-head-text h3 {
  margin: 0 0 6px;
  font-size: 24px;
}

.profile-head-text p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.profile-item {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.profile-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.profile-item strong {
  font-size: 18px;
  color: var(--text);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 960px) {
  .app {
    flex-direction: column;
  }

  .main {
    padding: 18px;
    padding-top: 82px;
  }

  .stats-main-card,
  .autofunnel-main-card,
  .history-main-card,
  .learning-main-card,
  .sales-main-card,
  .products-main-card,
  .profile-main-card {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  .topbar {
    gap: 14px;
  }

  .topbar-user-panel {
    width: 100%;
    justify-content: flex-start;
    gap: 14px;
  }

  .topbar-page-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .topbar-page-actions .search {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .main {
    padding-left: 14px;
    padding-right: 14px;
    padding-top: 82px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar-left h2 {
    font-size: 24px;
  }

  .topbar-left p {
    font-size: 13px;
  }

  .topbar-user-panel {
    gap: 12px;
  }

  .topbar-balance {
    gap: 8px;
  }

  .topbar-balance-value {
    font-size: 16px;
  }

  .topbar-balance-badge {
    min-height: 28px;
    padding: 0 11px;
    font-size: 12px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
  }

  .topbar-right {
    gap: 10px;
  }

  .topbar-user-panel {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar-balance {
    width: auto;
    justify-content: flex-start;
    gap: 7px;
  }

  .topbar-balance-icon {
    width: 22px;
    height: 22px;
  }

  .topbar-balance-icon svg {
    width: 18px;
    height: 18px;
  }

  .topbar-balance-value {
    font-size: 15px;
  }

  .topbar-balance-badge {
    min-height: 25px;
    padding: 0 9px;
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  .topbar-right {
    gap: 12px;
  }

  .topbar-page-actions .button {
    width: 100%;
    justify-content: center;
  }

  .topbar-user-panel {
    gap: 8px;
  }

  .topbar-balance {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    row-gap: 8px;
  }
}

/* =========================================================
   SALES WIDTH OVERRIDE
   ========================================================= */

.sales-main-card {
  max-width: 1120px;
}