:root {
  --bg-color: #f3f4f6;
  --sidebar-width: 420px;
  --primary-color: #111111;
  --accent-color: #3b82f6;
  --success-color: #10b981;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: var(--bg-color);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

::-webkit-scrollbar {
  display: none;
}

/* ------------------- LEFT SIDEBAR (For HISTORY) ------------------- */
#history-sidebar {
  width: 260px;
  background: #0f0f0f;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
}

.sidebar-header {
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #222;
}

.sidebar-title {
  color: #e5e7eb;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.new-chat-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #555;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.2s;
}

.new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* History Filter Tabs */
.history-tabs {
  display: flex;
  padding: 8px 10px;
  gap: 4px;
  border-bottom: 1px solid #222;
}

.history-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: #6b7280;
  padding: 6px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  font-weight: 600;
}

.history-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #9ca3af;
}

.history-tab.active {
  background: #1e3a8a;
  color: #fff;
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.history-item {
  padding: 10px 12px;
  margin-bottom: 5px;
  border-radius: 6px;
  cursor: pointer;
  color: #9ca3af;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.history-item:hover {
  background: #1a1a1a;
  color: #fff;
}

.history-item.active {
  background: #1e3a8a;
  color: #fff;
  border-color: #3b82f6;
}

.history-time {
  font-size: 0.7rem;
  color: #666;
  margin-left: 8px;
}

/* History Item Layout */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  cursor: pointer;
}

.history-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status Badges */
.status-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  width: fit-content;
}

.status-running {
  background: #1e40af;
  color: #93c5fd;
  animation: pulse 1.5s infinite;
}

.status-pending {
  background: #713f12;
  color: #fde68a;
}

.status-completed {
  background: transparent;
}

.status-failed {
  background: #7f1d1d;
  color: #fca5a5;
}

.status-cancelled {
  background: #374151;
  color: #9ca3af;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* Action Buttons */
.history-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.history-item:hover .history-actions {
  opacity: 1;
}

.action-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.action-btn.cancel-btn {
  color: #fca5a5;
}

.action-btn.cancel-btn:hover {
  background: #7f1d1d;
  color: #fff;
}

.action-btn.delete-btn {
  color: #9ca3af;
}

.action-btn.delete-btn:hover {
  background: #374151;
  color: #fff;
}

/* ------------------------ Main AREA VIEW (For Live Browser ScreenShot) -------------------------- */
#main-view {
  flex: 1;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-direction: column;
  /* Reserve space for Fixed Header (top) and Fixed Input (bottom) */
  padding-top: 80px;
  padding-bottom: 120px;
  box-sizing: border-box;
}

#live-image {
  /* Image fits entirely within the padded safe area */
  max-width: 95%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  display: none;
  transition: border 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#live-vnc {
  width: 95%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 8px;
  display: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  background: #000;
}

#stream-status {
  display: none;
  position: absolute;
  top: 90px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 11px;
  color: #4ade80;
  z-index: 200;
}

.task-finished {
  border: 2px solid var(--success-color);
  box-shadow: 0 0px 50px rgba(16, 185, 129, 0.3) !important;
}


/* ----------------------------------- NAV-BAR ------------------------------------- */
.logo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: absolute;
  width: 100%;
  top: 20px;
  left: 20px;
}

.head {
  width: 90%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: auto;

}

.head button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #555;
  outline: none;
  color: white;
  padding: 10px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s;
}

.head button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-hierarchy {
    display: flex;
    gap: 10px;
}

.header-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #e5e7eb;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
}

.header-select option {
    background-color: #1a1a1a;
    color: #e5e7eb;
}

.header-select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #666;
}

.header-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.header-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.header-delete-btn {
    background: transparent;
    border: 1px solid #555;
    color: #9ca3af;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: -4px;
}

.header-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
}

.logo {
  color: white;
  font-size: 1.5rem;
  opacity: 0.9;
  font-weight: bold;
  letter-spacing: 1px;
}

.placeholder {
  color: #9ca3af;
  font-size: 1.2rem;
  text-align: center;
  max-width: 600px;
  padding: 20px;
  line-height: 1.6;
}

/* ----------------------------------- SCHEDULE MODAL STYLES ------------------------------------- */
.schedule-section {
  text-align: left;
  margin-bottom: 15px;
}

