/* LyricPad - Dark mode, iPad-optimized */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f0f1a;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --accent: #4f8cff;
  --accent-hover: #3a7ae8;
  --danger: #ff4757;
  --danger-hover: #e8414f;
  
  /* Section colors */
  --verse-color: #4a9eff;
  --chorus-color: #ffd93d;
  --bridge-color: #a855f7;
  --intro-color: #22c55e;
  --outro-color: #ef4444;
  --pre-chorus-color: #f97316;
  --instrumental-color: #06b6d4;
  --other-color: #6b7280;
  
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Views */
.view {
  display: none;
  flex-direction: column;
  height: 100%;
}

.view.active {
  display: flex;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  padding-top: calc(16px + var(--safe-top));
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  flex: 1;
}

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

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.icon-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 1.25rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.icon-btn:hover, .icon-btn:active {
  background: rgba(255,255,255,0.1);
}

.icon-btn.danger:hover {
  background: rgba(255,71,87,0.2);
  color: var(--danger);
}

.primary-btn {
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
}

.primary-btn:hover, .primary-btn:active {
  background: var(--accent-hover);
}

.secondary-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
}

.secondary-btn:hover {
  background: rgba(255,255,255,0.15);
}

.danger-btn {
  background: var(--danger);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
}

.danger-btn:hover {
  background: var(--danger-hover);
}

.small-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.small-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* Main Content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}

/* Song List */
.song-list {
  display: grid;
  gap: 12px;
}

.song-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.song-card:hover, .song-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.song-card h3 {
  margin: 0 0 4px 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.song-card .meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.song-card .section-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.section-pill {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  opacity: 0.8;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  color: var(--text-muted);
  gap: 16px;
}

.empty-state p {
  font-size: 1.125rem;
}

/* Song Editor */
.title-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.title-input:focus {
  outline: none;
  background: rgba(255,255,255,0.05);
}

.title-input::placeholder {
  color: var(--text-muted);
}

.editor-main {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Quick Notes Bar */
.quick-notes-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.quick-notes-bar > span {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.quick-notes-bar .small-btn {
  margin-left: auto;
}

/* Column Headers */
.editor-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.col-header {
  padding: 12px 16px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.col-header:first-child {
  border-right: 1px solid rgba(255,255,255,0.1);
}

/* Sections List */
.sections-list {
  flex: 1;
  overflow-y: auto;
}

/* Section Row (lyrics + notes side by side) */
.section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 80px;
}

.section-row:last-child {
  border-bottom: none;
}

.section-content {
  padding: 12px 16px;
  border-right: 1px solid rgba(255,255,255,0.1);
  border-left: 4px solid var(--other-color);
  cursor: pointer;
  transition: background 0.15s ease;
}

.section-content:hover {
  background: rgba(255,255,255,0.03);
}

.section-content.verse { border-left-color: var(--verse-color); }
.section-content.chorus { border-left-color: var(--chorus-color); }
.section-content.bridge { border-left-color: var(--bridge-color); }
.section-content.intro { border-left-color: var(--intro-color); }
.section-content.outro { border-left-color: var(--outro-color); }
.section-content.pre-chorus { border-left-color: var(--pre-chorus-color); }
.section-content.instrumental { border-left-color: var(--instrumental-color); }

.section-content .section-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.section-content .section-lyrics {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: pre-line;
  line-height: 1.5;
}

.section-content .edit-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.section-content:hover .edit-hint {
  opacity: 1;
}

/* Section Notes */
.section-notes {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

.section-notes textarea {
  flex: 1;
  min-height: 60px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px;
  resize: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.section-notes textarea:hover {
  background: rgba(255,255,255,0.02);
}

.section-notes textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.03);
}

.section-notes textarea::placeholder {
  color: var(--text-muted);
}

/* Quick Notes */
.quick-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-note-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 16px;
}

.quick-note-btn:hover {
  background: rgba(255,255,255,0.2);
}

.quick-note-btn.active {
  background: var(--accent);
  color: white;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  padding: 12px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

/* Type Picker */
.type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.type-btn:hover {
  background: rgba(255,255,255,0.15);
}

.type-btn.selected {
  color: var(--bg-primary);
}

.type-btn[data-type="verse"].selected { background: var(--verse-color); }
.type-btn[data-type="chorus"].selected { background: var(--chorus-color); }
.type-btn[data-type="bridge"].selected { background: var(--bridge-color); }
.type-btn[data-type="intro"].selected { background: var(--intro-color); }
.type-btn[data-type="outro"].selected { background: var(--outro-color); }
.type-btn[data-type="pre-chorus"].selected { background: var(--pre-chorus-color); }
.type-btn[data-type="instrumental"].selected { background: var(--instrumental-color); }
.type-btn[data-type="other"].selected { background: var(--other-color); }

/* Section Pills (in song cards) */
.section-pill[data-type="verse"] { background: var(--verse-color); color: var(--bg-primary); }
.section-pill[data-type="chorus"] { background: var(--chorus-color); color: var(--bg-primary); }
.section-pill[data-type="bridge"] { background: var(--bridge-color); color: white; }
.section-pill[data-type="intro"] { background: var(--intro-color); color: var(--bg-primary); }
.section-pill[data-type="outro"] { background: var(--outro-color); color: white; }
.section-pill[data-type="pre-chorus"] { background: var(--pre-chorus-color); color: var(--bg-primary); }
.section-pill[data-type="instrumental"] { background: var(--instrumental-color); color: var(--bg-primary); }
.section-pill[data-type="other"] { background: var(--other-color); color: white; }

/* IO Modal */
#io-data {
  width: 100%;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px;
  resize: vertical;
}

/* Responsive - iPad Portrait */
@media (max-width: 768px) {
  .section-row {
    grid-template-columns: 1fr;
  }
  
  .section-content {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
  
  .editor-headers {
    grid-template-columns: 1fr;
  }
  
  .col-header:last-child {
    display: none;
  }
  
  .col-header:first-child {
    border-right: none;
  }
}

/* Touch-friendly tap areas */
@media (pointer: coarse) {
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  
  .song-card {
    padding: 20px;
  }
  
  .section-item {
    padding: 16px;
  }
}
