/* Unified Design System - OpenSlots Style */
:root {
  --primary-dark: rgb(81, 78, 145);
  --primary: rgb(91, 88, 165);
  --primary-light: rgb(101, 98, 185);
  --accent: rgb(91, 88, 165);
  --success: #00bcd4;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f0f2f5;
  --border-color: #e0e4e8;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --shadow-sm: 0 2px 4px rgba(91, 88, 165, 0.08);
  --shadow-md: 0 4px 12px rgba(91, 88, 165, 0.12);
  --radius-md: 8px;
  --radius-lg: 12px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #ffffff;
  color: var(--text-primary);
  padding: var(--space-lg);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

h1 {
  color: var(--primary-dark);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 0;
  padding: 0;
  letter-spacing: -0.02em;
}

h2 {
  color: var(--primary);
  font-size: 20px;
  font-weight: 600;
  margin: var(--space-lg) 0 var(--space-md) 0;
}

button {
  padding: 10px 24px;
  background: rgb(91, 88, 165);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(91, 88, 165, 0.15);
  font-family: inherit;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(91, 88, 165, 0.2);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Red color only for delete buttons */
button.delete,
form[action*="delete"] button[type="submit"] {
  background: #CD5881;
}

button.delete:hover,
form[action*="delete"] button[type="submit"]:hover {
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

input[type="text"],
input[type="number"],
textarea,
select {
  padding: 10px 14px;
  border: 2px solid #e0e4e8;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  transition: all 0.2s;
  background: white;
  color: #212529;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgb(91, 88, 165);
  box-shadow: 0 0 0 3px rgba(91, 88, 165, 0.1);
}

input[type="text"]:hover,
input[type="number"]:hover,
textarea:hover,
select:hover {
  border-color: #c0c4c8;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin-top: 20px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(91, 88, 165, 0.12);
  border: 1px solid #eef1f4;
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid #eef1f4;
  vertical-align: middle;
}

td form {
  margin: 0;
  display: inline;
}

th {
  background: #f5f7fb;
  color: #1f2230;
  font-weight: 600;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}

tbody tr {
  transition: background-color 0.15s;
}

tbody tr:hover {
  background: #f8f9fa;
}

/* Sets table with borders */
.sets-table {
  border-collapse: collapse;
  width: 100%;
}

.sets-table th,
.sets-table td {
  border: 1px solid #e6e8ef;
  padding: 10px 12px;
}

tr:last-child td {
  border-bottom: none;
}

/* Action columns - minimal width, right aligned */
td:nth-child(2),
td:nth-child(3),
th:nth-child(2),
th:nth-child(3) {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* First column takes remaining space */
td:nth-child(1),
th:nth-child(1) {
  width: auto;
}

.details {
  background: var(--bg-secondary);
}

.details td {
  padding: var(--space-lg);
}

.details textarea {
  min-height: 100px;
  margin-bottom: var(--space-md);
}

.details input[type="number"] {
  width: auto;
  min-width: 120px;
}

.details input[type="checkbox"] {
  width: auto;
  margin: 0 var(--space-sm) 0 0;
}

.details button {
  margin-right: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.details form {
  display: inline-block;
  padding: 0;
  margin: 0;
  background: none;
  box-shadow: none;
  border: none;
}

audio {
  width: 100%;
  min-width: 250px;
  height: 40px;
}

details {
  background: var(--bg-primary);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  margin: var(--space-lg) 0;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  padding: var(--space-sm);
  margin: calc(var(--space-lg) * -1);
  border-radius: var(--radius-lg);
  transition: background-color 0.15s;
}

summary:hover {
  background: var(--bg-tertiary);
}

details[open] summary {
  margin-bottom: var(--space-lg);
  border-bottom: 2px solid var(--border-color);
}

/* Library Modal Styles */
.library-modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: 95%;
  max-width: 1100px;
  height: 85vh;
  max-height: 700px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.library-modal-header {
  padding: 12px 16px;
  background: #f5f7fb;
  color: #1f2230;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid #e6e8ef;
}

.library-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: normal;
}

.library-modal-header .editor-modal-close {
  background: #fff;
  border: 1px solid #e6e8ef;
  color: #374151;
}

.library-tag-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  margin: 0 20px;
}

.library-tag-search label {
  font-size: 14px;
  white-space: nowrap;
}

.library-tag-search input {
  flex: 1;
  max-width: 300px;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
}

.library-modal-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Panel - Categories */
.library-categories {
  width: 220px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.library-categories-header {
  padding: var(--space-md);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.library-add-category-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: #5a4bd6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  box-shadow: none;
}

.library-add-category-btn:hover {
  background: #4a3cc0;
  transform: none;
}

.library-categories-header-btns {
  display: flex;
  gap: 4px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.library-categories-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.library-category-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.library-category-item:hover {
  background: #f0ede5;
}

.library-category-item.active {
  background: #5a4bd6;
  color: white;
}

.library-category-item.active .library-category-count {
  background: rgba(255,255,255,0.2);
  color: white;
}

.library-category-item.active .library-category-add {
  color: white;
  border-color: rgba(255,255,255,0.3);
}

.library-category-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.library-category-count {
  font-size: 12px;
  color: var(--text-muted);
  background: #e8e5dd;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 8px;
}

.library-category-add {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
  transition: all 0.15s;
}

.library-category-add:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: none;
}

.library-category-edit {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
  transition: all 0.15s;
  margin-left: 4px;
}

.library-category-edit:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: none;
}

.library-category-edit svg {
  width: 12px;
  height: 12px;
}

/* Right Panel - Sounds */
.library-sounds {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  background: #f5f3ee;
}

.library-sounds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.library-sounds-title {
  font-size: 14px;
  color: var(--text-secondary);
}

.library-sounds-title strong {
  color: var(--text-primary);
}

.library-add-sound-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: #5a4bd6;
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.library-add-sound-btn:hover {
  background: #4a3dc6;
}

.library-edit-category-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

.library-edit-category-btn:hover {
  background: #5a4bd6;
  color: white;
}

.library-edit-category-btn svg {
  width: 14px;
  height: 14px;
}

.library-sounds-header-actions {
  display: flex;
  align-items: center;
}

.library-sound-footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border-color);
}

.library-add-clip-btn {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 5px;
  background: white;
  color: #5a4bd6;
  border: 1px solid #5a4bd6;
  cursor: pointer;
  transition: all 0.15s;
}

.library-add-clip-btn:hover {
  background: rgba(90, 75, 214, 0.08);
}

/* Sound Card */
.library-sound-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(91, 88, 165, 0.06);
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.library-sound-header {
  padding: 12px 16px;
  background: #fafaf8;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-sound-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.library-sound-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 50px;
  background: rgba(91, 88, 165, 0.1);
  color: var(--primary);
  font-weight: 500;
}

.library-sound-edit-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  opacity: 0.6;
  transition: all 0.15s;
}

