/* ==========================================================================
   TOOROCOLLAB: SAAS PORTAL LAYOUT & DASHBOARD DESIGN SYSTEM
   Aesthetic: Fintech & Linear-level Dashboard Polish
   ========================================================================== */

.portal-container {
  display: flex;
  min-height: 100vh;
  background: var(--bg-2);
  position: relative;
}

/* ================= PORTAL SIDEBAR ================= */
.portal-sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xs);
}

.portal-sidebar-header {
  height: 72px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-soft);
}

.portal-role-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}

.portal-role-tag.creator {
  background: var(--brand-primary-soft);
  color: var(--brand-primary-hover);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.portal-role-tag.brand {
  background: var(--brand-secondary-soft);
  color: var(--brand-secondary-hover);
  border: 1px solid rgba(20, 184, 166, 0.2);
}

.portal-role-tag.admin {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.portal-sidebar-nav {
  flex: 1;
  padding: 18px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.portal-nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  text-transform: uppercase;
  padding: 12px 14px 6px;
}

.portal-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  text-decoration: none;
}

.portal-nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: translateX(2px);
}

.portal-nav-item.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary-hover);
  font-weight: 600;
}

.portal-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--brand-primary);
  border-radius: 0 3px 3px 0;
}

.portal-nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.portal-sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.portal-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}

.portal-user-info {
  flex: 1;
  overflow: hidden;
}

.portal-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-user-sub {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================= PORTAL MAIN BODY ================= */
.portal-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-2);
}

@media (max-width: 960px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }
  .portal-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.25);
  }
  .portal-main {
    margin-left: 0;
  }
}

/* ================= PORTAL TOPBAR ================= */
.portal-topbar {
  height: 72px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

@media (max-width: 640px) {
  .portal-topbar {
    padding: 0 16px;
  }
}

.portal-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.portal-sidebar-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius-s);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

@media (max-width: 960px) {
  .portal-sidebar-toggle {
    display: flex;
  }
}

.portal-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.portal-breadcrumbs .sep {
  color: var(--text-faint);
  font-size: 12px;
}

.portal-breadcrumbs .current {
  font-weight: 600;
  color: var(--text);
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.portal-action-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  position: relative;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}

.portal-action-btn:hover {
  color: var(--brand-primary-hover);
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.portal-action-btn .dot-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--brand-primary);
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.portal-content {
  padding: 32px;
  flex: 1;
}

@media (max-width: 640px) {
  .portal-content {
    padding: 20px 16px;
  }
}

/* ================= METRIC STAT CARDS ================= */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

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

@media (max-width: 600px) {
  .metrics-row { grid-template-columns: 1fr; }
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.metric-card:hover::after {
  opacity: 1;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.metric-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-s);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary-soft);
  color: var(--brand-primary-hover);
  font-size: 16px;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
}

.metric-footer {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ================= DATA TABLES ================= */
.data-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-header-row {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--surface);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

table.data-table th {
  background: #f8faf9;
  padding: 13px 22px;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-soft);
}

table.data-table td {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-secondary);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background: rgba(16, 185, 129, 0.025);
  color: var(--text);
}

/* ================= CHAT / MESSAGING VIEW ================= */
.chat-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 160px);
  min-height: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

@media (max-width: 860px) {
  .chat-container { grid-template-columns: 1fr; }
  .chat-thread-list { display: none; }
}

.chat-thread-list {
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}

.chat-thread-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.chat-thread-item:hover, .chat-thread-item.active {
  background: var(--surface);
}

.chat-thread-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand-primary);
}

.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
}

.chat-window-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
}

.chat-messages-stream {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-2);
}

.chat-bubble {
  max-width: 72%;
  padding: 12px 18px;
  border-radius: var(--radius-m);
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-xs);
}

.chat-bubble.incoming {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 4px;
}

.chat-bubble.outgoing {
  align-self: flex-end;
  background: var(--brand-gradient);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.chat-input-row {
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface);
}

.chat-input-row input {
  flex: 1;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13.5px;
  outline: none;
}

.chat-input-row input:focus {
  background: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* ================= ESCROW & FINANCIAL CARDS ================= */
.escrow-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(20, 184, 166, 0.04) 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-m);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.escrow-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-soft);
  color: var(--brand-primary-hover);
  font-weight: 600;
  font-size: 12px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
