/* ================================================================
   CuCu Note Extension — Premium Design System
   Modern, rounded, glassmorphic UI with warm brown palette
   ================================================================ */

/* ---- Light Theme (Paper — warm brown/amber) ---- */
:root {
  --background: oklch(0.95 0.015 75);
  --foreground: oklch(0.25 0.02 65);
  --card: oklch(0.98 0.008 80);
  --card-foreground: oklch(0.22 0.015 68);
  --popover: oklch(0.98 0.008 80);
  --popover-foreground: oklch(0.25 0.02 65);
  --primary: oklch(0.45 0.08 45);
  --primary-foreground: oklch(0.98 0.008 80);
  --secondary: oklch(0.92 0.025 70);
  --secondary-foreground: oklch(0.35 0.03 60);
  --muted: oklch(0.9 0.025 75);
  --muted-foreground: oklch(0.5 0.02 68);
  --accent: oklch(0.88 0.035 55);
  --accent-foreground: oklch(0.25 0.02 65);
  --destructive: oklch(0.48 0.15 25);
  --border: oklch(0.88 0.018 72);
  --input: oklch(0.8 0.03 75);
  --ring: oklch(0.45 0.08 45);
  --radius: 12px;
  --success: oklch(0.6 0.15 145);
  --warning: oklch(0.7 0.12 75);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.04);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.06);
  --shadow-lg: 0 8px 24px oklch(0 0 0 / 0.08);
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---- Dark Theme ---- */
[data-theme="dark"] {
  --background: oklch(0.16 0.008 60);
  --foreground: oklch(0.9 0.012 75);
  --card: oklch(0.20 0.01 62);
  --card-foreground: oklch(0.9 0.012 75);
  --popover: oklch(0.20 0.01 62);
  --popover-foreground: oklch(0.88 0.01 72);
  --primary: oklch(0.65 0.1 45);
  --primary-foreground: oklch(0.15 0.008 60);
  --secondary: oklch(0.26 0.012 65);
  --secondary-foreground: oklch(0.85 0.01 72);
  --muted: oklch(0.23 0.01 62);
  --muted-foreground: oklch(0.6 0.015 70);
  --accent: oklch(0.28 0.015 55);
  --accent-foreground: oklch(0.82 0.012 68);
  --destructive: oklch(0.55 0.1 25);
  --border: oklch(0.30 0.012 62);
  --input: oklch(0.35 0.015 65);
  --ring: oklch(0.65 0.1 45);
  --success: oklch(0.65 0.15 145);
  --warning: oklch(0.75 0.12 75);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.15);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.2);
  --shadow-lg: 0 8px 24px oklch(0 0 0 / 0.25);
}

/* ================================================================
   Base Reset
   ================================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 380px;
  min-height: 200px;
  overflow-x: hidden;
}

/* ================================================================
   Animations
   ================================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes glow {

  0%,
  100% {
    box-shadow: 0 0 4px oklch(0.6 0.15 145 / 0.3);
  }

  50% {
    box-shadow: 0 0 10px oklch(0.6 0.15 145 / 0.5);
  }
}

@keyframes successPop {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }

  50% {
    transform: scale(1.02);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ================================================================
   Popup Container
   ================================================================ */
.popup-container {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  animation: fadeIn 0.2s ease-out;
}

/* ================================================================
   Header
   ================================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--foreground);
  letter-spacing: -0.01em;
}

.header-brand-icon {
  font-size: 20px;
  filter: drop-shadow(0 1px 2px oklch(0 0 0 / 0.1));
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.status-connected {
  background: var(--success);
  animation: glow 2s ease-in-out infinite;
}

.status-dot.status-offline {
  background: var(--destructive);
}

.status-text {
  font-size: 11px;
}

/* ================================================================
   Content
   ================================================================ */
.content {
  padding: 16px 18px;
  animation: fadeIn 0.3s ease-out;
}

/* ================================================================
   Note Form
   ================================================================ */
.note-form {
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}

/* ---- Textarea ---- */
.note-textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  resize: vertical;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.note-textarea::placeholder {
  color: var(--muted-foreground);
  font-style: italic;
}

.note-textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px oklch(0.45 0.08 45 / 0.1);
}

/* ================================================================
   Source Info
   ================================================================ */
.source-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted-foreground);
  padding: 8px 12px;
  background: var(--muted);
  border-radius: calc(var(--radius) - 2px);
  margin-top: 10px;
  border: 1px solid var(--border);
}

/* ================================================================
   Tags Section
   ================================================================ */
.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: inherit;
  user-select: none;
}

.tag-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: oklch(0.45 0.08 45 / 0.06);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.tag-chip.selected {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: 0 2px 6px oklch(0.45 0.08 45 / 0.2);
}

.tag-chip.selected:hover {
  filter: brightness(1.1);
  background: var(--primary);
  color: var(--primary-foreground);
  transform: translateY(-1px);
}

.tag-input-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.tag-input-inline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tag-input-field {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
  color: var(--foreground);
  width: 80px;
}

/* ================================================================
   Workspace / Select
   ================================================================ */
.form-group {
  margin-bottom: 14px;
}

.select {
  display: block;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1.5px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  padding: 10px 36px 10px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px oklch(0.45 0.08 45 / 0.1);
}

/* ================================================================
   Visibility Selector
   ================================================================ */
.visibility-selector {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.visibility-selector:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ================================================================
   Buttons
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  padding: 9px 18px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), oklch(0.5 0.1 50));
  color: var(--primary-foreground);
  box-shadow: 0 2px 8px oklch(0.45 0.08 45 / 0.25);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px oklch(0.45 0.08 45 / 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--muted);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  padding: 6px 12px;
}

.btn-ghost:hover {
  background: var(--muted);
  color: var(--foreground);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: calc(var(--radius) - 4px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

/* ================================================================
   Action Bar (bottom)
   ================================================================ */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================================================================
   Badges & Messages
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: oklch(0.6 0.15 145 / 0.12);
  color: var(--success);
  border: 1px solid oklch(0.6 0.15 145 / 0.2);
  animation: successPop 0.3s ease-out;
}

.error {
  padding: 10px 14px;
  margin-top: 10px;
  background: oklch(0.55 0.15 25 / 0.08);
  color: var(--destructive);
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
  border: 1px solid oklch(0.55 0.15 25 / 0.15);
  animation: fadeIn 0.2s ease-out;
}

.success {
  padding: 10px 14px;
  margin-bottom: 12px;
  background: oklch(0.6 0.15 145 / 0.08);
  color: var(--success);
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
  border: 1px solid oklch(0.6 0.15 145 / 0.15);
}

/* ================================================================
   Loading Spinner
   ================================================================ */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

/* ================================================================
   Scrollbar
   ================================================================ */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* ================================================================
   Smooth transitions on all themed elements  
   ================================================================ */
*,
*::before,
*::after {
  transition-property: background-color, color, border-color, box-shadow, opacity;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}

/* Opt-out for animation elements */
.spinner,
.spinner *,
[class*="animate-"] {
  transition: none !important;
}