.library-sound-edit-btn:hover {
  background: var(--primary);
  color: white;
  opacity: 1;
}

.library-sound-edit-btn svg {
  width: 14px;
  height: 14px;
}

.library-sound-variants {
  padding: 8px;
}

/* Variant Row */
.library-variant-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
  overflow: hidden;
}

.library-variant-row:hover {
  background: #fafaf8;
}

.library-variant-info {
  min-width: 0;
}

.library-variant-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-variant-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.library-variant-tag {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 3px;
}

.library-variant-tag.library-tag-match {
  background: var(--primary);
  color: white;
}

/* Waveform */
.library-waveform {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.library-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #5a4bd6;
  background: white;
  color: #5a4bd6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
  flex-shrink: 0;
  transition: all 0.15s;
}

.library-play-btn:hover {
  background: #5a4bd6;
  color: white;
  transform: none;
}

.library-play-btn.playing {
  background: #5a4bd6;
  color: white;
}

.library-play-btn svg {
  width: 12px;
  height: 12px;
}

.library-waveform-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  flex: 1;
}

.library-waveform-bar {
  width: 3px;
  background: #d5d1c8;
  border-radius: 2px;
  transition: background 0.15s;
}

.library-waveform-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  min-width: 35px;
}

/* Variant Actions */
.library-variant-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-edit-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
  transition: all 0.15s;
}

