/**
 * Tapko Kit Builder Styles
 * A dark-themed UI for building drum kits
 */

/* ===== CSS Variables ===== */
:root {
  --bg: #0b0d12;
  --panel: rgba(21, 24, 32, 0.9);
  --panel-2: rgba(29, 33, 44, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f7fb;
  --text-secondary: #b8c0d0;
  --muted: #9ca6ba;
  --success: #67e8a5;
  --success-soft: rgba(103, 232, 165, 0.12);
  --danger: #ff8a8a;
  --danger-soft: rgba(255, 138, 138, 0.12);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;

  /* Pad row colors (4 rows of 4 pads) */
  --pad-row-0: #3b82f6; /* Blue */
  --pad-row-1: #8b5cf6; /* Purple */
  --pad-row-2: #f97316; /* Orange */
  --pad-row-3: #14b8a6; /* Teal */
}

/* ===== Reset & Base ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(124, 58, 237, 0.07), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(88, 101, 242, 0.05), transparent 55%),
    #111827;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Site Nav ===== */
.site-nav {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0 2rem;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-nav-inner {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-nav-links {
  display: flex;
  gap: 1.5rem;
}

.site-nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.15s;
}

.site-nav-links a:hover,
.site-nav-links a.active { color: var(--text); }

/* ===== App Container ===== */
.app {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px;
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kit-name-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.kit-name-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  width: 160px;
  padding: 0;
}

.kit-name-input::placeholder {
  color: var(--muted);
}

.icon-sm {
  width: 18px;
  height: 18px;
}

/* ===== Buttons ===== */
.icon-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon-btn.small {
  width: 36px;
  height: 36px;
}

.icon-btn.danger {
  color: var(--danger);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  border-color: rgba(255, 138, 138, 0.25);
}

/* ===== Main Layout ===== */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
}

.grid-wrap,
.editor {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.grid-wrap {
  padding: 20px;
}

.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.grid-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.grid-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ===== Pad Grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pad-cell {
  position: relative;
  aspect-ratio: 1;
  background: linear-gradient(180deg, #1f2430 0%, #181c25 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.pad-cell:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.22);
}

.pad-cell.selected {
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 18px 35px rgba(0, 0, 0, 0.26);
}

/* Row colors when pad has sample */
.pad-cell[data-row="0"].has-sample {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0.1) 100%);
  border-color: rgba(59, 130, 246, 0.4);
}
.pad-cell[data-row="1"].has-sample {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.25) 0%, rgba(139, 92, 246, 0.1) 100%);
  border-color: rgba(139, 92, 246, 0.4);
}
.pad-cell[data-row="2"].has-sample {
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.25) 0%, rgba(249, 115, 22, 0.1) 100%);
  border-color: rgba(249, 115, 22, 0.4);
}
.pad-cell[data-row="3"].has-sample {
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.25) 0%, rgba(20, 184, 166, 0.1) 100%);
  border-color: rgba(20, 184, 166, 0.4);
}

.pad-cell.empty {
  opacity: 0.7;
}

.pad-name {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.pad-icon {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.6;
}

.pad-cell.has-sample .pad-icon {
  color: var(--success);
  opacity: 1;
}

/* Drag states */
.pad-cell.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.pad-cell.drag-over {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 2px var(--success-soft), 0 16px 30px rgba(0, 0, 0, 0.22);
}

/* Flash animation on play */
.pad-cell.flashing {
  animation: padFlash 0.12s ease-out;
}

@keyframes padFlash {
  0% { filter: brightness(1.5); transform: scale(1.03); }
  100% { filter: brightness(1); transform: scale(1); }
}

/* ===== Editor Panel ===== */
.editor {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.editor-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  gap: 12px;
}

.editor-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.editor-placeholder p {
  margin: 0;
  font-size: 0.95rem;
}

.editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.pad-indicator {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: 9999px;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-section label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

/* ===== Sample Display ===== */
.sample-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(10, 13, 19, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.sample-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sample-icon.no-sample {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.sample-icon.has-sample {
  background: var(--success-soft);
  color: var(--success);
}

.sample-name {
  flex: 1;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-name.no-sample {
  color: var(--muted);
  font-style: italic;
}

/* ===== Form Elements ===== */
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(10, 13, 19, 0.92);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

select {
  cursor: pointer;
}

/* ===== Segment Control (Choke Groups) ===== */
.segment-control {
  display: flex;
  gap: 4px;
  background: rgba(10, 13, 19, 0.6);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.segment {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segment:hover {
  color: var(--text);
}

.segment.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

/* ===== Volume Slider ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  border: none;
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.volume-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 0.95rem;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: toastIn 0.2s ease-out;
}

.toast.success {
  border-color: rgba(103, 232, 165, 0.3);
  background: linear-gradient(135deg, rgba(103, 232, 165, 0.1), transparent);
}

.toast.error {
  border-color: rgba(255, 138, 138, 0.3);
  background: linear-gradient(135deg, rgba(255, 138, 138, 0.1), transparent);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== EQ Grid ===== */
.eq-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(10, 13, 19, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.eq-band {
  display: grid;
  grid-template-columns: 80px 1fr 60px;
  align-items: center;
  gap: 10px;
}

.eq-band-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.eq-freq {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}

.eq-value {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== Velocity Layers ===== */
.layers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layers-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  background: rgba(10, 13, 19, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.layer-velocity {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.layer-vel-input {
  width: 46px !important;
  padding: 5px 4px !important;
  font-size: 0.8rem !important;
  border-radius: 7px !important;
  text-align: center;
}

.layer-vel-sep {
  color: var(--muted);
  font-size: 0.85rem;
}

.layer-sample-name {
  flex: 1;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-sample-name.no-sample {
  color: var(--muted);
  font-style: italic;
}

/* ===== Responsive ===== */
@media (max-width: 1050px) {
  .main {
    grid-template-columns: 1fr;
  }

  .editor {
    order: -1;
  }
}

@media (max-width: 700px) {
  .app {
    padding: 16px;
  }

  .grid {
    gap: 10px;
  }

  .pad-cell {
    border-radius: 16px;
    padding: 10px;
  }

  .pad-name {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .top-bar-right {
    justify-content: flex-end;
  }
}
