/* === STANDING ORDERS — Dedicated Page === */

/* Page Layout */
.so-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Header */
.so-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.so-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.so-header-icon {
  font-size: 2.2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,215,0,0.1);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 12px;
}
.so-header-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffd700;
  letter-spacing: 2px;
  margin: 0;
}
.so-header-subtitle {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
  margin: 2px 0 0;
}

/* Stats Bar */
.so-stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.so-stat {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 18px;
  text-align: center;
  min-width: 80px;
}
.so-stat-num {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.so-stat-time {
  font-size: 0.85rem !important;
}
.so-stat-label {
  display: block;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}
.so-stat-active .so-stat-num { color: #28a745; }
.so-stat-inactive .so-stat-num { color: rgba(255,255,255,0.35); }
.so-stat-error .so-stat-num { color: #e74c3c; }

/* Main Layout — Sidebar + Detail */
.so-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  min-height: 500px;
}

/* Sidebar */
.so-sidebar {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.so-sidebar-header {
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.so-search {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 0.82rem;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.so-search:focus { border-color: rgba(0,255,255,0.4); }
.so-search::placeholder { color: rgba(255,255,255,0.3); }

.so-filter-row {
  display: flex;
  gap: 6px;
}
.so-filter-btn {
  flex: 1;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 4px 8px;
  color: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}
.so-filter-btn:hover { border-color: rgba(0,255,255,0.3); color: #fff; }
.so-filter-btn.active {
  background: rgba(0,255,255,0.1);
  border-color: rgba(0,255,255,0.3);
  color: #00e5ff;
}

.so-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.so-sidebar-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255,255,255,0.35);
}
.so-sidebar-empty p { margin: 4px 0; }

/* Sidebar Items */
.so-sidebar-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.so-sidebar-item:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
.so-sidebar-item.selected {
  background: rgba(0,255,255,0.06);
  border-color: rgba(0,255,255,0.2);
}
.so-sidebar-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.so-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.so-dot-active { background: #28a745; box-shadow: 0 0 6px rgba(40,167,69,0.5); }
.so-dot-inactive { background: rgba(255,255,255,0.2); }
.so-dot-error { background: #e74c3c; box-shadow: 0 0 6px rgba(231,76,60,0.5); }

.so-sidebar-item-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.so-sidebar-item-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding-left: 16px;
}
.so-sidebar-agent {
  font-size: 0.72rem;
  font-weight: 500;
}
.so-sidebar-schedule {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
}
.so-sidebar-item-last {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.3);
  padding-left: 16px;
  margin-top: 3px;
}
.so-error-badge {
  background: rgba(231,76,60,0.2);
  color: #e74c3c;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  font-weight: 700;
}

/* Toggle Switch */
.so-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.so-switch input { opacity: 0; width: 0; height: 0; }
.so-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  transition: 0.2s;
}
.so-switch-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.so-switch input:checked + .so-switch-slider { background: #28a745; }
.so-switch input:checked + .so-switch-slider::before { transform: translateX(16px); }

.so-switch-lg { width: 44px; height: 24px; }
.so-switch-lg .so-switch-slider::before { width: 20px; height: 20px; }
.so-switch-lg input:checked + .so-switch-slider::before { transform: translateX(20px); }

/* Detail Panel */
.so-detail {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
}
.so-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: rgba(255,255,255,0.3);
  text-align: center;
}
.so-detail-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.3;
}
.so-detail-empty h3 { margin: 0 0 6px; color: rgba(255,255,255,0.5); }
.so-detail-empty p { margin: 0; font-size: 0.85rem; }

.so-detail-content { padding: 0; }

/* Detail Header */
.so-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
  gap: 10px;
}
.so-detail-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.so-detail-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.so-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
}
.so-badge-active { background: rgba(40,167,69,0.2); color: #28a745; border: 1px solid rgba(40,167,69,0.3); }
.so-badge-inactive { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.4); border: 1px solid rgba(255,255,255,0.1); }

.so-detail-header-actions {
  display: flex;
  gap: 6px;
}

/* Detail Tabs */
.so-detail-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 22px;
}
.so-detail-tab {
  padding: 10px 18px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.so-detail-tab:hover { color: rgba(255,255,255,0.7); }
.so-detail-tab.active {
  color: #00e5ff;
  border-bottom-color: #00e5ff;
}

/* Detail Panels */
.so-detail-panel { padding: 22px; }

/* Detail Grid */
.so-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.so-detail-card {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 14px;
}
.so-detail-card-label {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.so-detail-card-value {
  font-size: 0.95rem;
  color: #fff;
  font-weight: 500;
}
.so-detail-card-schedule { font-family: 'JetBrains Mono', monospace; }
.so-detail-card-big { font-size: 1.8rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: #00e5ff; }
.so-detail-card-sub { font-size: 0.7rem; color: rgba(255,255,255,0.3); margin-top: 4px; }

/* Agent Chip */
.so-agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.2);
  border: 1px solid;
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
}
.so-agent-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #000;
}
.so-agent-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* Alerts */
.so-alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.82rem;
}
.so-alert-error {
  background: rgba(231,76,60,0.1);
  border: 1px solid rgba(231,76,60,0.3);
  color: #e74c3c;
}

/* Last Response Preview */
.so-last-response {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}
.so-last-response-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.so-last-response-text {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
}

/* Action Bar */
.so-detail-actions-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* Meta */
.so-detail-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  border-top: 1px solid rgba(255,255,255,0.04);
  padding-top: 12px;
}

