/* ==========================================================================
   AIME CRM — Page-Specific Styles
   Layout shell, sidebar, topbar, and per-page styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   LOGIN PAGE
   -------------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-base);
}

@media (max-width: 768px) {
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-aside { display: none; }
}

/* Left side: branding panel */
.login-aside {
  background: #0e1a14;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.login-aside::before {
  content: '';
  position: absolute;
  top: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,212,184,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-aside::after {
  content: '';
  position: absolute;
  bottom: -200px;
  right: -200px;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,166,35,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-aside-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 40px;
}

.login-aside-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-aside-logo-mark {
  font-size: 28px;
  color: var(--aime-teal);
  font-family: var(--font-heading);
  line-height: 1;
}

.login-aside-logo-name {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.04em;
}

.login-aside-logo-tag {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.login-aside-headline {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.login-aside-headline .accent {
  background: linear-gradient(135deg, var(--aime-teal), var(--aime-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-aside-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.login-aside-stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 16px;
}

.login-aside-stat-value {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--aime-teal);
  letter-spacing: -0.02em;
  line-height: 1;
}

.login-aside-stat-label {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-top: 4px;
  line-height: 1.3;
}

.login-aside-footer {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  font-family: var(--font-mono);
}

/* Right side: form */
.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--surface-base);
}

.login-form-inner {
  width: 100%;
  max-width: 380px;
}

.login-form-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-form-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: 32px;
  line-height: var(--leading-relaxed);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-placeholder);
  font-size: var(--text-xs);
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--surface-border);
}

.otp-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.otp-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-base);
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.otp-input:focus {
  outline: none;
  border-color: var(--aime-teal);
  box-shadow: var(--shadow-focus);
}

.otp-input.filled {
  border-color: var(--aime-teal);
  background: var(--aime-teal-light);
}

/* --------------------------------------------------------------------------
   APP SHELL (Sidebar + Content Layout)
   -------------------------------------------------------------------------- */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--surface-base);
}

/* --------------------------------------------------------------------------
   SIDEBAR
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface-raised);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-slow);
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

/* Logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--surface-border);
  flex-shrink: 0;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-logo-mark {
  font-size: 22px;
  color: var(--aime-teal);
  font-family: var(--font-heading);
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition-base), width var(--transition-base);
}

.sidebar-logo-name {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.sidebar-logo-sub {
  font-size: 9px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

/* Nav sections */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-section {
  margin-bottom: var(--space-4);
}

.sidebar-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-placeholder);
  padding: 0 10px;
  margin-bottom: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .sidebar-section-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  user-select: none;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

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

.nav-item.active {
  background: var(--aime-teal-light);
  color: var(--text-teal);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--text-teal);
}

.nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: color var(--transition-fast);
}

.nav-label {
  flex: 1;
  transition: opacity var(--transition-base), width var(--transition-base);
  overflow: hidden;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.nav-badge {
  background: var(--aime-teal);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .nav-badge { opacity: 0; }

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

.sidebar-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
  border: none;
  background: none;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-toggle:hover {
  background: var(--surface-overlay);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   TOPBAR
   -------------------------------------------------------------------------- */
.topbar {
  height: var(--topbar-height);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  flex: 1;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.topbar-user:hover { background: var(--surface-overlay); }

.topbar-user-info {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.topbar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-user-role {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Notification bell */
.topbar-notif {
  position: relative;
}

.topbar-notif-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid var(--surface-raised);
}

/* --------------------------------------------------------------------------
   MAIN CONTENT AREA
   -------------------------------------------------------------------------- */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* --------------------------------------------------------------------------
   PAGE HEADER
   -------------------------------------------------------------------------- */
.page-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-raised);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   DASHBOARD PAGE
   -------------------------------------------------------------------------- */
.dashboard-grid {
  padding: var(--space-6);
  display: grid;
  gap: var(--space-5);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

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

.dashboard-body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-5);
}

@media (max-width: 1100px) {
  .dashboard-body { grid-template-columns: 1fr; }
}

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

/* --------------------------------------------------------------------------
   PIPELINE PAGE
   -------------------------------------------------------------------------- */
.pipeline-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pipeline-page .page-header {
  flex-shrink: 0;
}

.pipeline-meta {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  background: var(--surface-overlay);
  border-bottom: 1px solid var(--surface-border);
  font-size: var(--text-xs);
  flex-shrink: 0;
}

.pipeline-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-tertiary);
}

.pipeline-meta-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

.pipeline-scroll {
  flex: 1;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   ACCOUNTS & CONTACTS PAGES
   -------------------------------------------------------------------------- */
.list-page-content {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.list-toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.list-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.list-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.list-filter-chip:hover {
  border-color: var(--surface-border-strong);
  color: var(--text-primary);
}

.list-filter-chip.active {
  background: var(--aime-teal-light);
  border-color: rgba(0,168,150,0.3);
  color: var(--text-teal);
  font-weight: 600;
}

/* Account logo / initials chip */
.account-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-tertiary);
  flex-shrink: 0;
  overflow: hidden;
}

/* Health score bar */
.health-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.health-bar-track {
  flex: 1;
  height: 4px;
  background: var(--surface-inset);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 48px;
}

.health-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--aime-teal);
  transition: width 0.5s ease;
}

.health-bar-fill.warn { background: var(--aime-gold); }
.health-bar-fill.poor { background: var(--color-danger); }

/* --------------------------------------------------------------------------
   OPPORTUNITY DETAIL PAGE
   -------------------------------------------------------------------------- */
.opportunity-detail {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  height: 100%;
}

@media (max-width: 1100px) {
  .opportunity-detail { grid-template-columns: 1fr; }
  .opportunity-sidebar { display: none; }
}

.opportunity-main {
  overflow-y: auto;
  padding: var(--space-6);
  border-right: 1px solid var(--surface-border);
}

.opportunity-sidebar {
  overflow-y: auto;
  background: var(--surface-overlay);
}

.opp-header {
  margin-bottom: var(--space-6);
}

.opp-name {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.opp-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.opp-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.opp-value-callout {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: var(--space-4) 0;
}

.opp-value-amount {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.opp-value-currency {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--text-tertiary);
  font-weight: 600;
}

/* Stage progress indicator */
.stage-progress {
  display: flex;
  align-items: stretch;
  gap: 3px;
  margin: var(--space-5) 0;
}

.stage-step {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-inset);
  transition: background var(--transition-base);
}

.stage-step.done    { background: var(--aime-teal); }
.stage-step.current { background: var(--aime-gold); }

/* --------------------------------------------------------------------------
   REPORTS PAGE
   -------------------------------------------------------------------------- */
.reports-page {
  padding: var(--space-6);
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.report-card {
  cursor: pointer;
}

.report-card:hover {
  box-shadow: var(--shadow-md);
}

.report-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: var(--space-4);
}

/* --------------------------------------------------------------------------
   SETTINGS PAGE
   -------------------------------------------------------------------------- */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100%;
}

.settings-nav {
  border-right: 1px solid var(--surface-border);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--surface-overlay);
}

.settings-nav-item {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.settings-nav-item:hover { background: var(--surface-border); color: var(--text-primary); }
.settings-nav-item.active { background: var(--aime-teal-light); color: var(--text-teal); font-weight: 600; }

.settings-content {
  padding: var(--space-6);
  overflow-y: auto;
}

.settings-section {
  max-width: 600px;
}

.settings-section-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.settings-section-desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .page-content {
    padding-bottom: 80px;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-body {
    grid-template-columns: 1fr;
  }

  .opportunity-detail {
    grid-template-columns: 1fr;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }
}
