/* Nico Workspace layout */

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: #000;
  color: #e5e7eb;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.nw-app {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
  background: radial-gradient(circle at top, #111827 0, #020617 40%, #000 100%);
  color: #e5e7eb;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  box-sizing: border-box;
}

/* Sidebar */

.nw-sidebar {
  width: 260px;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #020617 0, #020617 60%, #030712 100%);
  overflow-y: auto;
}

.nw-sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.nw-logo {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #4f46e5, #1e1b4b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #e5e7eb;
  font-size: 16px;
  flex-shrink: 0;
}

.nw-title-main {
  font-weight: 600;
  font-size: 14px;
}

.nw-title-sub {
  font-size: 11px;
  color: #9ca3af;
}

.nw-sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-top: 8px;
}

.nw-session-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.nw-session-item-wrapper {
  position: relative;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nw-session-item-wrapper:hover .nw-session-delete {
  opacity: 1;
}

.nw-session-item-wrapper.is-active .nw-session-item {
  background: radial-gradient(circle at 0 0, rgba(79, 70, 229, 0.35), rgba(15, 23, 42, 1));
  border-color: rgba(129, 140, 248, 0.9);
}

.nw-session-item {
  display: block;
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: #e5e7eb;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.nw-session-item:hover {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(79, 70, 229, 0.5);
}

.nw-session-item-wrapper.is-active .nw-session-item {
  background: radial-gradient(circle at 0 0, rgba(79, 70, 229, 0.35), rgba(15, 23, 42, 1));
  border-color: rgba(129, 140, 248, 0.9);
}

.nw-session-delete {
  opacity: 0;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}

.nw-session-item-wrapper:hover .nw-session-delete {
  opacity: 1;
}

.nw-session-delete:hover {
  background: rgba(239, 68, 68, 0.4);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fee2e2;
}

.nw-session-name {
  font-size: 13px;
  font-weight: 500;
}

.nw-session-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

/* Main */

.nw-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  overflow: hidden;
  position: relative;
  min-width: 0; /* Prevents flex item from overflowing */
}

.nw-main-header {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(14px);
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
  flex-shrink: 0;
}

.nw-main-session-title {
  font-size: 15px;
  font-weight: 600;
}

.nw-main-session-sub {
  font-size: 11px;
  color: #9ca3af;
}

/* Controls */

.nw-main-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nw-select {
  background: #020617;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.nw-select:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.8);
}

/* Run status + button */

.nw-run-status {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid transparent;
}

.nw-run-status-idle {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(148, 163, 184, 0.4);
  color: #9ca3af;
}

.nw-run-status-running {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.8);
  color: #bbf7d0;
}

.nw-run-status-error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fecaca;
}

/* Chat */

.nw-chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 90px;
  scroll-behavior: smooth;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
}

.nw-msg {
  margin-bottom: 10px;
  display: flex;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.nw-msg-user {
  justify-content: flex-end;
}

.nw-msg-assistant {
  justify-content: flex-start;
}

.nw-msg-inner {
  max-width: 720px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(31, 41, 55, 1);
  line-height: 1.5;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.nw-msg-user .nw-msg-inner {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.95), rgba(129, 140, 248, 0.95));
  border-color: rgba(191, 219, 254, 0.6);
}

