/* Modern styling for Atera RMM Chat Assistant */
:root {
  --bg-primary: #011320;
  --bg-secondary: #002238;
  --bg-card: rgba(0, 34, 56, 0.75);
  --border-color: rgba(152, 176, 71, 0.25);
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  
  /* Gradients & Accents */
  --accent-purple: #98b047;
  --accent-purple-hover: #a6bf4f;
  --accent-teal: #98b047;
  --accent-teal-hover: #a6bf4f;
  --accent-blue: #98b047;
  --accent-red: #ef4444;
  
  --glass-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --glass-border: 1px solid rgba(152, 176, 71, 0.25);
  
  --font-family: 'Montserrat', sans-serif;
  --transition-speed: 0.25s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* App Layout */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Sidebar Styling */
.sidebar {
  width: 320px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  max-width: 100%;
  max-height: 45px;
  object-fit: contain;
}

.brand-icon {
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand h2 span {
  color: var(--accent-purple);
}

.sidebar-section {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  overflow-y: auto;
}

.sidebar-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Forms & Inputs */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.input-with-icon input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 13px;
  transition: all var(--transition-speed) ease;
}

.input-with-icon input:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-purple-hover), var(--accent-blue));
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  border-color: var(--text-muted);
}

/* Status Indicator */
.settings-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-red);
}

.status-dot.active {
  background-color: var(--accent-teal);
  box-shadow: 0 0 8px var(--accent-teal);
}

/* Presets & Shortcuts */
.presets-section {
  flex-grow: 1;
}

.preset-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preset-btn {
  text-align: left;
  padding: 10px 12px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preset-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-purple);
  transform: translateX(3px);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Chat Workspace */
.chat-workspace {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
}

.chat-header {
  padding: 20px 32px;
  background-color: rgba(18, 24, 38, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.chat-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Messages Pane */
.messages-container {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

/* Scrollbars */
.messages-container::-webkit-scrollbar,
.sidebar-section::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.sidebar-section::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb,
.sidebar-section::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.sidebar-section::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted);
}

/* Message Bubble */
.message {
  display: flex;
  gap: 16px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

.message.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.model-message {
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.2);
}

.message.user-message .message-avatar {
  background: linear-gradient(135deg, var(--accent-teal), #00c6ff);
}

.message-content {
  padding: 16px 20px;
  border-radius: 16px;
  background-color: var(--bg-card);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  line-height: 1.6;
  font-size: 14.5px;
}

.message.user-message .message-content {
  border-top-right-radius: 4px;
  background-color: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.message.model-message .message-content {
  border-top-left-radius: 4px;
}

/* Welcome Message */
.system-message.welcome-message {
  max-width: 100%;
  align-self: center;
}

.system-message.welcome-message .message-content {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-color);
  padding: 24px;
  border-radius: 16px;
}

.system-message.welcome-message h3 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--accent-purple);
}

.system-message.welcome-message ul {
  margin: 16px 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.warning-text {
  font-size: 13px;
  color: #fbbf24;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Activity Panel */
.agent-activity-panel {
  position: absolute;
  bottom: 90px;
  left: 32px;
  right: 32px;
  background-color: rgba(18, 24, 38, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  z-index: 10;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: none;
  animation: slideUp 0.3s ease;
}

.activity-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.pulse-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-purple);
  animation: pulse 1.5s infinite;
}

.activity-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-purple);
}

.activity-logs {
  font-family: monospace;
  font-size: 11px;
  max-height: 120px;
  overflow-y: auto;
  color: var(--text-muted);
  background-color: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-entry i {
  color: var(--accent-teal);
}

/* Input Form */
.chat-input-area {
  padding: 24px 32px;
  background-color: rgba(11, 15, 25, 0.95);
  border-top: 1px solid var(--border-color);
}

.chat-form {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 16px;
  transition: all var(--transition-speed) ease;
}

.chat-form:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.chat-form textarea {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  resize: none;
  padding: 8px 0;
  outline: none;
  max-height: 150px;
}

.send-button {
  background-color: var(--accent-purple);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-speed) ease;
  margin-left: 12px;
}

.send-button:hover {
  background-color: var(--accent-purple-hover);
  transform: scale(1.05);
}

/* Custom classes for output formatting in markdown */
.message-content h1, .message-content h2, .message-content h3 {
  margin: 12px 0 6px 0;
  font-weight: 600;
  color: #fff;
}

.message-content h1 { font-size: 1.3em; }
.message-content h2 { font-size: 1.15em; }
.message-content h3 { font-size: 1.05em; }

.message-content p {
  margin-bottom: 10px;
}

.message-content ul, .message-content ol {
  margin: 10px 0;
  padding-left: 20px;
}

.message-content li {
  margin-bottom: 4px;
}

/* Markdown Table */
.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.message-content th, .message-content td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.message-content th {
  background-color: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
  font-weight: 600;
}

.message-content tr:last-child td {
  border-bottom: none;
}