/* Instruction View */
.so-instruction-view { }
.so-instruction-label {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
}
.so-instruction-text {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 16px;
  color: rgba(255,255,255,0.8);
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* History */
.so-history-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255,255,255,0.3);
}
.so-history-list { }
.so-history-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  margin-bottom: 10px;
}
.so-history-success { border-left: 3px solid #28a745; }
.so-history-error { border-left: 3px solid #e74c3c; }
.so-history-icon { font-size: 1.2rem; flex-shrink: 0; }
.so-history-time { font-size: 0.8rem; color: rgba(255,255,255,0.5); margin-bottom: 4px; }
.so-history-status { font-size: 0.85rem; color: #fff; font-weight: 500; }
.so-history-error-msg { font-size: 0.78rem; color: #e74c3c; margin-top: 4px; }
.so-history-response {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  margin-top: 8px;
  max-height: 100px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.so-history-summary {
  padding: 16px;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 0.82rem;
}

/* Settings */
.so-settings-section {
  margin-bottom: 28px;
}
.so-settings-section h4 {
  font-size: 0.9rem;
  color: #ffd700;
  margin: 0 0 14px;
  letter-spacing: 1px;
}
.so-settings-danger {
  border-top: 1px solid rgba(231,76,60,0.2);
  padding-top: 20px;
}
.so-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.7);
}

/* Buttons */
.so-btn {
  padding: 8px 16px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.so-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); }
.so-btn-sm { padding: 5px 10px; font-size: 0.72rem; }
.so-btn-primary {
  background: rgba(0,229,255,0.15);
  border-color: rgba(0,229,255,0.3);
  color: #00e5ff;
}
.so-btn-primary:hover { background: rgba(0,229,255,0.25); }
.so-btn-warning {
  background: rgba(255,193,7,0.15);
  border-color: rgba(255,193,7,0.3);
  color: #ffc107;
}
.so-btn-warning:hover { background: rgba(255,193,7,0.25); }
.so-btn-danger {
  background: rgba(231,76,60,0.15);
  border-color: rgba(231,76,60,0.3);
  color: #e74c3c;
}
.so-btn-danger:hover { background: rgba(231,76,60,0.3); }
.so-btn-danger-outline {
  background: none;
  border-color: rgba(231,76,60,0.3);
  color: #e74c3c;
}
.so-btn-danger-outline:hover { background: rgba(231,76,60,0.1); }
.so-btn-ghost {
  background: none;
  border-color: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
}
.so-btn-ghost:hover { background: rgba(255,255,255,0.05); color: #fff; }

/* Form */
.so-form-group { margin-bottom: 16px; }
.so-label {
  display: block;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.so-input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.so-input:focus { border-color: rgba(0,255,255,0.4); }
.so-input::placeholder { color: rgba(255,255,255,0.25); }
.so-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
}
.so-select option { background: #1a1a2e; color: #fff; }
.so-input-cron {
  margin-top: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.so-textarea {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}
.so-textarea:focus { border-color: rgba(0,255,255,0.4); }
.so-textarea::placeholder { color: rgba(255,255,255,0.25); }
.so-cron-help {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.25);
  margin-top: 4px;
}

/* Modal */
.so-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.so-modal-overlay.hidden { display: none; }
.so-modal {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.so-modal-sm { max-width: 420px; }
.so-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.so-modal-header h2 {
  font-size: 1.1rem;
  color: #ffd700;
  margin: 0;
}
.so-modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.so-modal-close:hover { color: #fff; }
.so-modal-body { padding: 22px; }
.so-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.so-delete-msg { color: rgba(255,255,255,0.7); font-size: 0.9rem; margin: 0; }

/* Toast */
.so-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px 20px;
  color: #fff;
  font-size: 0.85rem;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.so-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.so-toast-success { border-color: rgba(40,167,69,0.4); }
.so-toast-error { border-color: rgba(231,76,60,0.4); }
.so-toast-info { border-color: rgba(0,229,255,0.4); }

/* Agent Grid Picker */
.so-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}
.so-agent-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(0,0,0,0.15);
}
.so-agent-pick:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.15);
}
.so-agent-pick.selected {
  background: rgba(0,229,255,0.08);
  border-color: rgba(0,229,255,0.4);
  box-shadow: 0 0 12px rgba(0,229,255,0.1);
}
.so-agent-pick-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.so-agent-pick.selected .so-agent-pick-avatar {
  box-shadow: 0 0 8px rgba(0,229,255,0.3);
}
.so-agent-pick-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.so-agent-pick-initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #000;
  border-radius: 50%;
}
.so-agent-pick-name {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 68px;
  font-weight: 500;
  transition: color 0.15s;
}
.so-agent-pick.selected .so-agent-pick-name {
  font-weight: 600;
}

/* Muted text */
.so-muted { color: rgba(255,255,255,0.3); font-size: 0.8rem; }
.so-loading { text-align: center; padding: 30px; color: rgba(255,255,255,0.3); }

/* Responsive */
@media (max-width: 900px) {
  .so-layout {
    grid-template-columns: 1fr;
  }
  .so-sidebar {
    max-height: 300px;
  }
  .so-detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .so-page { padding: 12px; }
  .so-header { flex-direction: column; align-items: flex-start; }
  .so-stats-bar { flex-wrap: wrap; }
  .so-detail-grid { grid-template-columns: 1fr; }
  .so-detail-header { flex-direction: column; align-items: flex-start; }
  .so-detail-tabs { overflow-x: auto; }
}
