/* ==========================================================
   Midas CRM — Dashboard (Redesign: B+C Hybrid)
   ========================================================== */

/* --- Hero Banner --- */
.dash-hero {
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--teal) 40%, var(--teal-light) 70%, var(--teal-light) 100%);
  border-radius: 14px;
  padding: 28px 36px 0;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-left: 4px solid var(--gold);
}

.dash-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 22px;
}

.dash-hero::after {
  content: '';
  position: absolute;
  right: -60px; top: -60px;
  width: 250px; height: 250px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}

.dash-hero-greeting {
  font-size: 26px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.dash-hero-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.dash-hero-sub strong { color: #F87171; font-weight: 600; }

.dash-hero-stats {
  display: flex;
  gap: 28px;
  position: relative;
  z-index: 1;
}

.dash-hero-stat { text-align: center; }

.dash-hero-stat-value {
  font-size: 32px;
  font-weight: 300;
  font-family: Georgia, serif;
  color: var(--gold);
  line-height: 1;
}

.dash-hero-stat-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

/* --- Action Cards Row --- */
.dash-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.action-card {
  padding: 18px 22px;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.action-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 12px 0 0 12px;
}

.action-card.accent-gold::before { background: var(--gold); }
.action-card.accent-red::before { background: var(--red); }
.action-card.accent-amber::before { background: #F59E0B; }

.action-card:hover { border-color: rgba(212,168,67,0.2); }

.action-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.action-card-label {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--light-gray);
}

.action-card-value {
  font-size: 20px;
  font-weight: 300;
  font-family: Georgia, serif;
  color: var(--gold);
  line-height: 1.2;
}

.action-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
  margin-top: 4px;
}

.action-card-meta {
  font-size: 11px;
  color: var(--light-gray);
  margin-top: 2px;
}

/* --- Main Grid --- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.dash-left,
.dash-right {
  display: flex;
  flex-direction: column;
}

.dash-right .crm-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dash-right .dash-timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dash-right .tl-item {
  flex: 1;
}

.dash-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.dash-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.dash-section-label {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 700;
}

/* --- Priority Jobs --- */
.dash-job-list { padding: 0; }

.dash-job-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border-light);
}

.dash-job-item:last-child { border-bottom: none; }
.dash-job-item:hover { background: var(--teal-pale); }

.dash-job-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--teal-pale);
  color: var(--teal);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

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

.dash-job-title {
  font-size: 13px; font-weight: 500;
  color: var(--text-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dash-job-client {
  font-size: 11px;
  color: var(--light-gray);
}

/* --- Today's Schedule Timeline --- */
.dash-timeline {
  padding: 16px 20px 16px 36px;
  position: relative;
}

.dash-timeline::before {
  content: '';
  position: absolute;
  left: 24px; top: 28px; bottom: 28px;
  width: 1px;
  background: var(--border);
}

.tl-item {
  position: relative;
  padding: 0 0 0 16px;
  min-height: 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tl-dot {
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--white);
}

.tl-dot-now {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--gold);
  box-shadow: 0 0 8px rgba(212,168,67,0.35);
}

.tl-time {
  font-size: 10px;
  color: var(--teal);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tl-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
  margin-top: 1px;
}

.tl-meta {
  font-size: 10px;
  color: var(--light-gray);
}

.tl-item.past .tl-title { color: var(--light-gray); }
.tl-item.past .tl-time { color: var(--border); }
.tl-item.past .tl-dot { background: var(--border-light); }

.tl-item.now .tl-time { color: var(--gold); }
.tl-item.now .tl-title { color: var(--gold); }

/* Empty hour slots — same height as event slots, clearly distinguishable */
.tl-item.empty {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.tl-item.empty .tl-time {
  color: #B8AFA4;
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 52px;
}
.tl-open-label {
  font-size: 10px;
  color: #C4BBB2;
  font-style: italic;
  flex-shrink: 0;
}
.tl-item.empty::after {
  content: '';
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    #D5CEC6 0px, #D5CEC6 4px,
    transparent 4px, transparent 9px
  );
  opacity: 0.7;
  margin-right: 12px;
}
.tl-dot-empty {
  width: 5px;
  height: 5px;
  top: 50%;
  transform: translateY(-50%);
  left: -16px;
  background: #D5CEC6;
  border: 1px solid #C4BBB2;
}
.tl-item.empty.past .tl-time { color: #CEC7BF; }
.tl-item.empty.past .tl-open-label { color: #D5CEC6; }
.tl-item.empty.past::after { opacity: 0.35; }
.tl-item.empty.now .tl-time { color: var(--gold); }
.tl-item.empty.now .tl-open-label { color: rgba(212,168,67,0.6); }
.tl-item.empty.now::after { background: repeating-linear-gradient(to right, rgba(212,168,67,0.35) 0px, rgba(212,168,67,0.35) 4px, transparent 4px, transparent 9px); opacity: 1; }

.dash-schedule-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--light-gray);
  font-size: 13px;
}

.dash-schedule-empty svg {
  width: 32px; height: 32px;
  color: var(--border);
  margin-bottom: 10px;
}

/* --- Activity Feed (kept from original) --- */
.dash-feed-card { min-height: 200px; }

.dash-feed-body {
  max-height: 520px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}

.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--teal-pale); }