.nw-msg-meta {
  font-size: 10px;
  color: #9ca3af;
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.nw-msg-user .nw-msg-meta {
  color: rgba(255, 255, 255, 0.9);
}

.nw-msg-content {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* File previews */

.nw-file-preview {
  margin-top: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.8);
}

.nw-file-preview-header {
  background: rgba(79, 70, 229, 0.15);
  padding: 8px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nw-file-preview-path {
  font-size: 12px;
  font-weight: 500;
  color: #a5b4fc;
  font-family: "Monaco", "Menlo", monospace;
}

.nw-file-preview-lines {
  font-size: 11px;
  color: #9ca3af;
}

.nw-file-preview-content {
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  font-family: "Monaco", "Menlo", monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #e5e7eb;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Actions preview in chat */

.nw-action-pending {
  margin-top: 8px;
  border: 2px solid rgba(250, 204, 21, 0.6);
  border-radius: 8px;
  background: rgba(250, 204, 21, 0.1);
  padding: 12px;
}

.nw-action-pending-header {
  font-size: 12px;
  font-weight: 500;
  color: #fbbf24;
  margin-bottom: 8px;
}

.nw-action-pending-desc {
  font-size: 12px;
  color: #e5e7eb;
  margin-bottom: 10px;
  font-family: "Monaco", "Menlo", monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 8px;
  border-radius: 4px;
}

.nw-action-buttons {
  display: flex;
  gap: 8px;
}

.nw-action-status {
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
}

.nw-action-status.approved {
  background: rgba(22, 163, 74, 0.15);
  border: 1px solid rgba(22, 163, 74, 0.5);
  color: #bbf7d0;
}

.nw-action-status.rejected {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.nw-action-status.processing {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #bfdbfe;
}

/* Input bar */

.nw-inputbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 260px;
  padding: 10px 18px 14px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 1));
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  gap: 8px;
  z-index: 10;
  box-sizing: border-box;
  max-width: calc(100% - 260px);
}

.nw-input {
  flex: 1;
  resize: none;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: #020617;
  color: #e5e7eb;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.3;
  font-family: inherit;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.nw-input:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.8);
}

.nw-input::-webkit-input-placeholder {
  color: #6b7280;
}

.nw-input::-moz-placeholder {
  color: #6b7280;
  opacity: 1;
}

.nw-input::placeholder {
  color: #6b7280;
}

/* Buttons */

.nw-btn {
  border-radius: 999px;
  border: none;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.nw-btn-primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #e5e7eb;
}

.nw-btn-primary:hover {
  filter: brightness(1.05);
}

.nw-btn-primary:active {
  filter: brightness(0.95);
}

.nw-btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.7);
}

.nw-btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.nw-btn-success {
  background: rgba(22, 163, 74, 0.2);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.7);
}

.nw-btn-success:hover {
  background: rgba(22, 163, 74, 0.3);
}

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

/* Loading indicator */

.nw-loading {
  display: inline-block;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(31, 41, 55, 1);
  color: #9ca3af;
  font-size: 13px;
}

/* Phase done badge */

.nw-phase-done {
  margin: 12px 18px;
  padding: 10px 14px;
  background: rgba(22, 163, 74, 0.15);
  border: 1px solid rgba(22, 163, 74, 0.5);
  border-radius: 8px;
  color: #bbf7d0;
  font-size: 12px;
  display: none;
}

.nw-phase-done.show {
  display: block;
}

/* Scrollbar styling - WebKit browsers */

@supports (-webkit-appearance: none) {
  .nw-chat::-webkit-scrollbar,
  .nw-session-list::-webkit-scrollbar {
    width: 8px;
  }
  .nw-chat::-webkit-scrollbar-track,
  .nw-session-list::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
  }
  .nw-chat::-webkit-scrollbar-thumb,
  .nw-session-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
  }
  .nw-chat::-webkit-scrollbar-thumb:hover,
  .nw-session-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
  }
}

/* Scrollbar styling - Firefox */

.nw-chat,
.nw-session-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) rgba(15, 23, 42, 0.5);
}

/* Modal */

.nw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.nw-modal {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.nw-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nw-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #e5e7eb;
}

.nw-modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.nw-modal-close:hover {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
}

.nw-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.nw-form-group {
  margin-bottom: 16px;
}

.nw-form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #9ca3af;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nw-form-input {
  width: 100%;
  padding: 10px 12px;
  background: #020617;
  border: 1px solid rgba(55, 65, 81, 0.9);
  border-radius: 8px;
  color: #e5e7eb;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
}

.nw-form-input:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.8);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

.nw-form-input::placeholder {
  color: #6b7280;
}

.nw-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
