/* ==========================================================================
   OpenClaw Studio - shadcn/ui inspired Design System Tokens & Base Styles
   Palette: Zinc / Slate (Crisp dark & light modes, subtle borders, clean shadows)
   ========================================================================== */

:root {
  /* Dark mode default (Zinc/Slate theme matching shadcn dark) */
  --background: #09090b;
  --foreground: #f4f4f5;

  --card: #121215;
  --card-foreground: #f4f4f5;

  --popover: #121215;
  --popover-foreground: #f4f4f5;

  --primary: #fafafa;
  --primary-foreground: #09090b;

  --secondary: #27272a;
  --secondary-foreground: #fafafa;

  --muted: #18181b;
  --muted-foreground: #a1a1aa;

  --accent: #27272a;
  --accent-foreground: #fafafa;

  --destructive: #ef4444;
  --destructive-foreground: #fafafa;

  --success: #10b981;
  --success-foreground: #fafafa;

  --warning: #f59e0b;
  --warning-foreground: #09090b;

  --border: #27272a;
  --input: #27272a;
  --ring: #d4d4d8;

  --radius: 0.5rem; /* 8px */
  --radius-sm: 0.375rem; /* 6px */
  --radius-lg: 0.75rem; /* 12px */
  --radius-xl: 1rem; /* 16px */

  /* Aliases for backwards compatibility with existing templates */
  --bg-dark: var(--background);
  --card-bg: var(--card);
  --card-border: var(--border);
  --text: var(--foreground);
  --text-muted: var(--muted-foreground);
  --primary-hover: #e4e4e7;
  --danger: var(--destructive);
}

/* Light mode tokens (shadcn light) */
body.theme-light {
  --background: #f8fafc;
  --foreground: #0f172a;

  --card: #ffffff;
  --card-foreground: #0f172a;

  --popover: #ffffff;
  --popover-foreground: #0f172a;

  --primary: #0f172a;
  --primary-foreground: #f8fafc;

  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;

  --muted: #f1f5f9;
  --muted-foreground: #64748b;

  --accent: #f1f5f9;
  --accent-foreground: #0f172a;

  --destructive: #ef4444;
  --destructive-foreground: #ffffff;

  --success: #10b981;
  --success-foreground: #ffffff;

  --warning: #f59e0b;
  --warning-foreground: #0f172a;

  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #0f172a;

  /* Aliases */
  --bg-dark: var(--background);
  --card-bg: var(--card);
  --card-border: var(--border);
  --text: var(--foreground);
  --text-muted: var(--muted-foreground);
  --primary-hover: #1e293b;
}

/* Global Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  font-size: 0.875rem; /* 14px */
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* App Header (shadcn navbar) */
header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  letter-spacing: -0.01em;
}

.logo-badge {
  background: var(--secondary);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Base Buttons (shadcn button variants) */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.25rem;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  white-space: nowrap;
}
.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-0.5px);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.btn-secondary:hover {
  background: var(--muted);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}
.btn-ghost:hover {
  background: var(--accent);
  color: var(--foreground);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--destructive);
  color: var(--destructive-foreground);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s ease-in-out;
}
.btn-danger:hover {
  opacity: 0.9;
}

/* Nav Tab Buttons */
.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted-foreground);
  background: transparent;
  transition: all 0.15s ease-in-out;
}
.nav-tab-btn:hover {
  color: var(--foreground);
  background: var(--secondary);
}
.nav-tab-btn.active {
  background: var(--secondary);
  color: var(--foreground);
  border-color: var(--border);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Inputs & Form Controls (shadcn input) */
.field {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.field:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
body.theme-light .field:focus {
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.1);
}
.field::placeholder {
  color: var(--muted-foreground);
  opacity: 0.7;
}

/* Toast Messages */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-success {
  background: #059669;
}
.toast-error {
  background: #dc2626;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
}
.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}
.badge-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

/* Error Text */
.error-text {
  color: var(--destructive);
  font-size: 12px;
  margin-top: 6px;
  display: none;
}
