/* ══════════════════════════════════════════════
   StaxOS — Shared App Interior Components
   All apps use these for consistent branding
   ══════════════════════════════════════════════ */

/* ── App Layout: Sidebar + Content ── */
.app-layout {
  display: flex;
  height: 100%;
}

.app-sidebar {
  width: 200px;
  background: var(--stax-panel, var(--os-bg-alt));
  border-right: 1px solid var(--os-border);
  padding: 12px 0;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: auto;
  }
  
  .app-sidebar {
    width: 100%;
    height: auto;
    max-height: 52px;
    border-right: none;
    border-bottom: 1px solid var(--os-border-light);
    padding: 4px 0;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    flex-wrap: nowrap;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    box-sizing: border-box;
  }
  .app-sidebar::-webkit-scrollbar { display: none; }

  .app-sidebar-section {
    display: flex;
    flex-direction: row;
    margin-bottom: 0;
    padding: 0 4px;
    flex-shrink: 0;
  }

  .app-sidebar-title {
    display: none;
  }

  .app-sidebar-item {
    white-space: nowrap;
    padding: 12px 14px;
    font-size: 13px;
    min-height: 44px;
    display: flex;
    align-items: center;
    border-radius: 10px;
  }
  .app-sidebar-item.active {
    background: var(--os-accent-glow, rgba(200,164,74,0.14));
  }

  .app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }
}

.app-sidebar-section {
  padding: 0 8px;
  margin-bottom: 16px;
}

.app-sidebar-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--os-text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.app-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--os-radius-sm);
  font-size: 13px;
  color: var(--os-text);
  cursor: pointer;
  transition: background var(--os-transition);
}
.app-sidebar-item:hover { background: var(--os-accent-glow); }
.app-sidebar-item.active {
  background: var(--os-accent);
  color: var(--os-text-inverse);
  font-weight: 600;
}
.app-sidebar-item.active svg { stroke: var(--os-text-inverse); }

.app-sidebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.app-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

/* ── Cards ── */
.card {
  background: var(--os-surface);
  border: 1px solid var(--os-border-light);
  border-radius: var(--os-radius-md);
  padding: var(--os-space-lg);
  box-shadow: var(--os-shadow-sm);
  transition: box-shadow var(--os-transition), border-color var(--os-transition);
}
.card:hover {
  box-shadow: var(--os-shadow-md);
  border-color: var(--os-border-accent);
}
.card-clickable { cursor: pointer; }
.card-accent {
  border-left: 3px solid var(--os-accent);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--os-space-lg);
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--os-radius-md);
  background: var(--os-accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--os-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--os-transition);
  /* A plain .btn on a <button> used to inherit the browser's black text on
     the dark surface; the base is the secondary look, variants override it. */
  border: 1px solid var(--os-border);
  background: var(--os-surface);
  color: var(--os-text);
}

.btn-primary {
  background: var(--os-accent);
  color: var(--os-text-inverse);
  border-color: var(--os-accent);
}
.btn-primary:hover { background: var(--os-accent-hover); }

.btn-secondary {
  background: var(--os-surface);
  color: var(--os-text);
  border-color: var(--os-border);
}
.btn-secondary:hover {
  background: var(--os-accent-glow);
  border-color: var(--os-accent);
}

.btn-ghost {
  color: var(--os-accent);
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--os-accent-glow); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 14px; }
.btn-icon { padding: 6px; border-radius: var(--os-radius-sm); }

/* ── Inputs ── */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--os-border);
  border-radius: var(--os-radius-sm);
  background: var(--os-surface);
  color: var(--os-text);
  font-size: 16px;
  transition: border-color var(--os-transition), box-shadow var(--os-transition);
}
.input:focus {
  border-color: var(--os-accent);
  box-shadow: 0 0 0 3px var(--os-accent-glow);
}
.input::placeholder { color: var(--os-text-muted); }

.textarea {
  resize: vertical;
  min-height: 80px;
}

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238a9a8a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-group {
  margin-bottom: var(--os-space-lg);
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--os-text-secondary);
  margin-bottom: 4px;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--os-border-light);
  border-radius: var(--os-radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--os-bg-alt);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--os-text-secondary);
  border-bottom: 1px solid var(--os-border-light);
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--os-border-light);
}
.data-table tr:hover td { background: var(--os-accent-bg); }
.data-table tr:last-child td { border-bottom: none; }

