/* Workspace-specific styles. Loaded after styles.css. */

/* ── Layout ── */
.ws-panel {
  background: var(--bg-card);
  border-radius: 22px;
  padding: 28px 28px 28px;
  min-height: calc(100vh - 100px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── List view header ── */
.ws-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.ws-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.ws-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.btn-library {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-library:hover { background: var(--bg); border-color: var(--brand); color: var(--brand); }
.btn-ws-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-ws-new:hover { opacity: .88; }

/* ── Empty state ── */
.ws-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 0;
  color: var(--text-mute);
}
.ws-empty-icon {
  width: 64px; height: 64px;
  opacity: .35;
}
.ws-empty p { font-size: 14px; }

/* ── Workspace cards grid ── */
.ws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.ws-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.ws-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(99,102,241,.12); transform: translateY(-2px); }
.ws-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  display: grid; place-items: center;
  color: var(--brand);
  font-size: 20px;
}
.ws-card-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.ws-card-desc {
  font-size: 12px;
  color: var(--text-mute);
  flex: 1;
}
.ws-card-meta {
  font-size: 11px;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ws-card-files-badge {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}
.ws-card-del {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.ws-card:hover .ws-card-del { opacity: 1; }
.ws-card-del:hover { background: #fee2e2; color: var(--danger); }

/* ── Modals ── */
.ws-modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.ws-modal {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: 460px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ws-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ws-modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 18px;
  display: grid; place-items: center;
}
.ws-modal-close:hover { background: var(--bg); }
.ws-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.ws-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  transition: border-color .15s;
  outline: none;
}
.ws-input:focus { border-color: var(--brand); }
.ws-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  resize: vertical;
  min-height: 90px;
  transition: border-color .15s;
  outline: none;
}
.ws-textarea:focus { border-color: var(--brand); }
.ws-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}
.ws-btn-cancel {
  padding: 9px 18px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.ws-btn-cancel:hover { background: var(--bg); }
.ws-btn-create {
  padding: 9px 22px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}
.ws-btn-create:disabled { opacity: .45; cursor: default; }
.ws-btn-create:not(:disabled):hover { opacity: .88; }

/* ── Library modal ── */
.lib-modal {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 28px;
  width: 640px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 80vh;
  overflow-y: auto;
}
.lib-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.lib-card {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 18px 14px 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.lib-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(99,102,241,.12); }
.lib-card.selected { border-color: var(--brand); background: var(--brand-soft); }
.lib-emoji { font-size: 26px; line-height: 1; }
.lib-name { font-weight: 700; font-size: 14px; color: var(--text); }
.lib-desc { font-size: 12px; color: var(--text-mute); }

/* ── Editor layout ── */
.ws-editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  overflow: hidden;
  background: var(--bg);
}

.ws-editor-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ws-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.ws-breadcrumb-link {
  font-size: 14px;
  color: var(--text-mute);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
.ws-breadcrumb-link:hover { color: var(--brand); }
.ws-breadcrumb-sep { color: var(--text-mute); font-size: 13px; }
.ws-breadcrumb-current { font-size: 15px; font-weight: 700; color: var(--text); }
.ws-editor-name-sub { font-size: 12px; color: var(--text-mute); }
.ws-editor-actions { display: flex; gap: 8px; align-items: center; }
.ws-file-count {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 500;
}
.ws-btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s;
}
.ws-btn-download:hover { border-color: var(--brand); color: var(--brand); }

.ws-editor-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ── Chat panel ── */
.ws-chat-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
}
.ws-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.ws-chat-header-actions { display: flex; gap: 4px; }
.ws-chat-icon-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 13px;
}
.ws-chat-icon-btn:hover { background: var(--bg); color: var(--danger); }

.ws-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ws-chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
  padding: 24px;
  line-height: 1.5;
}
.ws-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ws-msg-from {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 0 2px;
}
.ws-msg-bubble {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
}
.ws-msg.user .ws-msg-bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.ws-msg.user { align-items: flex-end; }
.ws-msg.ai .ws-msg-bubble {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.ws-msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.ws-msg-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .12s;
}
.ws-msg-file-tag:hover { border-color: var(--brand); }
.ws-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
  margin-top: 4px;
}
.ws-typing-dots {
  display: flex;
  gap: 4px;
}
.ws-typing-dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--text-mute);
  animation: wsDot 1.2s infinite;
}
.ws-typing-dot:nth-child(2) { animation-delay: .2s; }
.ws-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes wsDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ws-chat-input-row {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.ws-chat-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  transition: border-color .15s;
  line-height: 1.4;
}
.ws-chat-input:focus { border-color: var(--brand); }
.ws-chat-send {
  width: 36px; height: 36px;
  border-radius: 9px;
  border: none;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
.ws-chat-send:disabled { opacity: .4; cursor: default; }
.ws-chat-send:not(:disabled):hover { opacity: .85; }

/* ── Code/Preview panel ── */
.ws-code-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-soft);
}
.ws-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  padding: 0 16px;
  flex-shrink: 0;
  gap: 0;
}
.ws-tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.ws-tab:hover { color: var(--text); }
.ws-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.ws-code-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Explorer ── */
.ws-explorer {
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.ws-explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ws-explorer-refresh {
  width: 20px; height: 20px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  display: grid; place-items: center;
}
.ws-explorer-refresh:hover { color: var(--brand); background: var(--brand-soft); }
.ws-explorer-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--text-mute);
  text-align: center;
}
.ws-file-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-soft);
  transition: background .12s, color .12s;
  border-radius: 0;
}
.ws-file-item:hover { background: var(--bg); color: var(--text); }
.ws-file-item.selected { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.ws-file-icon { font-size: 13px; flex-shrink: 0; }

/* ── Code editor area ── */
.ws-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ws-no-file {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  font-size: 13px;
}
.ws-code-header {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.ws-code-content {
  flex: 1;
  overflow: auto;
  padding: 0;
  background: #1e1e2e;
}
pre.ws-code-pre {
  margin: 0;
  padding: 18px 20px;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #cdd6f4;
  min-height: 100%;
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}

/* ── Preview panel ── */
.ws-preview-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.ws-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ws-preview-dot {
  width: 10px; height: 10px;
  border-radius: 999px;
}
.ws-preview-url {
  flex: 1;
  padding: 5px 12px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-mute);
}
.ws-preview-iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  background: #fff;
}
.ws-preview-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-mute);
  font-size: 13px;
}
.ws-preview-empty-icon { font-size: 40px; opacity: .3; }
