/* 
 * Leads Monopoly - Main App CSS 
 * Theme: Dark SaaS (Deep Navy/Gold)
 */

:root {
  /* Colors */
  --bg-app: #0a0e14;
  --bg-sidebar: #11151c;
  --bg-card: #161b24;
  --bg-input: #0f1623;

  --border-light: #1e293b;
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #fbbf24;
  --accent-hover: #f59e0b;
  --accent-text: #1e1b4b;

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Dimensions & Spacing */
  --sidebar-w: 260px;
  --header-h: 64px;
}

body.app-body {
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  margin: 0;
  font-family: 'Inter', sans-serif;
}

/* --- Layout Utility --- */
.app-wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
}

.app-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.app-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.container-fluid {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container-sm {
  max-width: 800px;
  margin: 0 auto;
}

/* Utilities */
.d-flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.gap-3 {
  gap: 1.5rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}

.w-100 {
  width: 100%;
}

.mobile-only {
  display: none !important;
}

/* --- Sidebar --- */
.app-sidebar {
  width: var(--sidebar-w);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-brand h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
}

.nav-group {
  margin-bottom: 1.5rem;
}

.nav-group-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.nav-link.active {
  background-color: var(--accent);
  color: var(--accent-text);
}

.nav-link.active svg {
  stroke: var(--accent-text);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-light);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
}

.user-snippet:hover {
  background: rgba(255, 255, 255, 0.03);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border-light);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Header --- */
.app-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background-color: var(--bg-app);
}

.page-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* --- Components --- */
/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  /* padding: 1.5rem;  -- Removed default padding to allow flush content */
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.card-header.no-border {
  border-bottom: none;
  padding-bottom: 0;
}

.card-body {
  padding: 1.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  border: none;
  gap: 0.5rem;
}

.btn-sm {
  height: 32px;
  padding: 0 0.75rem;
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

/* Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  width: 100%;
  font-size: 0.9rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

/* Tables */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-new {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.badge-contacted {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.badge-closed {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.badge-lost {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}


/* --- Dashboard Grid --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}


/* --- Settings View --- */
.settings-avatar-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
}

.settings-avatar {
  width: 80px;
  height: 80px;
  background: var(--bg-sidebar);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: var(--text-muted);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* --- Integrations View --- */
.integration-item {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.integration-item:last-child {
  border-bottom: none;
}

.integration-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.integration-info h4 {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.integration-info p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}


/* --- Pipeline / Kanban --- */
.pipeline-board {
  display: flex;
  gap: 1.5rem;
  height: calc(100vh - 140px);
  overflow-x: auto;
  padding-bottom: 1rem;
}

.pipeline-col {
  flex: 0 0 300px;
  background: var(--bg-sidebar);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.pipeline-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.pipeline-body {
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.deal-card {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  cursor: grab;
  transition: 0.2s;
}

.deal-card:hover {
  border-color: var(--text-dim);
}

.deal-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.deal-company {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.deal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.deal-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #333;
  font-size: 0.6rem;
  display: grid;
  place-items: center;
}

/* --- Chat / Conversations --- */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 100px);
  /* Fill remaining space */
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
}

.chat-list {
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  background: #13171f;
}

.chat-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: 0.2s;
}

.chat-item:hover,
.chat-item.active {
  background: rgba(255, 255, 255, 0.03);
}

.chat-item h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
}

.chat-item p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-view {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.msg-in {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  align-self: flex-start;
  border-bottom-left-radius: 0;
}

.msg-out {
  background: var(--accent);
  color: var(--accent-text);
  align-self: flex-end;
  border-bottom-right-radius: 0;
}

.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.75rem;
}

/* --- MOBILE RESPONSIVENESS (PHASE 5) --- */
@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex !important;
  }

  /* Layout Reset */
  .app-wrapper {
    position: relative;
  }

  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 25px rgba(0, 0, 0, 0.5);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  /* Overlay for sidebar */
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
  }

  .app-header {
    padding: 0 1rem;
  }

  /* Components */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  /* Integrations */
  .integration-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .integration-item>div:last-child {
    width: 100%;
  }

  .integration-item .btn {
    width: 100%;
  }

  /* Pipeline */
  .pipeline-board {
    padding-right: 1rem;
    /* Spacer */
  }

  /* Chat / Conversations Logic - Single Pane */
  .chat-layout {
    position: relative;
    grid-template-columns: 1fr;
  }

  .chat-view {
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 10;
  }

  .mobile-chat-active .chat-view {
    transform: translateX(0);
  }

  /* Settings */
  .settings-avatar-section {
    flex-direction: column;
    align-items: flex-start;
  }
}