/* ============================================================
   Live Studio — Global Styles
   Dark theme, CSS custom properties, shared components
   ============================================================ */

/* Design Tokens */
:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --surface-3: #2e2e2e;
  --border: #333;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #6c5ce7;
  --accent-hover: #7c6cf7;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --recording: #e74c3c;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: 0.2s ease;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --glow-accent: 0 0 0 2px rgba(108, 92, 231, 0.4);
  --glow-recording: 0 0 0 2px rgba(231, 76, 60, 0.5);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  color: var(--text-muted);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
  background-color: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background-color: #f05a4b;
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.4);
}

.btn-success {
  background-color: var(--success);
  color: #fff;
}

.btn-success:hover {
  background-color: #35d67b;
  box-shadow: 0 4px 16px rgba(46, 204, 113, 0.4);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.125rem;
  position: relative;
}

.btn-icon:hover {
  background-color: var(--surface-3);
  border-color: var(--accent);
}

.btn-icon.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-lg {
  height: 56px;
  padding: 0 32px;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-full {
  width: 100%;
}

/* ============================================================
   Form Elements
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--glow-accent);
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

select option {
  background-color: var(--surface-2);
  color: var(--text);
}

/* ============================================================
   Card
   ============================================================ */

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-sm {
  padding: 16px;
}

/* ============================================================
   Divider
   ============================================================ */

.divider {
  height: 1px;
  background-color: var(--border);
  margin: 20px 0;
}

/* ============================================================
   Badge / Tag
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-recording {
  background-color: rgba(231, 76, 60, 0.15);
  color: var(--recording);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.badge-live {
  background-color: rgba(46, 204, 113, 0.15);
  color: var(--success);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

/* Recording dot pulse animation */
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--recording);
  animation: pulse-rec 1.5s ease-in-out infinite;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ============================================================
   Toast Notifications
   ============================================================ */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  max-width: 320px;
  pointer-events: auto;
  animation: toast-in 0.25s ease forwards;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.toast-out {
  animation: toast-out 0.25s ease forwards;
}

.toast-icon {
  font-size: 1.125rem;
  flex-shrink: 0;
}

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

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: slide-up 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background-color: var(--surface-2);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ============================================================
   Skeleton Loading
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Spinner
   ============================================================ */

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Tooltip
   ============================================================ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--surface-3);
  color: var(--text);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  border: 1px solid var(--border);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ============================================================
   Video Grid
   ============================================================ */

.video-grid {
  display: grid;
  gap: 8px;
  width: 100%;
  height: 100%;
}

.video-tile {
  position: relative;
  background-color: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.video-tile.active-speaker {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(108, 92, 231, 0.3);
  animation: speaker-glow 2s ease-in-out infinite;
}

@keyframes speaker-glow {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(108, 92, 231, 0.3); }
  50%       { box-shadow: 0 0 0 2px var(--accent), 0 0 30px rgba(108, 92, 231, 0.5); }
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
}

.tile-muted {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

/* ============================================================
   Utility classes
   ============================================================ */

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

/* ============================================================
   Animations
   ============================================================ */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Recording border pulse on host bar */
.recording-pulse {
  animation: border-pulse 1.5s ease-in-out infinite;
}

@keyframes border-pulse {
  0%, 100% { border-color: transparent; }
  50%       { border-color: var(--recording); box-shadow: 0 0 12px rgba(231, 76, 60, 0.4); }
}

/* ============================================================
   Copy button feedback
   ============================================================ */

.btn-copy {
  position: relative;
  overflow: hidden;
}

.btn-copy.copied::after {
  content: "Скопійовано!";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--success);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  animation: fade-in 0.15s ease;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1023px) {
  .hide-mobile { display: none; }
}

@media (min-width: 1024px) {
  .hide-desktop { display: none; }
}