.schedule-section label {
  display: block;
  font-size: 0.85rem;
  color: #9ca3af;
  margin-bottom: 8px;
  font-weight: 600;
}

#schedule-scenario-select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: white;
  outline: none;
}

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.primary-btn {
  background: var(--accent-color) !important;
  flex: 2;
}

.cancel-btn {
  background: #444 !important;
  flex: 1;
}

/* ---------------------------- RIGHT SIDEBAR: Activity Panel --------------------------------- */
#activity-panel {
  width: var(--sidebar-width);
  background: #222;
  border-left: 1px solid #444;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 15px;
  border-bottom: 1px solid #444;
  background: #1f1f1f;
  color: white;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#log-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  scroll-behavior: smooth;
}

/* ---------------------------- SCENARIO/CASE STYLING -------------------------------- */
.scenario-box {
  background: transparent;
  margin-bottom: 20px;
  border: 1px solid #555;
  border-radius: 9px;
  padding: 15px 10px;
  transition: border-color 0.2s;
}

.scenario-box:hover {
  border-color: #777;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #e5e7eb;
  margin-bottom: 15px;
  font-size: 1rem;
  font-weight: 600;
}

.label-text {
  color: #e5e7eb;
  text-transform: uppercase;
  font-size: 0.85rem;
  white-space: nowrap;
}

.dash-input {
  background: transparent;
  border: none;
  color: white;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  padding: 2px 5px;
  cursor: default;
}

.icon-btn {
  cursor: pointer;
  color: #9ca3af;
  opacity: 1;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.icon-btn:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-btn:active {
  transform: scale(0.92);
  background-color: rgba(255, 255, 255, 0.05);
}

.icon-svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  pointer-events: none;
}


.header-icon {
  color: #9ca3af;
  margin-left: 10px;
}

.header-icon:hover {
  color: white;
}

.case-box {
  margin-left: 10px;
  padding-left: 10px;
  margin-bottom: 15px;
}

.steps-container {
  margin-top: 10px;
}

details {
  background: #333;
  margin-bottom: 10px;
  border-radius: 4px;
  color: #e5e7eb;
  border: 1px solid #404040;
}

summary {
  padding: 8px 12px;
  background: #3a3a3a;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary:hover {
  background: #404040;
}

summary::after {
  content: "+";
  color: #9ca3af;
}

details[open] summary::after {
  content: "-";
}

.step-content {
  padding: 10px;
  background: #2a2a2a;
  font-size: 0.85rem;
  border-top: 1px solid #444;
}

.log-item {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  align-items: flex-start;
  line-height: 1.4;
}

.log-item span:last-child {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  min-width: 50px;
  text-align: center;
  margin-top: 2px;
}

.badge.goal {
  background: #312e81;
  color: #c7d2fe;
}

.badge.action {
  background: #064e3b;
  color: #6ee7b7;
}

.badge.success {
  background: #10b981;
  color: #fff;
}

.badge.stop {
  background: #ef4444;
  /* Bright Red */
  color: #fff;
}

.result-card {
  background: #1e3a8a;
  border: 1px solid #3b82f6;
  color: #dbeafe;
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
  font-size: 0.9rem;
}

.result-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

#input-area {
  position: fixed;
  bottom: 30px;
  width: 800px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px;
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  border: 1px solid #333;
  backdrop-filter: blur(5px);
  z-index: 100;
}

input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 25px;
  border-radius: 50px;
  font-size: 1rem;
  background: transparent;
}

button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0 30px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

button:hover {
  background: #000;
}

button:disabled {
  background: #6b7280;
  cursor: not-allowed;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  margin-top: 10px;
}

#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#modal-card {
  background: #2a2a2a;
  border: 1px solid #444;
  width: 380px;
  padding: 25px;
  border-radius: 12px;
  color: #e5e7eb;
  box-shadow: 0 20px 50px rgba(5, 5, 5, 0.5);
  text-align: center;
}

#modal-card h3 {
  margin-top: 0;
  color: #fff;
  font-size: 1.2rem;
}

#modal-card p {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 20px;
}

#modal-card input {
  width: 100%;
  margin-bottom: 20px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: white;
  outline: none;
  box-sizing: border-box;
}

