/**
 * Bhajan Soundboard Styles
 * Main stylesheet for the sample-based bhajan soundboard application
 */

/* ============================================
   BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #1a0a00 0%, #2d1810 100%);
  min-height: 100vh;
  color: #fff8e7;
  padding: 20px;
  padding-bottom: 100px;
}

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

/* ============================================
   HEADER
   ============================================ */
header {
  text-align: center;
  padding: 20px 0 30px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  margin-bottom: 25px;
}

h1 {
  font-size: 1.8rem;
  color: #ffd700;
  margin-bottom: 5px;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.6;
}

/* ============================================
   LOADING INDICATOR
   ============================================ */
.loading {
  text-align: center;
  padding: 40px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  margin-bottom: 20px;
}

.loading.hidden {
  display: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 215, 0, 0.3);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

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

/* ============================================
   BHAJAN SELECTOR
   ============================================ */
.bhajan-selector {
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
}

.bhajan-label {
  display: block;
  font-size: 0.8rem;
  opacity: 0.7;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.bhajan-dropdown {
  width: 100%;
  padding: 12px;
  background: rgba(128, 0, 32, 0.4);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  color: #fff8e7;
  font-size: 1rem;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffd700' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  padding-right: 40px;
}

.bhajan-dropdown:focus {
  outline: none;
  border-color: #ffd700;
}

.bhajan-dropdown option {
  background: #2d1810;
  color: #fff8e7;
}

/* ============================================
   TEMPO CONTROL
   ============================================ */
.tempo-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 20px;
}

.tempo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.tempo-label {
  font-size: 0.8rem;
  opacity: 0.7;
  text-transform: uppercase;
}

.tempo-value {
  font-size: 1.3rem;
  color: #ffd700;
  font-weight: bold;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: linear-gradient(to right, #800020, #ff6b00);
  border-radius: 4px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: #ffd700;
  border-radius: 50%;
  cursor: pointer;
}

/* ============================================
   BEAT DISPLAY
   ============================================ */
.beats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

.beat {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.15);
  border: 2px solid rgba(255, 215, 0, 0.3);
  transition: all 0.1s;
}

.beat.sam {
  width: 26px;
  height: 26px;
}

.beat.on {
  background: #ffd700;
  box-shadow: 0 0 15px #ffd700;
}

/* ============================================
   CONTROL BUTTONS
   ============================================ */
.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 25px;
}

.btn {
  flex: 1;
  padding: 15px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid;
  text-transform: uppercase;
}

