/* Ynex-inspired theme – dark sidebar, indigo accent, clean cards */

:root {
  --ynex-primary: #6366f1;
  --ynex-primary-hover: #4f46e5;
  --ynex-primary-light: rgba(99, 102, 241, 0.12);
  --ynex-sidebar-bg: #1e293b;
  --ynex-sidebar-hover: rgba(255, 255, 255, 0.08);
  --ynex-sidebar-active: rgba(99, 102, 241, 0.2);
  --ynex-sidebar-text: rgba(255, 255, 255, 0.85);
  --ynex-sidebar-muted: rgba(255, 255, 255, 0.6);
  --ynex-body-bg: #f1f5f9;
  --ynex-card-bg: #ffffff;
  --ynex-card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --ynex-card-shadow-hover: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --ynex-radius: 0.5rem;
  --ynex-radius-lg: 0.75rem;
}

/* Override Bootstrap primary */
.bg-primary, .btn-primary, .border-primary {
  --bs-primary: var(--ynex-primary);
  --bs-primary-rgb: 99, 102, 241;
}
.btn-primary {
  background-color: var(--ynex-primary);
  border-color: var(--ynex-primary);
}
.btn-primary:hover {
  background-color: var(--ynex-primary-hover);
  border-color: var(--ynex-primary-hover);
}

/* Body & layout */
body {
  background-color: var(--ynex-body-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Sidebar */
.ynex-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--ynex-sidebar-bg);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}

