/* =========================================================
   Code In Motion — Minimalist Communicator Stylesheet
   Theme: Apple Clean Messenger (Chat, Audio & Video)
   ========================================================= */

:root {
  --accent: #0071e3;
}

body.portal-body {
  background: var(--bg-subtle, #fbfbfd);
  color: var(--ink, #1d1d1f);
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   Header
   ========================================================= */
.portal-header {
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 32px);
  flex-shrink: 0;
  z-index: 100;
}

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

.portal-brand .logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
}

.portal-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34c759;
  display: inline-block;
}

.status-dot.pulsing {
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.25);
  animation: pulse-ring 2.5s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}

/* Call Actions & Profile */
.portal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-call-action {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.btn-call-action:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-call-action svg,
.btn-call-action i {
  width: 14px;
  height: 14px;
  color: var(--ink);
}

.btn-call-action.audio:hover svg,
.btn-call-action.audio:hover i {
  color: #34c759;
}

.btn-call-action.video {
  background: var(--blue-subtle);
  border-color: rgba(0, 113, 227, 0.2);
  color: var(--accent);
}

.btn-call-action.video:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-call-action.video:hover svg,
.btn-call-action.video:hover i {
  color: #ffffff;
}

.btn-call-action.in-call {
  background: #ff3b30 !important;
  color: #ffffff !important;
  border-color: #ff3b30 !important;
}

.btn-call-action.in-call svg,
.btn-call-action.in-call i {
  color: #ffffff !important;
}

/* User Profile Pill & Dropdown */
.user-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.user-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 10px 3px 4px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: all 0.18s var(--ease);
}

.user-profile-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.user-profile-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}

.user-avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--mono);
  flex-shrink: 0;
}

.user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.dropdown-chevron {
  width: 13px;
  height: 13px;
  color: var(--ink-tertiary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.user-dropdown-wrapper.active .dropdown-chevron {
  transform: rotate(180deg);
}

/* Floating Dropdown Menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 215px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 8px;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}

.user-dropdown-wrapper.active .user-dropdown-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dropdown-client-info {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dropdown-client-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
}

.dropdown-client-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.dropdown-client-email {
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--ink-secondary);
  word-break: break-all;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0 6px;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dropdown-item.signout-item {
  color: #ff3b30;
}

.dropdown-item.signout-item:hover {
  background: rgba(255, 59, 48, 0.08);
}

.dropdown-item svg,
.dropdown-item i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* =========================================================
   Communicator Main Workspace
   ========================================================= */
.portal-main {
  flex: 1;
  display: flex;
  justify-content: center;
  height: calc(100vh - 60px);
  overflow: hidden;
  position: relative;
}

.portal-main.has-sidebar {
  justify-content: flex-start;
}

.portal-main.has-sidebar .chat-container {
  flex: 1;
  min-width: 0;
  max-width: none;
  border-inline: none;
}

/* Sidebar Toggle in Brand bar */
.btn-sidebar-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm, 6px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-right: 4px;
}

.btn-sidebar-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-sidebar-toggle svg,
.btn-sidebar-toggle i {
  width: 15px;
  height: 15px;
}

/* Studio Admin Clients Sidebar */
.admin-sidebar {
  width: 290px;
  height: 100%;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.btn-invite-client {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.btn-invite-client:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-invite-client svg,
.btn-invite-client i {
  width: 12px;
  height: 12px;
}

.clients-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--ink-secondary);
}

/* Segmented Tab Switcher (Active vs Archived) */
.admin-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: 9px;
  gap: 2px;
}

.admin-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-tab:hover {
  color: var(--ink);
}

.admin-tab.active {
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.admin-tab .tab-count {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink-secondary);
}

.admin-tab.active .tab-count {
  background: var(--blue-subtle);
  color: var(--accent);
}

.admin-search-wrapper {
  position: relative;
}

.admin-search-input {
  width: 100%;
  padding: 7px 11px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.admin-search-input:focus {
  border-color: var(--accent);
}

.admin-clients-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.admin-client-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  width: 100%;
}

.admin-client-card:hover {
  background: var(--surface);
}

.admin-client-card.active {
  background: var(--surface-hover);
  border-color: var(--border);
}

.admin-client-card.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.client-card-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  flex-shrink: 0;
}

.admin-client-card.active .client-card-avatar {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.client-card-info {
  flex: 1;
  min-width: 0;
}

.client-card-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

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

.client-card-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-tertiary);
  flex-shrink: 0;
}

