/* CifraPlayer Manager — Modern Dark Theme */

/* ==================== RESET & BASE ==================== */
:root {
  --bg-primary: #0a0d12;
  --bg-secondary: #0f1419;
  --bg-tertiary: #151b24;
  --bg-hover: #1a222d;
  --bg-active: #1f2937;

  --border: #1e2a3a;
  --border-light: #2a3a4d;

  --text-primary: #e6edf5;
  --text-secondary: #9baab8;
  --text-muted: #6b7c8d;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.3);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --gradient-card: linear-gradient(145deg, var(--bg-tertiary), var(--bg-secondary));

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --header-height: 64px;
  --sidebar-width: 260px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ==================== HEADER ==================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, #9ba8b5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--accent);
  color: white;
}

/* App Download Button */
.app-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
  transition: all 0.3s;
  overflow: hidden;
}

.app-download-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.6);
}

.app-download-btn img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.header-center {
  flex: 1;
  max-width: 500px;
  margin: 0 24px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 10px 40px 10px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

#clearSearch {
  position: absolute;
  right: 8px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-accent {
  background: var(--success);
  color: white;
}

.btn-accent:hover {
  background: #16a34a;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon.active {
  background: var(--accent);
  color: white;
}

.btn-icon-left {
  font-size: 14px;
}

/* ==================== LAYOUT ==================== */
.layout {
  display: flex;
  height: calc(100vh - var(--header-height));
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.categories-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.category-item:hover {
  background: var(--bg-hover);
}

.category-item.active {
  background: var(--accent);
  color: white;
}

.category-item .name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.category-item .name::before {
  content: '📁';
  font-size: 14px;
}

.category-item .count {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.category-item.active .count {
  background: rgba(255, 255, 255, 0.2);
}

.category-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  margin-left: auto;
  transition: opacity 0.2s;
}

.category-item:hover .category-actions {
  opacity: 1;
}

.category-actions .btn-icon {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.category-actions .btn-rename-category:hover {
  background: var(--accent);
  color: white;
}

.category-actions .btn-delete-category:hover {
  background: var(--danger);
  color: white;
}

/* Editor filename editable */
.editor-filename-editable {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.editor-filename-editable:hover {
  background: var(--bg-hover);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb .sep {
  color: var(--text-muted);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.file-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.view-options {
  display: flex;
  gap: 4px;
}

/* ==================== UPLOAD ZONE ==================== */
.upload-zone {
  position: relative;
  margin-bottom: 20px;
  padding: 40px;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  text-align: center;
  transition: all 0.3s;
}

.upload-zone.hidden {
  display: none;
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--bg-hover);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.upload-zone-content {
  pointer-events: none;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-zone p {
  margin: 4px 0;
  color: var(--text-secondary);
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-zone .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* ==================== FILES GRID ==================== */
.files-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  overflow-y: auto;
  padding-right: 8px;
  align-content: start;
}

.files-grid.list-view {
  grid-template-columns: 1fr;
  gap: 8px;
}

.file-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
}

.file-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.file-card .file-icon {
  font-size: 28px;
  margin-bottom: 12px;
}

.file-card .file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}

.file-card .file-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.file-card .file-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.file-card .file-actions .btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  justify-content: center;
}

/* List View */
.list-view .file-card {
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
}

.list-view .file-card .file-icon {
  font-size: 20px;
  margin: 0 16px 0 0;
}

.list-view .file-card .file-name {
  flex: 1;
  margin: 0;
}

.list-view .file-card .file-meta {
  margin: 0 16px;
  min-width: 120px;
  text-align: right;
}

.list-view .file-card .file-actions {
  margin: 0;
  flex: none;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state::before {
  content: '📂';
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* ==================== MODALS ==================== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.small-modal {
  width: 400px;
}

.editor-modal {
  width: 90vw;
  height: 85vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title span:first-child {
  font-size: 16px;
  font-weight: 600;
}

.editor-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.editor-status.saved {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.editor-status.modified {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.input-full {
  width: 100%;
  padding: 10px 14px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.input-full:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select.input-full {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239baab8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  padding-right: 36px;
}

.warning-text {
  margin-top: 8px;
  font-size: 12px;
  color: var(--danger);
}

/* ==================== EDITOR ==================== */
.editor-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-light);
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tool:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-tool.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-detect-chords {
  background: linear-gradient(135deg, var(--success), #16a34a);
  color: white;
  border-color: var(--success);
}

.btn-detect-chords:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
  color: white;
}

.btn-learn {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  border-color: #8b5cf6;
  font-size: 14px;
}

.btn-learn:hover {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
  color: white;
}

.font-size-display {
  min-width: 28px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.toggle-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.color-group {
  gap: 8px;
}

.color-label {
  font-size: 11px;
  color: var(--text-muted);
}

input[type="color"] {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
  border-radius: 3px;
  border: none;
}

.editor-info {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Editor Split View */
.editor-split {
  flex: 1;
  display: flex;
  gap: 0;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  display: flex;
  min-width: 0;
}

.editor-pane.hidden {
  display: none;
}

#editorTextarea {
  flex: 1;
  width: 100%;
  padding: 16px;
  border: none;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.7;
  resize: none;
  outline: none;
}

#editorTextarea:focus {
  outline: none;
}

/* Preview Pane */
.preview-pane {
  flex: 1;
  border-left: 1px solid var(--border);
  background: var(--bg-primary);
  overflow-y: auto;
}

.preview-pane.hidden {
  display: none;
}

.preview-content {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Chord Boxes in Preview */
.chord-box {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 2px;
  background: var(--chord-box-bg, rgba(34, 197, 94, 0.2));
  border: 1px solid var(--chord-box-border, rgba(34, 197, 94, 0.4));
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9em;
  color: var(--chord-color, #22c55e);
  vertical-align: baseline;
  transition: all 0.2s;
}

.chord-box:hover {
  filter: brightness(1.2);
  transform: scale(1.05);
}

.lyrics-text {
  color: var(--lyrics-color, var(--text-primary));
}

.metadata-line {
  color: var(--text-muted);
  font-size: 0.85em;
}

.separator-line {
  color: var(--border-light);
  margin: 8px 0;
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--accent);
}

/* ==================== LOADING ==================== */
.loading-skeleton {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 200;
    height: calc(100vh - var(--header-height));
    transition: left 0.3s;
  }

  .sidebar.open {
    left: 0;
  }

  .header-center {
    display: none;
  }

  .files-grid {
    grid-template-columns: 1fr;
  }

  .editor-modal {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}