/* Kashi Slack-like Chat Stylesheet */

/* Scrollable Container Styles */
.chat-list-scrollable {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-list-scrollable::-webkit-scrollbar {
  width: 5px;
}

.chat-list-scrollable::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-list-scrollable::-webkit-scrollbar-track {
  background: transparent;
}

/* Chat Item in Sidebar List */
.chat-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius, 8px);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  margin-bottom: 2px;
  border: 1px solid transparent;
  text-decoration: none;
}

.chat-item:hover {
  background: var(--border-light);
}

.chat-item.active {
  background: var(--accent-light);
  border-color: rgba(61, 107, 79, 0.15);
}

.chat-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11.5px;
  margin-right: 8px;
  flex-shrink: 0;
  text-transform: uppercase;
}

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

.chat-item-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-msg {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.chat-message-bubble {
  font-size: 12px;
}

.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: 8px;
  flex-shrink: 0;
}

.chat-item-time {
  font-size: 10px;
  color: var(--text-faint);
}

.chat-item-badge {
  background: var(--accent);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-top: 4px;
  min-width: 10px;
  text-align: center;
  line-height: 1.2;
}

.chat-item-delete {
  display: none;
  cursor: pointer;
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.6;
  transition: opacity 0.12s, color 0.12s;
  user-select: none;
}

.chat-item-delete:hover {
  opacity: 1 !important;
  color: #ef4444;
}

.chat-item:hover .chat-item-delete {
  display: block;
}

.chat-item:hover .chat-item-badge {
  display: none !important;
}

/* Chat User / Search Result Item */
.chat-user-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid transparent;
}

.chat-user-item:hover {
  background: var(--border-light);
}

.chat-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 10px;
  margin-right: 8px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.chat-user-info {
  flex: 1;
  min-width: 0;
}

.chat-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-email {
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat Message Styles */
.chat-message {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 3px 5px;
  margin-top: 0px;
  transition: background 0.1s ease;
  position: relative;
  max-width: 100%;
  animation: chatMsgFadeIn 0.15s ease-out;
}

.chat-message:first-child {
  margin-top: 0;
}

.chat-message:hover {
  background: var(--border-light);
}

.chat-message-actions {
  display: none;
  position: absolute;
  right: 12px;
  top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.chat-message:hover .chat-message-actions {
  display: flex;
}

.chat-message-btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.12s, background 0.12s;
  border-radius: 3px;
  font-family: var(--font-body);
}

.chat-message-btn-delete:hover {
  background: var(--border-light);
  color: #ef4444;
}

.chat-message-btn-edit {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.12s, background 0.12s;
  border-radius: 3px;
  font-family: var(--font-body);
}

.chat-message-btn-edit:hover {
  background: var(--border-light);
  color: var(--accent);
}

.chat-message-edited {
  font-size: 10px;
  color: var(--text-faint);
  margin-left: 5px;
  font-style: italic;
  user-select: none;
}


.chat-message-avatar-container {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  user-select: none;
}

.chat-message-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-message-sender {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.chat-message-sender.is-self {
  color: var(--accent);
}

.chat-message-time {
  font-size: 9.5px;
  color: var(--text-faint);
}

.chat-message-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Grouped Message Styling */
.chat-message.grouped {
  margin-top: 0;
  padding-top: 2px;
  padding-bottom: 2px;
}

.chat-message.grouped .chat-message-avatar-container {
  height: 18px;
  /* vertically align with the message text line */
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-message-hover-time {
  display: none;
  font-size: 8.5px;
  color: var(--text-faint);
  user-select: none;
  text-align: center;
  width: 100%;
}

.chat-message.grouped:hover .chat-message-hover-time {
  display: inline-block;
}

/* Animations */
@keyframes chatMsgFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat Room Layout (centered doc style matching #preview on desktop) */
#chat-room {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

#chat-room-header {
  height: 50px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  background: var(--toolbar-bg);
  z-index: 10;
}

#chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#chat-messages-container::-webkit-scrollbar {
  width: 6px;
}

#chat-messages-container::-webkit-scrollbar-track {
  background: transparent;
}

#chat-messages-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#chat-welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

#chat-messages-list {
  display: none;
  flex-direction: column;
  gap: 0;
}

#chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--toolbar-bg);
  display: none;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}