#modal-card button {
  width: 100%;
  background: var(--accent-color);
  padding: 12px;
}

/* --- New Project Header Styles --- */
.project-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.project-label {
  color: #e5e7eb;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  background-color: var(--accent-color);
  padding: 5px 8px;
  border-radius: 4px;
}

.project-name-input {
  font-size: 1.1rem !important;

  color: #ffffff !important;
}

/* -------------------------------- SCHEDULER MODAL UI ----------------------------------- */
.schedular-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.schedular-card {
  background: #1f1f1f;
  border: 1px solid #444;
  width: 450px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.schedular-header {
  padding: 20px;
  border-bottom: 1px solid #333;
  background: #252525;
}

.schedular-header h3 {
  margin: 0;
  color: white;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.schedular-body {
  padding: 20px;
}

.tab-container {
  display: flex;
  background: #111;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid #333;
}

.tab-btn {
  flex: 1;
  background: transparent;
  color: #9ca3af;
  border: none;
  padding: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 600;
}

.tab-btn.active {
  background: #333;
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.input-group {
  margin-bottom: 20px;
  display: none;
}

.input-group.active {
  display: block;
  animation: slideUp 0.3s ease;
}

.input-group label {
  display: block;
  color: #9ca3af;
  font-size: 0.8rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.schedular-input,
.schedular-select {
  width: 100%;
  padding: 12px;
  background: #111;
  border: 1px solid #444;
  border-radius: 8px;
  color: white;
  font-size: 0.95rem;
  outline: none;
  box-sizing: border-box;
  transition: border 0.2s;
}

.schedular-input:focus,
.schedular-select:focus {
  border-color: var(--accent-color);
}

input[type="file"]::file-selector-button {
  background: #333;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  margin-right: 10px;
  cursor: pointer;
}

input[type="datetime-local"] {
  appearance: none;
  background-color: #1a1a1a;
  color: #fff;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px 15px;
  font-family: "Segoe UI", sans-serif;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  cursor: pointer;
  color-scheme: dark;
  transition: all 0.2s ease;
  position: relative;
}

input[type="datetime-local"]:focus {
  border-color: var(--accent-color);
  background-color: #111;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3E%3Crect x="3" y="4" width="18" height="18" rx="2" ry="2"%3E%3C/rect%3E%3Cline x1="16" y1="2" x2="16" y2="6"%3E%3C/line%3E%3Cline x1="8" y1="2" x2="8" y2="6"%3E%3C/line%3E%3Cline x1="3" y1="10" x2="21" y2="10"%3E%3C/line%3E%3C/svg%3E');
  background-position: center;
  background-size: 20px;
  background-repeat: no-repeat;
  color: rgba(0, 0, 0, 0);
  opacity: 0.8;
  cursor: pointer;
  width: 24px;
  height: 24px;
  margin-left: 10px;
  transition: opacity 0.2s;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  transform: scale(1.1);
}

.schedular-footer {
  padding: 20px;
  border-top: 1px solid #333;
  background: #252525;
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  align-items: center;
}

.schedular-footer button {
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cancel-btn {
  background-color: #3a3a3a !important;
  color: #d1d5db !important;
  border: 1px solid #4a4a4a !important;
}

.cancel-btn:hover {
  background-color: #4a4a4a !important;
  color: #fff !important;
  transform: translateY(-1px);
}

.cancel-btn:active {
  transform: scale(0.98);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-color), #2563eb) !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  box-shadow: 0 6px 15px rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: scale(0.98);
}

/* --------------------------------- Animations ------------------------------------ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ----------------------- LOGIN OVERLAY ----------------------- */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
}

#login-overlay.hidden { display: none; }

#login-card {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 40px 36px;
  width: 340px;
  text-align: center;
}

.login-logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.login-subtitle {
  color: #9ca3af;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

#login-card input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-size: 0.95rem;
  box-sizing: border-box;
}

#login-card input:focus {
  outline: none;
  border-color: var(--accent-color);
}

#login-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

#login-btn:hover { opacity: 0.9; }
#login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#login-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 1.2em;
}

#app-container {
  width: 100%;
  height: 100vh;
  display: flex;
  overflow: hidden;
}