/* ── Badges / Tags ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: rgba(200, 164, 74, 0.15); color: var(--os-accent); }
.badge-warning { background: rgba(255,152,0,0.15); color: #E65100; }
.badge-danger  { background: rgba(244,67,54,0.15); color: #C62828; }
.badge-info    { background: rgba(33,150,243,0.15); color: #1565C0; }

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 40px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--os-surface);
  border: 1px solid var(--os-border);
  border-radius: var(--os-radius-md);
  box-shadow: var(--os-shadow-lg);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  min-width: 280px;
  animation: toastIn 0.3s ease;
}
.toast.closing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(100%); opacity: 0; } }

.toast-success { border-left: 3px solid var(--os-success); }
.toast-error   { border-left: 3px solid var(--os-danger); }
.toast-warning { border-left: 3px solid var(--os-warning); }
.toast-info    { border-left: 3px solid var(--os-info); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--os-text-muted);
}
.empty-state-icon {
  margin-bottom: 12px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--os-text-secondary);
  margin-bottom: 4px;
}

/* ── Miller Column Layout (File Manager) ── */
.miller-columns {
  display: flex;
  height: 100%;
  overflow-x: auto;
}

.miller-column {
  min-width: 220px;
  max-width: 280px;
  border-right: 1px solid var(--os-border-light);
  overflow-y: auto;
  flex-shrink: 0;
}

.miller-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--os-transition);
}
.miller-item:hover { background: var(--os-accent-glow); }
.miller-item.active {
  background: var(--os-accent);
  color: var(--os-text-inverse);
}

.miller-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.miller-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.miller-item-arrow {
  color: var(--os-text-muted);
  flex-shrink: 0;
  font-size: 10px;
}
.miller-item.active .miller-item-arrow { color: var(--os-text-inverse); }

/* ── Preview Pane (right of Miller columns) ── */
.preview-pane {
  flex: 1;
  min-width: 240px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--os-text-muted);
}

.preview-pane-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--os-radius-lg);
  background: var(--os-accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.preview-pane-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--os-text);
  margin-bottom: 4px;
}

.preview-pane-meta {
  font-size: 12px;
  color: var(--os-text-muted);
  line-height: 1.6;
}

/* ── Chat UI (ClawBot) ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--os-radius-lg);
  font-size: 13px;
  line-height: 1.5;
}
.chat-bubble.user {
  background: var(--os-accent);
  color: var(--os-text-inverse);
  align-self: flex-end;
  border-bottom-right-radius: var(--os-radius-xs);
}
.chat-bubble.assistant {
  background: var(--os-bg-alt);
  color: var(--os-text);
  align-self: flex-start;
  border-bottom-left-radius: var(--os-radius-xs);
  border: 1px solid var(--os-border-light);
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--os-border-light);
}

.chat-input {
  flex: 1;
}

/* ── Scrollbar (green themed) ── */
.os-window-content::-webkit-scrollbar-thumb { background: rgba(200, 164, 74, 0.3); }
.os-window-content::-webkit-scrollbar-thumb:hover { background: rgba(200, 164, 74, 0.5); }

/* ════════════════════════════════════════════
   Theme Engine — Appearance Settings Components
   ════════════════════════════════════════════ */

/* Accent color circles */
.theme-swatch-color {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid transparent;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: transform var(--os-transition), outline-color var(--os-transition);
  flex-shrink: 0;
}
.theme-swatch-color:hover  { transform: scale(1.12); }
.theme-swatch-color.active { outline-color: var(--os-text); }

/* Custom color <input type=color> */
.theme-color-input {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  padding: 1px;
  border: 2px solid var(--os-border);
  cursor: pointer;
  overflow: hidden;
  background: none;
  flex-shrink: 0;
}

/* Gradient preview rectangles */
.theme-swatch-grad {
  width: 52px;
  height: 34px;
  border-radius: var(--os-radius-sm);
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform var(--os-transition), border-color var(--os-transition), box-shadow var(--os-transition);
  flex-shrink: 0;
}
.theme-swatch-grad:hover  { transform: scale(1.06); }
.theme-swatch-grad.active { border-color: var(--os-accent); box-shadow: var(--os-shadow-sm); }

/* Rainbow swatch for "custom" option */
.theme-swatch-rainbow {
  background: conic-gradient(#f44336, #ff9800, #4caf50, #2196f3, #9c27b0, #f44336) !important;
}

/* Font option cards */
.theme-font-option {
  padding: 10px 14px;
  border-radius: var(--os-radius-md);
  border: 1.5px solid var(--os-border-light);
  cursor: pointer;
  transition: all var(--os-transition);
  user-select: none;
}
.theme-font-option:hover  { border-color: var(--os-accent); background: var(--os-accent-glow); }
.theme-font-option.active { border-color: var(--os-accent); background: var(--os-accent-bg); }

.theme-font-name    { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.theme-font-preview { font-size: 12px; color: var(--os-text-secondary); }

/* ── Spinner ── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--os-border-light);
  border-top-color: var(--os-accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