/* Status Cards & Grid (for rich agentic layouts) */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.data-card {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-info { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background-color: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-success { background-color: rgba(16, 185, 129, 0.15); color: #34d399; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { opacity: 0.6; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0.6; transform: scale(0.95); }
}

/* Confirmation UI Styles */
.confirmation-message {
  align-self: flex-start;
  width: 100%;
  max-width: 600px;
}

.confirmation-card {
  background: rgba(1, 19, 32, 0.9) !important;
  border: 1px solid rgba(251, 191, 36, 0.4) !important; /* amber/yellow border to denote caution/confirmation */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(251, 191, 36, 0.1) !important;
  border-radius: 14px;
  width: 100%;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #fbbf24; /* amber yellow */
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.confirm-header i {
  font-size: 18px;
}

.confirm-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.confirm-field {
  display: flex;
  gap: 8px;
  font-size: 13.5px;
  align-items: baseline;
}

.confirm-field strong {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 100px;
  flex-shrink: 0;
}

.confirm-field span {
  color: var(--text-main);
  word-break: break-all;
}

.confirm-body-field {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-top: 5px;
}

.confirm-body-preview {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-family);
  font-size: 13px;
  color: #e2e8f0;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 15px;
}

.btn-confirm {
  background: linear-gradient(135deg, #10b981, #059669) !important; /* vibrant emerald green */
  color: #ffffff !important;
  border: none !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-confirm:hover {
  background: linear-gradient(135deg, #34d399, #059669) !important;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.btn-cancel {
  background: rgba(239, 68, 68, 0.1) !important; /* subtle red background */
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  color: #f87171 !important;
  font-weight: 500;
}

.btn-cancel:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}

/* Responsiveness */
.btn-back-toolbox {
  display: none;
}
.header-left-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    display: none; /* Hide sidebar entirely on mobile to save space */
  }
  .btn-back-toolbox {
    display: inline-flex; /* Show back button on mobile */
  }
  .chat-header {
    padding: 12px 16px;
  }
  .chat-header p {
    display: none; /* Hide description on mobile to keep header thin */
  }
  .messages-container {
    padding: 16px 12px;
    gap: 16px;
  }
  .message {
    max-width: 95%;
  }
  .chat-input-area {
    padding: 12px 16px;
  }
  .agent-activity-panel {
    bottom: 75px;
    left: 16px;
    right: 16px;
    padding: 12px;
  }
}


/* =========================================================
   MOBILE RESPONSIVENESS & IPHONE 15 PRO FIXES (SAFE AREA / SCROLL)
   ========================================================= */
html, body {
  height: 100% !important;
  height: 100dvh !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  position: fixed !important;
  top: 0; left: 0; right: 0; bottom: 0;
  -webkit-text-size-adjust: 100%;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.chat-workspace {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
  height: 100%;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.chat-header {
  padding: 16px 24px;
  background-color: rgba(18, 24, 38, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}

.messages-container {
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-input-area {
  padding: 16px 24px;
  padding-bottom: max(16px, calc(12px + env(safe-area-inset-bottom)));
  background-color: rgba(11, 15, 25, 0.98);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.btn-menu-toggle {
  display: none;
}

@media (max-width: 768px) {
  .btn-menu-toggle {
    display: inline-flex !important;
  }

  .btn-back-toolbox {
    display: inline-flex !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    bottom: 0;
    width: 290px;
    height: 100%;
    height: 100dvh;
    z-index: 1000;
    background-color: #002238;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex !important;
    flex-direction: column;
  }

  .sidebar.active {
    transform: translateX(320px);
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  .chat-header {
    padding-top: max(12px, calc(8px + env(safe-area-inset-top)));
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 10px;
  }

  .chat-header h1 {
    font-size: 16px;
  }

  .chat-header p {
    display: none;
  }

  .btn-text {
    display: none;
  }

  .messages-container {
    padding: 16px 12px 24px 12px;
    gap: 16px;
  }

  .message {
    max-width: 95%;
  }

  .chat-input-area {
    padding: 10px 12px;
    padding-bottom: max(12px, calc(10px + env(safe-area-inset-bottom)));
  }

  .chat-form {
    padding: 6px 12px;
  }

  .chat-form textarea {
    font-size: 16px; /* Fix iOS Safari auto-zoom on input focus */
  }

  .agent-activity-panel {
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    padding: 10px 14px;
  }
}

/* =========================================================
   HEADER BUTTONS & PDF EXPORT MOBILE FIX
   ========================================================= */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .chat-header {
    padding-top: max(8px, calc(6px + env(safe-area-inset-top))) !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    padding-bottom: 8px !important;
    gap: 4px !important;
  }

  .header-left-side {
    gap: 4px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .header-left-side h1 {
    font-size: 15px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .header-left-side h1 .badge {
    display: none !important;
  }

  .header-actions {
    gap: 4px !important;
    flex-shrink: 0 !important;
  }

  #chat-model-select {
    max-width: 95px !important;
    font-size: 11px !important;
    padding: 4px 6px !important;
    height: 32px !important;
    text-overflow: ellipsis !important;
  }

  #export-pdf, #clear-chat, .btn-menu-toggle, .btn-back-toolbox {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    flex-shrink: 0 !important;
    border-radius: 6px !important;
  }

  .btn-text {
    display: none !important;
  }
}