.library-edit-btn:hover {
  background: #dbeafe;
  color: #2563eb;
  border-color: #bfdbfe;
  transform: none;
}

.library-edit-btn svg {
  width: 14px;
  height: 14px;
}

.library-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
  transition: all 0.15s;
}

.library-delete-btn:hover {
  background: #fee2e2;
  color: #dc3545;
  border-color: #fecaca;
  transform: none;
}

.library-delete-btn svg {
  width: 14px;
  height: 14px;
}

.library-apply-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 50px;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: none;
}

.library-apply-btn:hover {
  background: var(--primary-dark);
  transform: none;
}

.library-apply-btn svg {
  width: 12px;
  height: 12px;
}

/* Modal Footer */
.library-modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  background: white;
  flex-shrink: 0;
}

.library-modal-footer button {
  background: #5a4bd6;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  border: none;
  box-shadow: none;
}

.library-modal-footer button:hover {
  background: #4a3cc0;
  transform: none;
}

.library-modal-footer button[style*="text-secondary"] {
  background: #6b7280 !important;
}

.library-modal-footer button[style*="text-secondary"]:hover {
  background: #4b5563 !important;
}

/* Add Sound Modal */
.add-sound-modal {
  background: white;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
}

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

.add-sound-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #2d2a33;
}

.add-sound-header .category-name {
  color: #5a4bd6;
  text-transform: capitalize;
}

.add-sound-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #6b6777;
  display: flex;
  box-shadow: none;
}

.add-sound-close:hover {
  color: #2d2a33;
  transform: none;
}

/* Mode Toggle */
.add-sound-toggle {
  display: flex;
  background: #f5f3ee;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.add-sound-toggle button {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  color: #6b6777;
  box-shadow: none;
}

.add-sound-toggle button:hover {
  transform: none;
}

.add-sound-toggle button.active {
  background: white;
  color: #5a4bd6;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.add-sound-toggle button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form Fields */
.add-sound-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.add-sound-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #2d2a33;
  margin-bottom: 6px;
}

.add-sound-field input[type="text"],
.add-sound-field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e2db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  background: white;
}

.add-sound-field input[type="text"]:focus,
.add-sound-field select:focus {
  border-color: #5a4bd6;
}

/* File Upload */
.file-upload-btn {
  width: 100%;
  padding: 16px;
  border: 2px dashed #d5d1c8;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  box-shadow: none;
}

.file-upload-btn:hover {
  border-color: var(--primary);
  background: #fafaf8;
  transform: none;
}

.file-upload-btn.has-file {
  background: #f5f3ee;
  border-style: solid;
}

.file-upload-info {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.file-upload-info .file-details {
  flex: 1;
  min-width: 0;
}

.file-upload-info .file-name {
  font-size: 13px;
  font-weight: 500;
  color: #2d2a33;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-info .file-duration {
  font-size: 11px;
  color: #6b6777;
}

.file-upload-placeholder {
  color: #6b6777;
  font-size: 13px;
}

.file-upload-placeholder svg {
  display: block;
  margin: 0 auto 8px;
}

/* Tags Input */
.tags-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border: 2px solid #e5e2db;
  border-radius: 8px;
  background: white;
  min-height: 42px;
  align-items: center;
}

.tags-input-wrapper:focus-within {
  border-color: var(--primary);
}

.tag-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--primary);
  background: rgba(91, 88, 165, 0.1);
  padding: 4px 8px;
  border-radius: 50px;
}

.tag-pill button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  color: var(--primary);
  opacity: 0.6;
  box-shadow: none;
}

.tag-pill button:hover {
  opacity: 1;
  transform: none;
}

.tags-input {
  flex: 1;
  min-width: 80px;
  border: none;
  outline: none;
  font-size: 13px;
  background: transparent;
}

/* Actions */
.add-sound-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.add-sound-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}

.add-sound-actions .btn-cancel {
  border: 2px solid #e5e2db;
  background: white;
  color: #6b6777;
}

.add-sound-actions .btn-cancel:hover {
  background: #f5f3ee;
  transform: none;
}

.add-sound-actions .btn-submit {
  border: none;
  background: #5a4bd6;
  color: white;
}