/* Chat File Attachment Styles */
.chat-attachment {
  margin-top: 6px;
  max-width: 100%;
}

.chat-image-attachment {
  max-width: 320px;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
}

.chat-image-attachment:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow);
}

.chat-image-attachment img {
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}


.chat-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 380px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.chat-file-card:hover {
  background: var(--border-light);
  border-color: var(--accent);
}

.chat-file-icon {
  font-size: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
}

.chat-file-info {
  flex: 1;
  min-width: 0;
}

.chat-file-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.chat-file-size {
  font-size: 10px;
  color: var(--text-faint);
}

.chat-file-download-icon {
  color: var(--text-faint);
  font-size: 13px;
  flex-shrink: 0;
  margin-left: auto;
}

.chat-file-card:hover .chat-file-download-icon {
  color: var(--accent);
}

/* Responsive layout: centered note card on desktop, full screen on mobile */
@media (min-width: 769px) {
  #chat-room {
    max-width: 760px;
    width: calc(100% - 32px);
    margin: 16px auto;
    height: calc(100% - 32px);
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  #chat-room-header {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
  }

  #chat-input-area {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
  }
}

/* Workspace Switcher & Setup Layout Styles */
#workspace-switcher-trigger {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}
#workspace-switcher-trigger:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

#workspace-switcher-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-radius: 6px;
  z-index: 100;
  font-family: var(--font-body);
}

.ws-list-item-btn {
  font-family: var(--font-body);
  transition: background 0.12s;
}
.ws-list-item-btn:hover {
  background: var(--surface-hover);
}

.ws-dropdown-btn {
  font-family: var(--font-body);
}

/* Workspace Setup & Notice Styles */
.workspace-setup-notice {
  padding: 24px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}

.workspace-setup-header {
  text-align: center;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.workspace-setup-icon-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: 50%;
  margin-bottom: 12px;
  box-shadow: var(--skeu-raise);
  transition: transform 0.3s ease;
}

.workspace-setup-icon-wrap:hover {
  transform: scale(1.05) rotate(5deg);
}

.workspace-setup-icon {
  font-size: 32px;
  z-index: 2;
}

.workspace-setup-icon-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 2px dashed var(--accent);
  border-radius: 50%;
  opacity: 0.3;
  animation: rotateDashed 20s linear infinite;
}

@keyframes rotateDashed {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.workspace-setup-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.workspace-setup-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
  max-width: 240px;
}

/* Segmented Tabs Control styling */
.workspace-setup-tabs-container {
  padding: 4px;
  background: var(--sidebar-bg);
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border-light);
  box-shadow: var(--skeu-inset);
  margin-bottom: 8px;
}

.workspace-setup-tabs {
  display: flex;
  gap: 2px;
}

.ws-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  font-family: var(--font-body);
}

.ws-tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.ws-tab-btn.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), var(--skeu-raise);
}

/* Forms layout */
.workspace-setup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: setupFormFadeIn 0.25s ease-out;
}

@keyframes setupFormFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Input wrappers with icon inside */
.workspace-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.workspace-input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: var(--text-faint);
  pointer-events: none;
  transition: color 0.2s ease;
}

.workspace-setup-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  padding: 0 12px 0 34px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  outline: none;
  transition: all 0.2s ease;
  box-shadow: var(--skeu-inset);
}

.workspace-setup-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--skeu-inset);
  background: var(--surface);
}

.workspace-setup-input:focus + .workspace-input-icon,
.workspace-setup-input:focus-within + .workspace-input-icon {
  color: var(--accent);
}

/* Premium Buttons with arrow animation */
.workspace-setup-btn {
  width: 100%;
  height: 38px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--skeu-raise);
  font-family: var(--font-body);
}

.workspace-setup-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), var(--skeu-raise);
}

.workspace-setup-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.workspace-setup-btn .btn-arrow {
  transition: transform 0.2s ease;
  display: inline-block;
}

.workspace-setup-btn:hover .btn-arrow {
  transform: translateX(3px);
}

.workspace-setup-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Pending Invitations Section */
.workspace-invitations-section {
  margin-top: 16px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}

.workspace-invitations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#workspace-inline-setup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 99;
}

#workspace-drawer {
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 90;
  box-shadow: -4px 0 12px rgba(0,0,0,0.05);
}

#company-members-list, #company-invitations-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}