/* ============================================
   Audio Cutter — style.css
   Dark theme, responsive, waveform & handles
   Matches actual HTML structure of audio.bd2051.ru
   ============================================ */

/* === Reset & Base === */
*,*::before,*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0a0a1a;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Container === */
.container {
  background: #16213e;
  border-radius: 16px;
  padding: 28px 32px;
  width: 100%;
  max-width: 860px;
  max-height: 98vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  transition: all 0.2s ease;
}

.container::-webkit-scrollbar {
  width: 6px;
}

.container::-webkit-scrollbar-track {
  background: transparent;
}

.container::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 3px;
}

/* === Header === */
.container h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.container h1 small {
  font-size: 0.75rem;
  font-weight: 400;
  color: #666;
  display: block;
  width: 100%;
  margin-top: 2px;
}

/* === Upload Zone === */
.upload-zone {
  position: relative;
  border: 2px dashed #0f3460;
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  margin-bottom: 14px;
  background: rgba(10,10,26,0.3);
}

.upload-zone:hover {
  border-color: #e94560;
  background: rgba(233,69,96,0.05);
}

.upload-zone.dragover {
  border-color: #4ecca3;
  background: rgba(78,204,163,0.08);
  animation: pulse-border 1s ease infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: #4ecca3; }
  50% { border-color: #2ecc71; }
}

.upload-zone .icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  display: block;
  opacity: 0.6;
}

.upload-zone .text {
  font-size: 0.95rem;
  color: #a0a0b0;
  line-height: 1.5;
}

.upload-zone .text strong {
  color: #e94560;
}

.upload-zone .filename {
  font-size: 0.85rem;
  color: #4ecca3;
  margin-top: 6px;
  word-break: break-all;
}

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

/* === Info Bar === */
.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 4px;
}

.info-bar .val {
  color: #c0c0d0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* === Waveform === */
.waveform-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  background: #0a0a1a;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid #0f3460;
  cursor: crosshair;
  touch-action: none;
}

.waveform-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* === Trim Region & Handles === */
.trim-region {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(233,69,96,0.15);
  border-left: 2px solid #e94560;
  border-right: 2px solid #e94560;
  pointer-events: none;
  z-index: 2;
  transition: background 0.15s ease;
}

.trim-region:hover {
  background: rgba(233,69,96,0.22);
}

.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  cursor: ew-resize;
  z-index: 3;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trim-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  right: 6px;
  background: #e94560;
  border-radius: 2px;
  opacity: 0.9;
  transition: opacity 0.15s;
}

.trim-handle:hover::before,
.trim-handle:active::before {
  opacity: 1;
}

.trim-handle .knob {
  position: absolute;
  width: 20px;
  height: 20px;
  background: #e94560;
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 8px rgba(233,69,96,0.5);
  border: 2px solid #fff;
  z-index: 4;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.trim-handle:hover .knob,
.trim-handle:active .knob {
  transform: translateY(-50%) scale(1.15);
  box-shadow: 0 0 14px rgba(233,69,96,0.7);
}

.trim-handle.start .knob {
  left: -10px;
}

.trim-handle.end .knob {
  right: -10px;
}

/* === Playhead / Cursor === */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #4ecca3;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(78,204,163,0.6);
}

/* === Time Labels === */
.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: #666;
  margin-bottom: 10px;
  padding: 0 2px;
}

/* === Time Inputs === */
.time-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #aaa;
}

.time-inputs label {
  color: #888;
  font-size: 0.8rem;
}

.time-inputs input[type="number"] {
  width: 56px;
  padding: 5px 8px;
  background: #0a0a1a;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  text-align: center;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.time-inputs input[type="number"]::-webkit-inner-spin-button,
.time-inputs input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.time-inputs input[type="number"]:focus {
  outline: none;
  border-color: #e94560;
  box-shadow: 0 0 0 2px rgba(233,69,96,0.15);
}

/* === Controls === */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.controls .zoom-group {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.controls .zoom-group label {
  font-size: 0.85rem;
  color: #666;
  margin-right: 2px;
}

/* === Buttons === */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #0f3460;
  color: #c0c0d0;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: #1a4a7a;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,52,96,0.3);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-success {
  background: #4ecca3;
  color: #0a0a1a;
  font-weight: 600;
}

.btn-success:hover:not(:disabled) {
  background: #3db88f;
  color: #0a0a1a;
  box-shadow: 0 4px 12px rgba(78,204,163,0.3);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-icon {
  padding: 8px 10px;
  font-size: 1.1rem;
  line-height: 1;
}

/* === Progress Bar === */
.progress-wrap {
  height: 4px;
  background: #0f3460;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: #e94560;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

/* === Status === */
.status {
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  min-height: 1.2em;
  line-height: 1.4;
}

.status.error {
  color: #e94560;
}

.status.success {
  color: #4ecca3;
}

/* === Supported Formats Badge === */
.formats-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 0.7rem;
  color: #555;
  flex-wrap: wrap;
}

.formats-badge span {
  background: rgba(15,52,96,0.3);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.65rem;
  color: #777;
}

/* === Fade-in animation === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.container {
  animation: fadeIn 0.3s ease;
}

/* ============================================
   Responsive — Tablet & Mobile
   ============================================ */
@media (max-width: 700px) {
  .container {
    padding: 20px 16px;
    border-radius: 12px;
    width: 100vw;
    min-height: 100vh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .container h1 {
    font-size: 1.1rem;
  }

  .upload-zone {
    padding: 24px 16px;
  }

  .upload-zone .icon {
    font-size: 2rem;
  }

  .waveform-wrap {
    height: 120px;
  }

  .controls {
    gap: 6px;
  }

  .controls .zoom-group {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .btn {
    padding: 7px 12px;
    font-size: 0.8rem;
  }

  .btn-sm {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .time-inputs input[type="number"] {
    width: 50px;
    padding: 4px 6px;
  }

  .time-inputs {
    gap: 4px;
  }

  .trim-handle {
    width: 12px;
  }

  .trim-handle .knob {
    width: 18px;
    height: 18px;
  }

  .info-bar {
    font-size: 0.7rem;
  }
}

@media (max-width: 400px) {
  .container {
    padding: 14px 10px;
  }

  .container h1 {
    font-size: 1rem;
  }

  .container h1 small {
    font-size: 0.65rem;
  }

  .waveform-wrap {
    height: 90px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .time-inputs input[type="number"] {
    width: 42px;
    font-size: 0.75rem;
  }

  .upload-zone {
    padding: 18px 12px;
  }

  .upload-zone .icon {
    font-size: 1.6rem;
  }

  .upload-zone .text {
    font-size: 0.85rem;
  }
}

/* ============================================
   Dark scrollbar for the page
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 3px;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #0f3460 transparent;
}