.client-card-snippet {
  font-size: 11.5px;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* =========================================================
   Left Navigation: clients (admin) + video chats
   ========================================================= */
.portal-nav {
  display: flex;
  height: 100%;
  flex-shrink: 0;
  z-index: 40;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-sidebar-toggle {
  position: relative;
}

.btn-sidebar-toggle.has-unread::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
}

/* Unread count pill (shared by client cards and chat items) */
.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-client-card.has-unread .client-card-name,
.admin-client-card.has-unread .client-card-snippet {
  color: var(--ink);
  font-weight: 600;
}

.admin-client-card.has-unread .client-card-snippet {
  font-weight: 500;
}

/* Video chats column */
.projects-panel {
  width: 260px;
  height: 100%;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.projects-panel-header {
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-new-video {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.btn-new-video:hover {
  background: var(--blue-hover);
}

.btn-new-video:active {
  transform: scale(0.98);
}

.btn-new-video:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-new-video svg,
.btn-new-video i {
  width: 15px;
  height: 15px;
}

.projects-panel-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.projects-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.projects-empty {
  padding: 20px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-tertiary);
  text-align: center;
}

.project-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}

.project-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.project-item.active {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.project-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

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

.project-item-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-tertiary);
  flex-shrink: 0;
}

.project-item-snippet {
  font-size: 11.5px;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item.draft .project-item-snippet {
  font-style: italic;
}

.project-item.has-unread .project-item-title {
  font-weight: 700;
}

.project-item.has-unread .project-item-snippet {
  color: var(--ink);
  font-weight: 500;
}

.project-item.has-unread .project-item-time {
  color: var(--accent);
  font-weight: 600;
}

/* Brief highlight when a new message lands in a background chat */
.project-item.just-updated,
.admin-client-card.just-updated {
  animation: nav-flash 1.4s var(--ease);
}

@keyframes nav-flash {
  0%, 30% { background: var(--blue-subtle); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .project-item.just-updated,
  .admin-client-card.just-updated {
    animation: none;
  }
}

/* Active project header above the messages */
.project-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}

.project-bar-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.project-bar-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-title-input {
  width: 100%;
  max-width: 420px;
  padding: 3px 8px;
  margin-left: -9px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-subtle);
}

.project-bar-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-tertiary);
}

/* Active Client Bar inside Chat Header */
.active-client-bar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.active-client-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.active-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.active-client-details h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.active-email {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-secondary);
}

.active-tag.archived {
  background: rgba(255, 149, 0, 0.12);
  color: #d97706;
  border-radius: 4px;
  padding: 2px 6px;
}

.active-client-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-client-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  transition: all 0.15s var(--ease);
}

.btn-client-action:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.btn-client-action svg,
.btn-client-action i {
  width: 13px;
  height: 13px;
}

.btn-client-action.archive:hover {
  border-color: rgba(255, 149, 0, 0.4);
  color: #ff9500;
  background: rgba(255, 149, 0, 0.08);
}

.btn-client-action.delete:hover {
  border-color: rgba(255, 59, 48, 0.4);
  color: #ff3b30;
  background: rgba(255, 59, 48, 0.08);
}

.chat-container {
  width: 100%;
  max-width: 820px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-inline: 1px solid var(--border);
  position: relative;
}

/* Messages Stream */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px clamp(16px, 3vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-subtle);
}

.date-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 12px 0 6px;
}

.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.date-divider span {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-tertiary);
  padding: 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Message Bubble Items */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msg-appear 0.2s var(--ease);
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Studio Message (Left-aligned) */
.message-row.studio {
  align-self: flex-start;
}

.message-row.studio .msg-bubble {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.message-row.studio .msg-sender-tag {
  color: var(--accent);
}

/* Client Message (Right-aligned) */
.message-row.client {
  align-self: flex-end;
  /* Undo the marketing-site .client card styles from style.css */
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  gap: 0;
  box-shadow: none;
  transition: none;
}

.message-row.client:hover {
  transform: none;
  box-shadow: none;
}

.message-row.client .msg-bubble {
  background: #1d1d1f;
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-row.client .msg-sender-tag {
  color: var(--ink-tertiary);
  text-align: right;
}

.message-row.client .msg-meta {
  justify-content: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 4px;
}

.msg-author {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.msg-role-tag {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink-tertiary);
}

.message-row.studio .msg-role-tag {
  background: var(--blue-subtle);
  color: var(--accent);
}

.msg-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-tertiary);
}

.msg-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.message-row.client .msg-bubble a {
  color: #5ac8fa;
  text-decoration: underline;
}