.btn-start {
  background: linear-gradient(135deg, #2d5a27, #1a3a15);
  border-color: #4a9c3f;
  color: #90ee90;
}

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

.btn-stop {
  background: linear-gradient(135deg, #8b0000, #5a0000);
  border-color: #dc143c;
  color: #ff6b6b;
}

/* ============================================
   INSTRUMENTS
   ============================================ */
.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.5;
  text-align: center;
  margin-bottom: 15px;
}

.instruments {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instrument {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(128, 0, 32, 0.3);
  border: 2px solid rgba(255, 215, 0, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.instrument.active {
  background: rgba(255, 107, 0, 0.25);
  border-color: #ffd700;
}

.instrument.error {
  opacity: 0.4;
  cursor: not-allowed;
}

.instrument:active:not(.error) {
  transform: scale(0.98);
}

.inst-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  margin-top: 4px;
}

.instrument.active .inst-icon {
  animation: pulse 0.5s ease infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.1);
  }
}

.inst-info {
  flex: 1;
}

.inst-name {
  font-size: 1rem;
  margin-bottom: 2px;
}

.inst-eng {
  font-size: 0.7rem;
  opacity: 0.5;
  text-transform: uppercase;
}

.inst-status {
  font-size: 0.65rem;
  color: #ff6b6b;
  margin-top: 2px;
}

/* ============================================
   BEAT PATTERN SELECTOR
   ============================================ */
.beat-pattern {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.beat-selector {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.15);
  border: 2px solid rgba(255, 215, 0, 0.3);
  cursor: pointer;
  transition: all 0.2s;
}

.beat-selector.sam {
  width: 22px;
  height: 22px;
}

.beat-selector.selected {
  background: #ffd700;
  border-color: #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

/* ============================================
   VOLUME CONTROLS
   ============================================ */
.vol-btns {
  display: flex;
  gap: 4px;
}

.vol-btn {
  padding: 6px 10px;
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 4px;
  color: rgba(255, 248, 231, 0.5);
  cursor: pointer;
  text-transform: uppercase;
}

.vol-btn.active {
  background: rgba(255, 215, 0, 0.2);
  border-color: #ffd700;
  color: #ffd700;
}

/* ============================================
   FADE BUTTON
   ============================================ */
.fade-btn {
  padding: 4px 8px;
  font-size: 0.6rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 4px;
  color: rgba(255, 248, 231, 0.5);
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.fade-btn:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: rgba(255, 215, 0, 0.4);
}

.fade-btn.active {
  background: rgba(255, 215, 0, 0.3);
  border-color: #ffd700;
  color: #ffd700;
}

/* ============================================
   DEBUG PANEL
   ============================================ */
.debug-panel {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #ffd700;
  border-radius: 8px;
  padding: 15px;
  max-width: 300px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1000;
  font-size: 0.75rem;
}

.debug-panel.hidden {
  display: none;
}

.debug-close {
  float: right;
  cursor: pointer;
  color: #ffd700;
  font-weight: bold;
}

.debug-beat {
  margin: 8px 0;
  padding: 8px;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 4px;
}

.debug-beat-title {
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 4px;
}

/* ============================================
   MASTER VOLUME
   ============================================ */
.master-vol {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 25px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.master-vol span:first-child {
  font-size: 1.2rem;
}

.master-vol input {
  flex: 1;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  text-align: center;
  margin-top: 30px;
  font-size: 0.75rem;
  opacity: 0.4;
}

/* ============================================
   ERROR MESSAGE
   ============================================ */
.error-box {
  background: rgba(220, 20, 60, 0.2);
  border: 1px solid rgba(220, 20, 60, 0.5);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  font-size: 0.85rem;
}

.error-box.hidden {
  display: none;
}

/* ============================================
   MOBILE OPTIMIZATION (iPhone 13: 390x844)
   ============================================ */
@media (max-width: 768px) {
  body {
    padding: 15px;
    padding-bottom: 80px;
  }

  .container {
    max-width: 100%;
  }

  header {
    padding: 15px 0 20px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .subtitle {
    font-size: 0.75rem;
  }

  /* Larger touch targets */
  .btn {
    padding: 18px;
    font-size: 1.1rem;
  }

  .instrument {
    padding: 14px;
    gap: 14px;
  }

  .inst-icon {
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
  }

  .inst-name {
    font-size: 1.1rem;
  }

  .inst-eng {
    font-size: 0.75rem;
  }

  /* Larger beat selectors for easier tapping */
  .beat-selector {
    width: 22px;
    height: 22px;
  }

  .beat-selector.sam {
    width: 28px;
    height: 28px;
  }

  /* Larger volume buttons */
  .vol-btn {
    padding: 8px 12px;
    font-size: 0.7rem;
  }

  /* Larger tempo slider thumb */
  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    background: #ffd700;
    border-radius: 50%;
    cursor: pointer;
    border: none;
  }

  /* Beat indicators */
  .beat {
    width: 24px;
    height: 24px;
  }

  .beat.sam {
    width: 30px;
    height: 30px;
  }

  /* Dropdown */
  .bhajan-dropdown {
    font-size: 1.1rem;
    padding: 14px;
    padding-right: 45px;
  }

  /* Fade button */
  .fade-btn {
    padding: 6px 10px;
    font-size: 0.65rem;
  }
}

/* Extra optimization for smaller screens */
@media (max-width: 400px) {
  body {
    padding: 10px;
  }

  h1 {
    font-size: 1.3rem;
  }

  .instrument {
    padding: 12px;
  }

  .inst-icon {
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
  }

  .section-title {
    font-size: 0.7rem;
    margin-bottom: 12px;
  }
}

/* Prevent text selection on interactive elements */
.instrument,
.btn,
.beat-selector,
.vol-btn,
.fade-btn,
.beat {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling for better mobile experience */
html {
  scroll-behavior: smooth;
}