.add-sound-actions .btn-submit:hover {
  background: #4a3cc0;
  transform: none;
}

.add-sound-actions .btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Log viewer modal styles */
.log-viewer-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.log-viewer-modal-overlay.active {
  display: flex;
}

.log-viewer-modal {
  background: #1e1e1e;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 1000px;
  height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.log-viewer-header {
  padding: var(--space-md) var(--space-lg);
  background: var(--primary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-viewer-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.log-viewer-status {
  font-size: 12px;
  opacity: 0.8;
}

.log-viewer-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: none;
}

.log-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: none;
}

.log-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #1e1e1e;
  color: #d4d4d4;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 2px 0;
}

.log-line-error {
  color: #f48771;
}

.log-line-success {
  color: #89d185;
}

.log-line-timestamp {
  color: #6a9955;
}

.log-viewer-footer {
  padding: var(--space-sm) var(--space-lg);
  background: #252526;
  border-top: 1px solid #3c3c3c;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-viewer-footer label {
  color: #d4d4d4;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.log-viewer-footer button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

.log-viewer-footer button:hover {
  background: var(--primary-dark);
}

/* ============================================
   Page Title with Actions
   ============================================ */

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 6px 0 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.page-title span {
  color: #1f2230;
}

.title-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.title-btn {
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: background 0.15s ease, transform 0.1s ease;
  cursor: pointer;
  font-family: inherit;
}

.title-btn:hover {
  transform: translateY(-1px);
}

.title-btn.primary {
  background: #5a4bd6;
  color: #fff;
}

.title-btn.primary:hover {
  background: #4a3cc0;
}

.title-btn.outline {
  background: #fff;
  color: #5a4bd6;
  border-color: #c7c0f0;
}

.title-btn.outline:hover {
  background: #f3f1fd;
}

.title-btn.success {
  background: #22c55e;
  color: #fff;
}

.title-btn.success:hover {
  background: #16a34a;
}

.secondary-btn {
  background: #5a4bd6;
  color: white;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s ease;
  border: none;
  cursor: pointer;
}

.secondary-btn:hover {
  background: #4a3cc0;
  transform: none;
}

.test-game-select {
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 12px;
  background: #fff;
  color: var(--text-primary);
}

.settings-panel {
  margin: 16px 0;
}

.settings-panel details {
  background: #fff;
  border: 1px solid #e6e8ef;
  border-radius: 10px;
  padding: 0;
  box-shadow: none;
  margin: 0;
}

.settings-panel summary {
  padding: 12px 16px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1f2230;
  cursor: pointer;
  border-radius: 10px;
  border-bottom: none;
}

.settings-panel details[open] summary {
  border-bottom: 1px solid #e6e8ef;
  border-radius: 10px 10px 0 0;
  margin-bottom: 0;
}

.settings-panel .add-sound-form,
.settings-panel .settings-form {
  padding: 16px;
}

.settings-panel .form-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-panel .form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-panel .form-row .label-text {
  font-size: 12px;
  font-weight: 500;
  color: #374151;
}

.settings-panel .form-row input[type="text"],
.settings-panel .form-row input[type="number"] {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  min-width: 180px;
}

.title-actions .file-input-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #5a4bd6;
  border: 1px solid #c7c0f0;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  position: relative;
}

.title-actions .file-input-wrapper:hover {
  background: #f3f1fd;
  transform: translateY(-1px);
}

.title-actions .file-input-wrapper input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ============================================
   Sounds Grid Styles
   ============================================ */

.sounds-manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 0 0;
}

.sounds-manage-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sound-search {
  position: relative;
  display: flex;
  align-items: center;
}

.sound-search input {
  width: 280px;
  padding: 9px 14px 9px 34px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  font-size: 13px;
  background: #fff;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sound-search input:focus {
  outline: none;
  border-color: #5a4bd6;
  box-shadow: 0 0 0 3px rgba(90, 75, 214, 0.15);
}

.sound-search .search-ico {
  position: absolute;
  left: 12px;
  color: #9ca3af;
  font-size: 13px;
  pointer-events: none;
}