.message-row.studio .msg-bubble a {
  color: var(--accent);
  text-decoration: underline;
}

/* Call Invitation Card in Chat */
.call-invite-row {
  align-self: center;
  width: 100%;
  max-width: 480px;
  margin: 6px 0;
}

.call-card {
  background: #ffffff;
  border: 1px solid rgba(52, 199, 89, 0.35);
  border-left: 3px solid #34c759;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.call-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(52, 199, 89, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #34c759;
}

.call-card-icon svg,
.call-card-icon i {
  width: 16px;
  height: 16px;
}

.call-card-text h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 2px 0;
  color: var(--ink);
}

.call-card-text p {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-secondary);
  margin: 0;
}

.btn-join-call {
  background: #34c759;
  color: #ffffff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-join-call:hover {
  background: #2db84d;
  transform: scale(1.02);
}

/* =========================================================
   Composer
   ========================================================= */
.chat-composer {
  padding: 12px 20px 20px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
  background: #ffffff;
}

.composer-textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 140px;
}

.composer-textarea::placeholder {
  color: var(--ink-tertiary);
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--ink-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.tool-btn:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.tool-btn svg,
.tool-btn i {
  width: 15px;
  height: 15px;
}

.composer-send {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-tertiary);
}

.btn-send {
  background: var(--accent);
  color: #ffffff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-send:hover {
  background: var(--blue-hover);
  transform: scale(1.05);
}

.btn-send svg,
.btn-send i {
  width: 14px;
  height: 14px;
  margin-left: 1px;
}

/* =========================================================
   In-Page Daily.co Video / Audio Call Drawer
   ========================================================= */
.call-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 480px;
  height: 100%;
  background: #111113;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.35s var(--ease);
}

.call-drawer.open {
  transform: translateX(0);
}

.call-drawer.minimized {
  position: fixed;
  bottom: 24px;
  right: 24px;
  top: auto;
  width: 320px;
  height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.call-drawer-header {
  height: 48px;
  padding: 0 14px;
  background: #1a1a1c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
}

.call-drawer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.call-type-indicator {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(52, 199, 89, 0.2);
  color: #34c759;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.call-type-indicator svg,
.call-type-indicator i {
  width: 12px;
  height: 12px;
}

.call-timer {
  font-family: var(--mono);
  font-size: 11px;
  color: #34c759;
  background: rgba(52, 199, 89, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.call-drawer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-control-btn {
  background: transparent;
  border: none;
  color: #8e8e93;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.call-control-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.call-control-btn.btn-leave {
  color: #ff453a;
}

.call-control-btn.btn-leave:hover {
  background: rgba(255, 69, 58, 0.2);
}

.call-frame-container {
  flex: 1;
  background: #000000;
  position: relative;
}

.call-frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.call-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  gap: 12px;
  font-size: 13px;
  background: #111113;
}

/* =========================================================
   Auth Gate Overlay
   ========================================================= */
.portal-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 245, 247, 0.95);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.portal-auth-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 420px;
  padding: clamp(32px, 5vw, 42px);
  text-align: center;
}

.auth-lock-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.auth-lock-icon svg,
.auth-lock-icon i {
  width: 22px;
  height: 22px;
}

.portal-auth-card .sec-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  display: block;
}

.portal-auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 8px 0;
}

.portal-auth-card p {
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 22px 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.auth-form label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}

.auth-form input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition: all 0.2s;
}

.auth-form input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.btn-magic-link {
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
  margin-top: 4px;
}

.btn-magic-link:hover {
  background: var(--blue-hover);
}

.auth-footer {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-tertiary);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* Admin has two columns; slim them down before they become a drawer */
@media (min-width: 861px) and (max-width: 1180px) {
  .admin-sidebar {
    width: 240px;
  }

  .projects-panel {
    width: 220px;
  }
}