.feed-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--teal-pale);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
}

.feed-icon svg { width: 16px; height: 16px; }

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

.feed-text {
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.45;
}

.feed-text strong { font-weight: 600; }

.feed-time {
  font-size: 11px;
  color: var(--light-gray);
  margin-top: 3px;
}

.feed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--light-gray);
}

.feed-empty svg { width: 36px; height: 36px; color: var(--border); margin-bottom: 12px; }
.feed-empty p { font-size: 14px; font-weight: 600; color: var(--text-dark); margin: 0 0 4px; }
.feed-empty span { font-size: 12px; color: var(--light-gray); }

.feed-show-more {
  display: block;
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  border-top: 1px solid var(--border-light);
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.feed-show-more:hover { background: var(--teal-pale); }

.dash-feed-body::-webkit-scrollbar { width: 4px; }
.dash-feed-body::-webkit-scrollbar-track { background: transparent; }
.dash-feed-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-actions { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .dash-hero-top { flex-direction: column; gap: 16px; align-items: flex-start; }
  .dash-hero-stats { gap: 16px; }
}

/* ==========================================================
   Dashboard Dark Mode
   Scoped to body.dash-dark — only affects the dashboard page
   ========================================================== */

.dash-dark .main-content {
  background: #FFFFFF;
}

.dash-dark .page-header {
  background: #FFFFFF;
  border-bottom-color: rgba(28,21,14,0.12);
}

.dash-dark .page-title {
  color: var(--text-strong);
}

.dash-dark .btn-external {
  color: #AAA;
  border-color: rgba(255,255,255,0.1);
}

.dash-dark .btn-external:hover {
  color: #F5F5F0;
  border-color: rgba(212,168,67,0.3);
}

/* Cards */
.dash-dark .crm-card {
  background: #FFFFFF;
  border-color: rgba(28,21,14,0.10);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.dash-dark .crm-card:hover {
  border-color: rgba(212,168,67,0.25);
}

/* Action cards */
.dash-dark .action-card-label { color: var(--light-gray); }
.dash-dark .action-card-title { color: var(--text-strong); }
.dash-dark .action-card-meta { color: var(--light-gray); }

/* Section labels */
.dash-dark .dash-section-label { color: var(--teal); }
.dash-dark .dash-section-header::after { background: rgba(28,21,14,0.10); }

/* Priority Jobs */
.dash-dark .dash-job-item { border-bottom-color: rgba(28,21,14,0.07); }
.dash-dark .dash-job-item:hover { background: rgba(212,168,67,0.06); }
.dash-dark .dash-job-title { color: var(--text-strong); }
.dash-dark .dash-job-client { color: var(--light-gray); }
.dash-dark .dash-job-num { background: rgba(212,168,67,0.10); }

/* Schedule Timeline */
.dash-dark .dash-timeline::before { background: rgba(28,21,14,0.12); }
.dash-dark .tl-title { color: var(--text-strong); }
.dash-dark .tl-meta { color: var(--light-gray); }
.dash-dark .tl-time { color: var(--gold); }
.dash-dark .tl-dot { background: var(--border); border-color: #FFFFFF; }
.dash-dark .tl-item.past .tl-title { color: var(--light-gray); }
.dash-dark .tl-item.past .tl-time { color: var(--border); }
.dash-dark .tl-item.past .tl-dot { background: rgba(28,21,14,0.12); }
.dash-dark .tl-item.now .tl-title { color: var(--gold); }
.dash-dark .dash-schedule-empty { color: var(--light-gray); }
.dash-dark .dash-schedule-empty svg { color: var(--border); }
.dash-dark .tl-item.empty .tl-time { color: #B8AFA4; }
.dash-dark .tl-open-label { color: #C4BBB2; }
.dash-dark .tl-dot-empty { background: #D5CEC6; border-color: #C4BBB2; }
.dash-dark .tl-item.empty::after { background: repeating-linear-gradient(to right, #D5CEC6 0px, #D5CEC6 4px, transparent 4px, transparent 9px); }

/* Activity Feed */
.dash-dark .feed-item { border-bottom-color: rgba(28,21,14,0.07); }
.dash-dark .feed-item:hover { background: rgba(212,168,67,0.06); }
.dash-dark .feed-icon { background: rgba(212,168,67,0.10); color: var(--gold); }
.dash-dark .feed-text { color: var(--dark-gray); }
.dash-dark .feed-text strong { color: var(--text-strong); }
.dash-dark .feed-time { color: var(--light-gray); }
.dash-dark .feed-empty { color: var(--light-gray); }
.dash-dark .feed-empty p { color: var(--dark-gray); }
.dash-dark .feed-empty svg { color: var(--border); }
.dash-dark .feed-show-more { color: var(--gold); border-top-color: rgba(28,21,14,0.07); }
.dash-dark .feed-show-more:hover { background: rgba(212,168,67,0.06); }

/* ==========================================================
   AI Morning Email Digest Widget
   ========================================================== */

.dash-digest-section { margin-bottom: 24px; }

/* Loading */
.digest-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  color: var(--light-gray);
  font-size: 13px;
}
.digest-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: digest-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes digest-spin { to { transform: rotate(360deg); } }

/* Empty */
.digest-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  color: var(--light-gray);
  font-size: 13px;
}
.digest-empty svg { color: var(--border); }

/* Proxy offline banner */
.digest-proxy-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #FFF8E1;
  color: #7A5800;
  font-size: 12px;
  border-bottom: 1px solid #FFE082;
  border-radius: 10px 10px 0 0;
}
.digest-proxy-banner code {
  background: rgba(0,0,0,0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
}

/* List */
.digest-list { display: flex; flex-direction: column; }

/* Item */
.digest-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--pale);
  transition: background 0.15s, opacity 0.3s;
  flex-wrap: wrap;
}
.digest-item:last-child { border-bottom: none; }
.digest-item:hover { background: rgba(212,168,67,0.04); }

/* Quick actions (dismiss only — visible when collapsed) */
.digest-item-quick-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Expanded email body */
.digest-item-expanded {
  width: 100%;
  padding: 0 0 4px 46px;
}
.digest-expanded-content {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 16px 20px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.digest-full-body {
  font-size: 13px;
  line-height: 1.65;
  color: #1a1a1a;
  word-break: break-word;
}
.digest-full-body img { max-width: 100%; height: auto; }
.digest-expanded-actions {
  display: flex;
  gap: 8px;
  padding-top: 6px;
}
.digest-expanded-loading {
  font-size: 12px;
  color: var(--light-gray);
  font-style: italic;
  padding: 6px 0;
}

.digest-item-left { flex-shrink: 0; padding-top: 2px; }

.digest-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--teal-pale);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
}

.digest-item-body { flex: 1; min-width: 0; }

.digest-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.digest-item-from {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.digest-item-time {
  font-size: 11px;
  color: var(--light-gray);
  white-space: nowrap;
  flex-shrink: 0;
}
.digest-item-subject {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.digest-item-preview {
  font-size: 12px;
  color: var(--light-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.digest-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}
.digest-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
}
.digest-tag-job { font-weight: 600; }
.digest-tag-confidence { background: #F5F5F5; color: #757575; }
.digest-tag-client {
  background: var(--teal-pale);
  color: var(--teal);
  cursor: pointer;
}
.digest-tag-client:hover { opacity: 0.8; text-decoration: underline; }
.digest-item-reasoning {
  font-size: 11px;
  color: var(--light-gray);
  font-style: italic;
  margin-top: 2px;
}

/* Actions */
.digest-item-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  align-items: flex-end;
  padding-top: 2px;
}

/* Dark mode */
.dash-dark .digest-proxy-banner {
  background: rgba(255,224,130,0.12);
  color: #FFD54F;
  border-bottom-color: rgba(255,213,79,0.2);
}
.dash-dark .digest-proxy-banner code { background: rgba(255,255,255,0.1); }
.dash-dark .digest-item:hover { background: rgba(212,168,67,0.06); }
.dash-dark .digest-item { border-bottom-color: rgba(28,21,14,0.1); }
.dash-dark .digest-expanded-content { background: #fff; border-color: #e0e0e0; }
.dash-dark .digest-full-body { color: #1a1a1a; }
.dash-dark .digest-avatar { background: rgba(212,168,67,0.12); color: var(--gold); }
.dash-dark .digest-item-from { color: var(--text-strong); }
.dash-dark .digest-tag-confidence { background: rgba(255,255,255,0.06); color: #aaa; }
.dash-dark .digest-tag-client { background: rgba(212,168,67,0.12); color: var(--gold); }
.dash-dark .digest-item-reasoning { color: #888; }

/* --- Hero Digest Strip --- */
.dash-hero-digest-strip {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 12px 0 18px;
}

.dash-hero-digest-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Hero-mode overrides for digest items */
#dash-hero-digest .digest-loading {
  color: rgba(255,255,255,0.45);
}
#dash-hero-digest .digest-spinner {
  border-color: rgba(255,255,255,0.15);
  border-top-color: var(--gold);
}
#dash-hero-digest .digest-empty {
  color: rgba(255,255,255,0.35);
  padding: 8px 0 4px;
}
#dash-hero-digest .digest-empty svg { color: rgba(255,255,255,0.15); }

#dash-hero-digest .digest-list {
  gap: 5px;
  display: flex;
  flex-direction: column;
}
#dash-hero-digest .digest-item {
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  border-bottom: none;
  padding: 9px 12px;
  align-items: center;
}
#dash-hero-digest .digest-item:hover { background: rgba(255,255,255,0.11); }
#dash-hero-digest .digest-avatar {
  width: 30px; height: 30px;
  background: rgba(212,168,67,0.25);
  color: var(--gold);
  font-size: 10px;
}
#dash-hero-digest .digest-item-from { color: #fff; font-size: 13px; }
#dash-hero-digest .digest-item-time { color: rgba(255,255,255,0.4); }
#dash-hero-digest .digest-item-subject { color: rgba(255,255,255,0.75); font-size: 12px; }
#dash-hero-digest .digest-item-preview { display: none; }
#dash-hero-digest .digest-item-reasoning { display: none; }
#dash-hero-digest .digest-item-tags { margin-bottom: 0; }
#dash-hero-digest .digest-tag-confidence {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
}
#dash-hero-digest .digest-tag-client {
  background: rgba(212,168,67,0.2);
  color: var(--gold);
}
#dash-hero-digest .digest-item[style*="opacity: 0.4"] { opacity: 0.35 !important; }
#dash-hero-digest .digest-item-quick-actions { flex-direction: row; align-items: center; }
#dash-hero-digest .digest-item-expanded { padding-left: 42px; }
#dash-hero-digest .digest-expanded-content { background: #fff; border-color: #e0e0e0; }
#dash-hero-digest .digest-full-body { color: #1a1a1a; }
#dash-hero-digest .digest-expanded-actions { flex-direction: row; align-items: center; }
#dash-hero-digest .btn-outline {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.7);
}
#dash-hero-digest .btn-outline:hover {
  border-color: rgba(255,255,255,0.6);
  color: #fff;
  background: rgba(255,255,255,0.08);
}
#dash-hero-digest .digest-proxy-banner {
  background: rgba(255,224,130,0.1);
  color: rgba(255,213,79,0.8);
  border: none;
  border-radius: 6px;
  margin-bottom: 8px;
}
#dash-hero-digest .digest-proxy-banner code { background: rgba(255,255,255,0.1); }