.ynex-sidebar-brand {
  padding: 1.25rem 1.5rem;
  color: var(--ynex-sidebar-text);
  font-weight: 600;
  font-size: 1.125rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ynex-sidebar-brand:hover { color: #fff; }

.ynex-sidebar-brand i {
  color: var(--ynex-primary);
  font-size: 1.5rem;
}

.ynex-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.ynex-nav-section {
  margin-bottom: 0.5rem;
}

.ynex-nav-section-label {
  display: block;
  padding: 0.5rem 1.5rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ynex-sidebar-muted);
  opacity: 0.75;
}

.ynex-sidebar-nav .nav-link {
  color: var(--ynex-sidebar-muted);
  padding: 0.625rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border-radius: 0;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.ynex-sidebar-nav .nav-link:hover {
  color: var(--ynex-sidebar-text);
  background: var(--ynex-sidebar-hover);
}

.ynex-sidebar-nav .nav-link.active {
  color: #fff;
  background: var(--ynex-sidebar-active);
  border-left-color: var(--ynex-primary);
}

.ynex-sidebar-nav .nav-link i {
  font-size: 1.125rem;
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
}

.ynex-sidebar-nav .nav-link-sub {
  padding-left: 2.75rem;
  font-size: 0.9375rem;
  color: var(--ynex-sidebar-muted);
  opacity: 0.95;
}

.ynex-sidebar-nav .nav-link-sub:hover {
  color: var(--ynex-sidebar-text);
}

.ynex-sidebar-nav .nav-link-sub.active {
  color: #fff;
  opacity: 1;
}

.ynex-sidebar-nav .nav-link-sub i {
  font-size: 1rem;
}

.ynex-sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ynex-sidebar-footer .nav-link {
  color: var(--ynex-sidebar-muted);
  padding: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.ynex-sidebar-footer .nav-link:hover { color: #fff; }

/* Main content */
.ynex-main {
  margin-left: 260px;
  min-height: 100vh;
  padding: 1.5rem 0;
}

/* Page header – clear hierarchy, generous spacing */
.ynex-page-header {
  margin-bottom: 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.ynex-page-header-left { flex: 1; min-width: 0; }
.ynex-page-header-right { flex-shrink: 0; }

.ynex-page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.ynex-page-header .subtitle {
  font-size: 0.9375rem;
  color: #64748b;
  line-height: 1.5;
}

/* Cards – Ynex style */
.card {
  background: var(--ynex-card-bg);
  border: 1px solid #e2e8f0;
  border-radius: var(--ynex-radius-lg);
  box-shadow: var(--ynex-card-shadow);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--ynex-card-shadow-hover);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f1f5f9;
  padding: 1rem 1.25rem;
  font-weight: 500;
  color: #0f172a;
}

.card-header .h6 { font-weight: 600; }

.card-body {
  padding: 1.25rem;
}

/* Form-heavy cards (e.g. Projects/Edit) – more breathing room */
.card-body:has(form .row.g-3) {
  padding: 1.5rem 1.5rem;
}

/* Status cards – accent border */
.card.border-success { border-left: 4px solid #22c55e !important; }
.card.border-warning { border-left: 4px solid #eab308 !important; }
.card.border-primary { border-left: 4px solid var(--ynex-primary) !important; }
.card.border-secondary { border-left: 4px solid #94a3b8 !important; }

/* Buttons */
.btn {
  border-radius: var(--ynex-radius);
  font-weight: 500;
}

.btn-outline-primary {
  color: var(--ynex-primary);
  border-color: var(--ynex-primary);
}

.btn-outline-primary:hover {
  background: var(--ynex-primary-light);
  color: var(--ynex-primary-hover);
  border-color: var(--ynex-primary-hover);
}

/* Forms */
.form-control, .form-select {
  border-radius: var(--ynex-radius);
  border-color: #e2e8f0;
}

.form-control:focus {
  border-color: var(--ynex-primary);
  box-shadow: 0 0 0 3px var(--ynex-primary-light);
}

/* Form sections (Projects/Edit and similar) – modular, clear delineation */
.card .form-label {
  font-weight: 500;
  color: #475569;
  margin-bottom: 0.35rem;
}

.card .row.g-3 {
  --bs-gutter-y: 1.25rem;
}

.card hr + .text-muted,
.card .col-12:has(hr) + .col-12 .text-muted {
  margin-top: 0.5rem;
}

.card h6.text-muted.small {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 0.75rem;
  padding-top: 0.25rem;
}

.card .form-check {
  padding-left: 1.6em;
  min-height: 1.5rem;
}

.card .form-check-input {
  margin-top: 0.2em;
}

/* Form card body – generous padding for Edit-style forms */
.card .card-body form {
  max-width: 52rem;
}

/* Tables – generous padding for readability */
.table {
  --bs-table-border-color: #f1f5f9;
}

.table thead th {
  font-weight: 600;
  color: #475569;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom-width: 1px;
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

.table tbody td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

.table-sm thead th,
.table-sm tbody td {
  padding: 0.625rem 0.875rem;
}

/* Code in tables/cards – same size as surrounding text */
.table code,
.card-body code {
  font-size: 1em;
}

/* Badges – pill/card-style with good internal padding */
.badge {
  font-weight: 500;
  padding: 0.4em 0.75em;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
}

.bg-primary { background-color: var(--ynex-primary) !important; }

/* Items in cards – reuse-step-card, status cards */
.reuse-step-card {
  border: 1px solid #e2e8f0;
  border-radius: var(--ynex-radius);
  padding: 1rem 1.25rem;
  background: #fafbfc;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.reuse-step-card:hover {
  border-color: #cbd5e1;
}

.reuse-step-card .flex-grow-1.border {
  border-color: #e2e8f0 !important;
  border-radius: var(--ynex-radius);
  padding: 1rem !important;
  background: #fff !important;
}

/* Dashboard status cards – more breathing room */
.card.border-success .card-body,
.card.border-warning .card-body,
.card.border-primary .card-body,
.card.border-secondary .card-body {
  padding: 1rem 1.25rem !important;
}

/* Alerts */
.alert {
  border-radius: var(--ynex-radius);
  border: none;
}

.alert-success { background: rgba(34, 197, 94, 0.12); color: #15803d; }
.alert-danger { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.alert-warning { background: rgba(234, 179, 8, 0.12); color: #a16207; }
.alert-info { background: rgba(99, 102, 241, 0.12); color: var(--ynex-primary-hover); }

/* Login layout */
.ynex-login-body {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
}

.ynex-login-body .container > .row > [class*="col-"] {
  transform: translateY(-3rem);
}

.ynex-login-card {
  background: #fff;
  border-radius: var(--ynex-radius-lg);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.ynex-login-brand {
  color: #fff;
  font-size: 2rem;
  margin-bottom: 2rem;
}

.ynex-login-brand i {
  color: var(--ynex-primary);
}

/* Prompts editor – full-height, maximized space */
.prompts-editor-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 12rem);
  margin: 0 -1rem;
  background: var(--ynex-card-bg);
  border: 1px solid #e2e8f0;
  border-radius: var(--ynex-radius-lg);
  overflow: hidden;
}

.prompts-file-list {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e2e8f0;
  background: #fafbfc;
}

.prompts-file-list-header {
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.prompts-file-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem;
}

.prompts-file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--ynex-radius);
  color: #475569;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}

.prompts-file-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.prompts-file-item.active {
  background: var(--ynex-primary-light);
  color: var(--ynex-primary-hover);
  font-weight: 500;
}

.prompts-file-item i {
  flex-shrink: 0;
  opacity: 0.8;
}

.prompts-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompts-file-size {
  font-size: 0.75rem;
  color: #94a3b8;
}

.prompts-file-item.active .prompts-file-size {
  color: var(--ynex-primary);
  opacity: 0.9;
}

.prompts-hint {
  padding: 0.5rem 0.75rem;
  margin: 0;
  border-top: 1px solid #e2e8f0;
}

.prompts-editor-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.prompts-editor-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.prompts-editor-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #fafbfc;
}

.prompts-editor-filename {
  font-weight: 500;
  font-size: 0.9375rem;
  color: #334155;
}

.prompts-editor-actions {
  display: flex;
  gap: 0.5rem;
}

.prompts-editor-textarea {
  flex: 1;
  min-height: 400px;
  resize: none;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 1rem 1.25rem;
  tab-size: 4;
}

.prompts-editor-textarea:focus {
  box-shadow: none;
  border-color: transparent;
}

.prompts-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

/* Send command – chat-like layout */
.clawbot-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  min-height: 8rem;
}

.clawbot-chat-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--ynex-radius-lg);
  overflow: hidden;
  background: #1e293b;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.clawbot-run-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 16rem;
  max-height: 28rem;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.clawbot-run-area .clawbot-run-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.clawbot-run-logs {
  flex: 1;
  min-height: 8rem;
  background: transparent;
  color: #e2e8f0;
  padding: 0.5rem 0;
  border-radius: 0;
  overflow-y: auto;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.clawbot-run-area .alert {
  flex-shrink: 0;
}

.clawbot-chat-input-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}

.clawbot-chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.clawbot-chat-input-bar .clawbot-chat-input {
  flex: 1;
  border-radius: 1.25rem;
  padding: 0.625rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 42, 0.8);
  color: #f1f5f9;
  font-size: 0.9375rem;
}

.clawbot-chat-input-bar .clawbot-chat-input::placeholder {
  color: rgba(226, 232, 240, 0.5);
}

.clawbot-chat-input-bar .clawbot-chat-input:focus {
  border-color: var(--ynex-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
  outline: none;
  background: rgba(15, 23, 42, 0.95);
}

.clawbot-chat-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 1rem;
  right: 4rem;
  max-height: 12rem;
  overflow-y: auto;
  background: var(--ynex-card-bg);
  border: 1px solid #e2e8f0;
  border-radius: var(--ynex-radius);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 0.25rem;
  z-index: 10;
}

.clawbot-chat-autocomplete.show {
  display: block !important;
}

.clawbot-chat-autocomplete-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  border-bottom: 1px solid #f1f5f9;
}

.clawbot-chat-autocomplete-item:last-child {
  border-bottom: none;
}

.clawbot-chat-autocomplete-item:hover,
.clawbot-chat-autocomplete-item.active {
  background: var(--ynex-primary-light);
}

.clawbot-chat-autocomplete-item code {
  font-weight: 500;
  color: var(--ynex-primary);
}

@media (max-width: 767.98px) {
  .prompts-editor-layout {
    flex-direction: column;
    min-height: 60vh;
  }

  .prompts-file-list {
    width: 100%;
    min-width: 0;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }
}

/* Mobile */
@media (max-width: 991.98px) {
  .ynex-sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .ynex-sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 0.5rem;
  }

  .ynex-sidebar-nav .nav-link {
    padding: 0.5rem 1rem;
    border-left: none;
    border-radius: var(--ynex-radius);
    flex: 1 1 auto;
  }

  .ynex-main {
    margin-left: 0;
  }
}