/* Navigation Drawer Responsive Behavior */
@media (max-width: 860px) {
  .portal-nav {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    width: min(320px, 88vw);
    flex-direction: column;
    background: #ffffff;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.25s;
  }

  .portal-nav.open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
  }

  /* Admin: clients on top, the selected client's chats below */
  .portal-nav .admin-sidebar,
  .portal-nav .projects-panel {
    width: 100%;
    height: auto;
    min-height: 0;
    border-right: none;
  }

  .portal-nav .admin-sidebar {
    flex: 0 1 50%;
    border-bottom: 1px solid var(--border);
  }

  .portal-nav .projects-panel {
    flex: 1 1 50%;
  }

  .project-bar {
    padding: 8px 14px;
  }

  .project-bar .btn-client-action span {
    display: none;
  }
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 680px) {
  body.portal-body {
    height: 100dvh;
  }

  .portal-header {
    height: 56px;
    padding: 0 12px;
  }

  .portal-brand {
    gap: 8px;
  }

  .portal-brand .logo {
    font-size: 14px;
    gap: 5px;
  }

  .portal-status-pill {
    display: none;
  }

  .portal-actions {
    gap: 6px;
  }

  /* Call action buttons: neat circular buttons with icons */
  .btn-call-action {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-call-action span {
    display: none;
  }

  .btn-call-action svg,
  .btn-call-action i {
    width: 15px;
    height: 15px;
    margin: 0;
  }

  /* User profile dropdown button */
  .user-profile-btn {
    padding: 3px 8px 3px 4px;
    gap: 6px;
  }

  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  .user-name {
    max-width: 85px;
    font-size: 12.5px;
  }

  .dropdown-chevron {
    width: 12px;
    height: 12px;
  }

  .user-dropdown-menu {
    right: 0;
    max-width: calc(100vw - 20px);
    min-width: 210px;
  }

  /* Main & Chat layout */
  .portal-main {
    height: calc(100dvh - 56px);
    height: calc(100vh - 56px);
  }

  .chat-container {
    border-inline: none;
  }

  .chat-messages {
    padding: 14px 12px 10px;
    gap: 12px;
  }

  .message-row {
    max-width: 88%;
  }

  .msg-bubble {
    font-size: 13.5px;
    padding: 9px 13px;
    line-height: 1.5;
  }

  /* Composer */
  .chat-composer {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .composer-box {
    padding: 8px 10px;
    border-radius: 16px;
  }

  .composer-textarea {
    font-size: 14px;
    line-height: 1.45;
  }

  .composer-hint {
    display: none;
  }

  .tool-btn {
    padding: 5px;
  }

  .call-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }

  .btn-join-call {
    text-align: center;
    width: 100%;
    padding: 8px;
  }

  /* In-page call drawer on mobile */
  .call-drawer {
    width: 100%;
    height: 60vh;
    bottom: 0;
    right: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
  }
}

@media (max-width: 380px) {
  .portal-header {
    padding: 0 8px;
  }

  .portal-brand .logo {
    font-size: 13.5px;
  }

  .user-name {
    display: none; /* Icon and avatar only on very small screens */
  }

  .user-profile-btn {
    padding: 3px 6px 3px 3px;
  }

  .btn-call-action {
    width: 32px;
    height: 32px;
  }

  .user-avatar {
    width: 22px;
    height: 22px;
    font-size: 9.5px;
  }
}

/* =========================================================
   Invite Client Modal (Studio Admin)
   ========================================================= */
.portal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.portal-modal-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.06);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modalScaleUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  0% { opacity: 0; transform: scale(0.96) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--blue-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon svg,
.modal-icon i {
  width: 18px;
  height: 18px;
}

.modal-title-wrap h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

.modal-title-wrap p {
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.45;
  margin: 4px 0 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--ink-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close-btn:hover {
  background: var(--surface);
  color: var(--ink);
}

.modal-close-btn svg,
.modal-close-btn i {
  width: 16px;
  height: 16px;
}

.invite-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
}

.modal-field input,
.modal-field textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: all 0.18s;
  box-sizing: border-box;
}

.modal-field textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}

.modal-field input:focus,
.modal-field textarea:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.btn-modal-cancel {
  background: transparent;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-modal-cancel:hover {
  background: var(--surface);
  color: var(--ink);
}

.btn-modal-submit {
  background: var(--accent);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
}

.btn-modal-submit:hover {
  background: #0077ed;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.28);
}

.btn-modal-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-modal-submit svg,
.btn-modal-submit i {
  width: 13px;
  height: 13px;
}

/* Delete Modal Styling */
.delete-modal-card {
  max-width: 400px;
}

.modal-icon.delete-icon {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
}

.delete-modal-body {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}

.delete-modal-body p {
  margin: 0 0 8px;
}

.delete-warning-text {
  font-size: 12px;
  color: var(--ink-secondary);
  background: rgba(0, 0, 0, 0.03);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid #ff3b30;
}

.btn-modal-delete-confirm {
  background: #ff3b30;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
}

.btn-modal-delete-confirm:hover {
  background: #e02d23;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.35);
}

.btn-modal-delete-confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-modal-delete-confirm svg,
.btn-modal-delete-confirm i {
  width: 13px;
  height: 13px;
}