.sound-search .clear-btn {
  position: absolute;
  right: 8px;
  background: #eef0f6;
  border: none;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #6b7280;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
}

.sound-search .clear-btn:hover {
  background: #ddd;
  transform: none;
}

.sound-search .clear-btn.visible {
  display: flex;
}

.sounds-empty {
  grid-column: 1 / -1;
  padding: 30px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

.sounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
}

.sound-card {
  border: 1px solid #e6e8ef;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sound-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(30, 30, 80, 0.08);
  border-color: #c7c0f0;
}

@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 0 3px #f5c542, 0 0 18px 4px rgba(245, 197, 66, 0.55), 0 6px 22px rgba(245, 197, 66, 0.35); }
  50% { box-shadow: 0 0 0 3px #ffd75e, 0 0 26px 8px rgba(255, 215, 94, 0.75), 0 8px 28px rgba(255, 215, 94, 0.5); }
}

.sound-card.active {
  border-color: #f5c542;
  background: linear-gradient(180deg, #fff8df 0%, #fdedb0 100%);
  transform: translateY(-2px);
  animation: goldPulse 1.8s ease-in-out infinite;
}

.sound-card.active .name {
  color: #7a5a10;
  font-weight: 700;
}

.sound-card.active::before {
  content: "⭐ EDITING";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #ffd75e, #e9a712);
  color: #5a3a16;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.6px;
  padding: 3px 10px;
  border-radius: 10px;
  border: 1.5px solid #b07a18;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  z-index: 2;
}

.sound-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
    linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
    linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sound-thumb .badge-music,
.sound-thumb .badge-loop {
  position: absolute;
  top: 6px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sound-thumb .badge-music {
  left: 6px;
  background: #5a4bd6;
  color: white;
}

.sound-thumb .badge-loop {
  right: 6px;
  background: #22c55e;
  color: white;
}

.sound-thumb .waveform {
  width: 80%;
  height: 40%;
  color: #5a4bd6;
}

.sound-thumb.no-audio {
  background: #f8f9fa;
  background-image: none;
}

.sound-thumb.no-audio::after {
  content: 'No audio';
  font-size: 10px;
  color: #9ca3af;
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.sound-thumb .play-thumb-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #5a4bd6;
  font-size: 18px;
  border: 2px solid #5a4bd6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 3;
  padding: 0;
}

.sound-card:hover .play-thumb-btn,
.sound-card.active .play-thumb-btn,
.sound-thumb .play-thumb-btn.playing {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.sound-thumb .play-thumb-btn:hover {
  background: #5a4bd6;
  color: white;
}

.sound-thumb .play-thumb-btn:disabled {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--text-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

.sound-thumb .play-thumb-btn.playing {
  background: #22c55e;
  color: white;
  border-color: #16a34a;
}

.sound-card .name {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
}

.sound-card .meta {
  font-size: 10px;
  color: #9ca3af;
}

.sound-card .sound-card-status {
  font-size: 10px;
}

.sound-card .sound-card-status.generated {
  color: #22c55e;
}

.sound-card .sound-card-status.not-generated {
  color: var(--text-muted);
}

.sound-card .open-sound-btn {
  width: 100%;
  background: #5a4bd6;
  color: white;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 4px;
  transition: background 0.15s ease;
  border: none;
  cursor: pointer;
}

.sound-card .open-sound-btn:hover {
  background: #4a3cc0;
  transform: none;
}

/* ============================================
   Sound Editor Modal Styles
   ============================================ */

.editor-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.editor-modal-overlay.active {
  display: flex;
}

.editor-panel {
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: 95%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.editor-toolbar .soundset-select {
  min-width: 160px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #e6e8ef;
  background: #fff;
  font-size: 13px;
  color: var(--text-primary);
}

.editor-toolbar .test-btn {
  background: #5a4bd6;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  border: none;
  box-shadow: none;
}

.editor-toolbar .test-btn:hover {
  background: #4a3cc0;
  transform: none;
  box-shadow: none;
}

.editor-toolbar .editor-close {
  margin-left: auto;
  background: #fff;
  border: 1px solid #e6e8ef;
  color: #374151;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}

.editor-toolbar .editor-close:hover {
  background: #eef0f6;
  transform: none;
}

.editor-row-header {
  display: grid;
  grid-template-columns: 1.6fr 0.6fr 0.5fr 0.5fr 1.6fr 0.6fr 0.5fr;
  gap: 12px;
  padding: 12px 18px;
  background: #6a5acd;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #fff;
}

.editor-row-data {
  display: grid;
  grid-template-columns: 1.6fr 0.6fr 0.5fr 0.5fr 1.6fr 0.6fr 0.5fr;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  font-size: 13px;
  color: #374151;
}

.editor-row-data audio {
  width: 100%;
  height: 36px;
}

.history-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s, border-color 0.15s;
}

.history-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* Sound History Modal */
.sound-history-modal {
  background: #fff;
  border-radius: 12px;
  width: 95%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.sound-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sound-history-header h3 {
  margin: 0;
  font-size: 16px;
  color: #1f2937;
}

.sound-history-header .editor-modal-close {
  background: #fff;
  border: 1px solid #e6e8ef;
  color: #374151;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.sound-history-header .editor-modal-close:hover {
  background: #eef0f6;
}

.sound-history-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.sound-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sound-history-table th,
.sound-history-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.sound-history-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}

.sound-history-table tr:hover {
  background: #f9fafb;
}

.sound-history-table .current-tag {
  background: #10b981;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  text-transform: uppercase;
  font-weight: 600;
}

.sound-history-table audio {
  height: 32px;
  width: 120px;
}

.history-actions {
  white-space: nowrap;
}

.history-action-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 4px;
  transition: all 0.15s;
}

.history-action-btn:hover {
  background: #f3f4f6;
}

.history-action-btn.rollback {
  color: #2563eb;
  border-color: #2563eb;
}

.history-action-btn.rollback:hover {
  background: #eff6ff;
}

.history-action-btn.delete {
  color: #dc2626;
  border-color: #dc2626;
}

.history-action-btn.delete:hover {
  background: #fef2f2;
}

.editor-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.editor-left-col,
.editor-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-body .field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-body .small-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.editor-body textarea {
  min-height: 100px;
  resize: vertical;
}

.editor-body .checkbox-row {
  display: flex;
  gap: 20px;
}

.editor-body .checkbox-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.editor-body .checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.waveform-display {
  height: 90px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 12px;
}

.waveform-display svg {
  width: 100%;
  height: 100%;
}

.waveform-display.no-audio {
  background: #f8f9fa;
}

.waveform-display .no-waveform-text {
  position: absolute;
  font-size: 12px;
  color: #9ca3af;
}

.action-bar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.action-bar .action-btn {
  background: #5a4bd6;
  color: #fff;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
}

.action-bar .action-btn:hover {
  background: #4a3cc0;
  transform: none;
}

.action-bar .action-btn.danger {
  background: #e85a7a;
}

.action-bar .action-btn.danger:hover {
  background: #cf4467;
}

.action-bar .action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.upload-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.upload-row .file-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 2px dashed var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}

.upload-row .file-pill:hover {
  border-color: var(--primary);
}

.upload-row .file-pill input[type="file"] {
  display: none;
}

.upload-row .file-pill .browse {
  font-weight: 500;
  color: var(--primary);
}

.upload-row .file-pill .file-name-display {
  color: var(--text-muted);
  font-size: 13px;
}

.upload-row .action-btn {
  background: #5a4bd6;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  border: none;
  box-shadow: none;
  cursor: pointer;
}

.upload-row .action-btn:hover {
  background: #4a3cc0;
  transform: none;
  box-shadow: none;
}

/* ============ SLOT EMBED AREA ============ */
.slot-embed-area {
  border: 2px dashed #c7c0f0;
  border-radius: 12px;
  background: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.slot-stage {
  width: 100%;
  max-width: 1024px;
  aspect-ratio: 825/720;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, #9fd8ff 0%, #cfe8f5 55%, #e0d4b0 100%);
  position: relative;
  border: 1px solid #d1d5db;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  margin: 0 auto;
}

.slot-stage iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.slot-expand-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-stage:hover .slot-expand-btn {
  opacity: 1;
}

.slot-expand-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.slot-controls {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  text-align: center;
}

.slot-controls .slot-row {
  justify-content: center;
}

.slot-controls h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.slot-controls .desc {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 6px;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.play-btn {
  background: #5a4bd6;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
}

.play-btn:hover {
  background: #4a3cc0;
  box-shadow: none;
  transform: none;
}

.reload-btn {
  background: #fff;
  color: #374151;
  border: 1px solid #e6e8ef;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: none;
}

.reload-btn:hover {
  background: #f5f7fb;
  box-shadow: none;
  transform: none;
}

.embed-hint {
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

@media (max-width: 1080px) {
  .slot-embed-area {
    flex-direction: column;
  }
  .slot-stage {
    flex: 0 0 auto;
    width: 100%;
  }
}

/* =====================================================
   Floating Chat Window
   ===================================================== */
.chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 35vw;
  min-width: 350px;
  max-width: 500px;
  height: 33vh;
  min-height: 300px;
  max-height: 500px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(91, 88, 165, 0.2), 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.chat-window.chat-minimized {
  height: 48px;
  min-height: 48px;
}

.chat-window.chat-minimized .chat-body {
  opacity: 0;
  visibility: hidden;
}

.chat-window.chat-minimized .chat-icon-expand {
  display: block;
}

.chat-window.chat-minimized .chat-icon-collapse {
  display: none;
}

.chat-window:not(.chat-minimized) .chat-icon-expand {
  display: none;
}

.chat-window:not(.chat-minimized) .chat-icon-collapse {
  display: block;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #5a4bd6;
  color: white;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.chat-header:hover {
  background: #4a3cc0;
}

.chat-title {
  font-weight: 600;
  font-size: 14px;
}

.chat-toggle-btn {
  background: transparent;
  border: none;
  color: white;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
  border-radius: 4px;
}

.chat-toggle-btn:hover {
  background: rgba(255,255,255,0.15);
  box-shadow: none;
  transform: none;
}

.chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s, visibility 0.2s;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-message.user .chat-bubble {
  background: #5a4bd6;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-typing {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 16px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chat-attachments {
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.chat-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  max-width: 150px;
}

.chat-attachment-item .filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-attachment-item .remove-btn {
  background: none;
  border: none;
  padding: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: none;
}

.chat-attachment-item .remove-btn:hover {
  background: rgba(0,0,0,0.1);
  color: var(--text-primary);
  transform: none;
  box-shadow: none;
}

.chat-attachment-item.uploading {
  opacity: 0.6;
}

.chat-attachment-item.error {
  border-color: #dc3545;
  background: #fff5f5;
}

.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.chat-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-attach-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
  transform: none;
  box-shadow: none;
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 100px;
  min-height: 40px;
}

.chat-input-area textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(91, 88, 165, 0.1);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #5a4bd6;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-send-btn:hover {
  background: #4a3cc0;
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-menu-container {
  position: relative;
}

.chat-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-menu-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
}

.chat-menu.active {
  display: block;
}

.chat-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.chat-menu-item:hover {
  background: var(--bg-tertiary);
}

/* Responsive adjustments for chat */
@media (max-width: 768px) {
  .chat-window {
    width: 90vw;
    max-width: none;
    right: 5vw;
    bottom: 10px;
  }
}

/* =====================================================
   Generation Status Bar
   ===================================================== */

.generation-status-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

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

.generation-status-bar.running {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  border: 1px solid #a5b4fc;
  color: #3730a3;
}

.generation-status-bar.success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 1px solid #6ee7b7;
  color: #065f46;
}

.generation-status-bar.error {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.gen-status-icon {
  font-size: 18px;
}

.gen-status-text {
  flex: 1;
  font-weight: 500;
}

.gen-status-progress {
  width: 120px;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.gen-progress-bar {
  height: 100%;
  background: #6366f1;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.gen-status-details,
.gen-status-refresh,
.gen-status-close {
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: inherit;
  transition: background 0.15s;
}

.gen-status-details:hover,
.gen-status-refresh:hover,
.gen-status-close:hover {
  background: rgba(0, 0, 0, 0.2);
}

.gen-status-close {
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
}
