@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================================
   GLOBAL DESIGN SYSTEM
   ============================================================ */
:root {
  --capcut-black: #08080a;
  --capcut-dark: #111114;
  --capcut-panel: #18181c;
  --capcut-surface: #22222a;
  --capcut-surface-hover: #2a2a33;
  --capcut-border: #33333d;
  --capcut-border-light: #3e3e48;
  --capcut-text: #ededef;
  --capcut-muted: #a0a0aa;
  --capcut-subtle: #6e6e78;
  --capcut-blue: #3aa6ff;
  --capcut-orange: #ff8a3d;
  --capcut-red: #ff4757;
  --capcut-green: #3dffa3;
  --capcut-yellow: #ffd23d;
  --capcut-purple: #a86cff;
}

html,
body {
  background-color: var(--capcut-black);
  color: var(--capcut-text);
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#__next,
body > div:first-child {
  height: 100%;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--capcut-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--capcut-border);
  border-radius: 4px;
  border: 2px solid var(--capcut-dark);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--capcut-border-light);
}
::-webkit-scrollbar-corner {
  background: var(--capcut-dark);
}

/* ============================================================
   RANGE INPUT (sliders)
   ============================================================ */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 24px;
}
input[type='range']:focus {
  outline: none;
}
input[type='range']::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--capcut-blue), var(--capcut-blue));
  background-color: var(--capcut-border);
  height: 4px;
  border-radius: 2px;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  background-color: #fff;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(58, 166, 255, 0.4);
  transition: transform 120ms ease-out;
}
input[type='range']:hover::-webkit-slider-thumb,
input[type='range']:active::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(58, 166, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.4);
}
input[type='range']::-moz-range-track {
  background: var(--capcut-border);
  height: 4px;
  border-radius: 2px;
}
input[type='range']::-moz-range-thumb {
  background-color: #fff;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   FOCUS RINGS (only on keyboard nav)
   ============================================================ */
*:focus {
  outline: none;
}
*:focus-visible {
  outline: 2px solid var(--capcut-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

button {
  font-family: inherit;
  cursor: pointer;
  transition: background-color 120ms ease-out, color 120ms ease-out,
    transform 80ms ease-out, box-shadow 120ms ease-out;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

input,
textarea {
  font-family: inherit;
}

/* ============================================================
   CUSTOM CHECKBOX
   ============================================================ */
input[type='checkbox'] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--capcut-border-light);
  background: var(--capcut-surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 120ms ease-out;
}
input[type='checkbox']:checked {
  background: var(--capcut-blue);
  border-color: var(--capcut-blue);
}
input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type='checkbox']:hover {
  border-color: var(--capcut-blue);
}

/* ============================================================
   NUMBER INPUT
   ============================================================ */
input[type='number'],
input[type='text'],
textarea {
  background: var(--capcut-surface);
  border: 1px solid var(--capcut-border);
  color: var(--capcut-text);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  transition: border-color 120ms ease-out;
}
input[type='number']:focus,
input[type='text']:focus,
textarea:focus {
  border-color: var(--capcut-blue);
  box-shadow: 0 0 0 2px rgba(58, 166, 255, 0.2);
}
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ============================================================
   COLOR PICKER
   ============================================================ */
input[type='color'] {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--capcut-border);
  border-radius: 6px;
  width: 32px;
  height: 28px;
  cursor: pointer;
  padding: 2px;
  background: var(--capcut-surface);
}
input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type='color']::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

/* ============================================================
   TOOLTIP (data-tip)
   ============================================================ */
.tip {
  position: relative;
}
.tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: #000;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: tipFade 120ms ease-out;
}
.tip:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #000;
  z-index: 1000;
  pointer-events: none;
}
@keyframes tipFade {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.cursor-col-resize { cursor: col-resize; }
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }
.no-select { -webkit-user-select: none; user-select: none; }

.glass {
  background: rgba(17, 17, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.animate-pulse-soft {
  animation: pulse-soft 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.animate-shimmer {
  background: linear-gradient(90deg, var(--capcut-surface) 0%, var(--capcut-surface-hover) 50%, var(--capcut-surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-slide-up {
  animation: slideUp 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.animate-fade-in {
  animation: fadeIn 200ms ease-out;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 1s linear infinite;
}

/* ============================================================
   SCROLLBAR INSIDE TIMELINE (thin & subtle)
   ============================================================ */
.scroll-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.scroll-thin::-webkit-scrollbar-track {
  background: transparent;
}
.scroll-thin::-webkit-scrollbar-thumb {
  background: var(--capcut-border);
  border-radius: 3px;
}
.scroll-thin::-webkit-scrollbar-thumb:hover {
  background: var(--capcut-border-light);
}

/* ============================================================
   SMOOTH TRANSITIONS on hover (utility for buttons)
   ============================================================ */
.transition-base {
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
}