/* ============================================
   Recording Panel - "Sound-Fänger" Design
   ============================================
   Kindgerechtes, einladendes Recording-Interface.
   Ersetzt die inline-Styles aus play.php.
   ============================================ */

/* ============================================
   PANEL GRUNDSTRUKTUR
   ============================================ */

.marker-record-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 250;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.marker-record-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 300;
    background: linear-gradient(145deg, rgba(37, 26, 66, 0.98) 0%, rgba(26, 18, 48, 0.98) 100%);
    border-radius: 32px;
    padding: 56px 28px 28px; /* Mehr Platz oben fuer Close-Button */
    min-width: 320px;
    max-width: 400px;
    width: calc(100% - 40px);
    text-align: center;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid var(--color-primary);
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden; /* Fuer abgerundete Ecken der Overlays */
}

.marker-record-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 50; /* Ueber allen Panel-Inhalten */
}

.marker-record-close:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: scale(1.1);
}

/* ============================================
   STATE STEPS - Schritt-Indikator
   ============================================ */

.state-steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.state-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.state-step .step-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.state-step.active {
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
}

.state-step.active .step-icon {
    background: #ff6b6b;
    color: white;
}

.state-step.recording {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
}

.state-step.recording .step-icon {
    background: #ff4757;
    animation: pulse-icon 1s ease-in-out infinite;
}

.state-step.completed {
    color: var(--color-success, #22c55e);
}

.state-step.completed .step-icon {
    background: var(--color-success, #22c55e);
    color: white;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ============================================
   PANEL TITEL
   ============================================ */

.marker-record-panel-title {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
}

.marker-record-panel-title .icon {
    font-size: 28px;
}

.marker-record-panel-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 24px;
    font-weight: 500;
}

/* ============================================
   MARKER STATUS - Freundlicher Look
   ============================================ */

.marker-status {
    background: linear-gradient(135deg, rgba(84, 160, 255, 0.1) 0%, rgba(165, 94, 234, 0.1) 100%);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: center;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    transition: all 0.4s ease;
}

.marker-status.has-marker {
    border-style: solid;
    border-color: var(--color-accent-1, #4ade80);
    background: linear-gradient(135deg, rgba(29, 209, 161, 0.15) 0%, rgba(46, 213, 115, 0.1) 100%);
}

.marker-status-waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.marker-status-waiting .icon {
    font-size: 48px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.marker-status-waiting p,
.marker-status-waiting span {
    font-size: 15px;
    font-weight: 600;
}

.marker-status-locked {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.marker-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-accent-1, #4ade80);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 700;
    animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Legacy support - alte Klasse */
.marker-status-locked .marker-id {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-accent-1, #4ade80);
    animation: bounce-in 0.3s var(--ease-bounce, cubic-bezier(0.68, -0.55, 0.265, 1.55));
}

@keyframes bounce-in {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.marker-status-locked .marker-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.marker-status-locked .marker-has-sound {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(74, 222, 128, 0.2);
    border-radius: 16px;
    font-size: 13px;
    color: var(--color-accent-1, #4ade80);
    margin-top: 8px;
}

/* ============================================
   SOUND CATCHER - Record Button
   ============================================ */

.marker-record-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 20px;
}

/* Outer glow ring */
.catcher-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160px;
    height: 160px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 107, 107, 0.35) 0%, transparent 70%);
    opacity: 0.6;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

/* Recording: Glow wächst und pulsiert intensiv */
.marker-record-container.recording .catcher-glow {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 71, 87, 0.5) 0%, rgba(255, 71, 87, 0.2) 40%, transparent 70%);
    opacity: 1;
    animation: glow-pulse 1.2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.5;
    }
}

/* Progress Ring */
.marker-record-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140px;
    height: 140px;
    transform: translate(-50%, -50%) rotate(-90deg);
    pointer-events: none;
    z-index: 1;
}

.marker-record-progress circle {
    fill: none;
    stroke-width: 5;
    stroke-linecap: round;
}

.marker-record-progress-bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.marker-record-progress-ring {
    stroke: #ff6b6b;
    transition: stroke-dashoffset 0.08s linear, stroke 0.3s ease;
    filter: drop-shadow(0 0 4px rgba(255, 107, 107, 0.5));
}

/* Recording: Progress Ring leuchtet intensiver */
.marker-record-container.recording .marker-record-progress-ring {
    stroke: #ff4757;
    filter: drop-shadow(0 0 8px rgba(255, 71, 87, 0.7));
}

/* Main Record Button */
.marker-record-btn-large {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #ff6b6b 0%, #ff8a8a 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 30px rgba(255, 107, 107, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.marker-record-btn-large:hover:not(.recording) {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow:
        0 12px 40px rgba(255, 107, 107, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

.marker-record-btn-large:active:not(.recording) {
    transform: translate(-50%, -50%) scale(0.95);
}

.marker-record-btn-large:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translate(-50%, -50%);
}

.marker-record-btn-large .inner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Recording State - Lebendige Animation */
.marker-record-btn-large.recording {
    background: linear-gradient(145deg, #ff4757 0%, #ff6b81 100%);
    box-shadow:
        0 8px 40px rgba(255, 71, 87, 0.6),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
    animation: recording-bounce 0.6s ease-in-out infinite;
}

@keyframes recording-bounce {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.04);
    }
}

/* Inner Circle wird zu abgerundetem Quadrat beim Recording */
.marker-record-btn-large.recording .inner {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: white;
    animation: inner-pulse 0.6s ease-in-out infinite;
}

@keyframes inner-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.92);
        opacity: 0.9;
    }
}

/* Live Waveform Canvas - zentriert im Button */
.marker-record-waveform {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.marker-record-btn-large.recording .marker-record-waveform {
    opacity: 1;
}

/* ============================================
   STATUS TEXT
   ============================================ */

.marker-record-state {
    margin-top: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.marker-record-state .status-text {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.marker-record-state .status-hint {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

.marker-record-state .timer {
    font-size: 28px;
    font-weight: 800;
    color: #ff4757;
    font-variant-numeric: tabular-nums;
}

/* Legacy states */
.marker-record-state.idle {
    color: rgba(255, 255, 255, 0.6);
}

.marker-record-state.recording {
    color: #ff4757;
}

.marker-record-state.done {
    color: var(--color-accent-1, #4ade80);
}

/* ============================================
   WAVEFORM PREVIEW
   ============================================ */

.marker-record-waveform-preview {
    position: relative;
    height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
}

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

/* Trim overlays */
.trim-overlay-left,
.trim-overlay-right {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.trim-overlay-left {
    left: 0;
}

.trim-overlay-right {
    right: 0;
}

/* Trim Handles - Größer und freundlicher */
.trim-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    background: #feca57;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    transition: background 0.2s ease;
    z-index: 10;
}

.trim-handle:hover,
.trim-handle:active {
    background: #ffdc6b;
}

.trim-handle::after {
    content: '';
    width: 4px;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.trim-handle-start {
    border-radius: 8px 0 0 8px;
}

.trim-handle-end {
    border-radius: 0 8px 8px 0;
}

/* Trim Region */
.trim-region {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(139, 92, 246, 0.2);
    border-top: 2px solid var(--color-primary, #8b5cf6);
    border-bottom: 2px solid var(--color-primary, #8b5cf6);
    pointer-events: none;
}

/* Playhead */
.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ff6b6b;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    z-index: 5;
    transition: left 0.05s linear;
}

/* Trim Info */
.trim-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    padding: 0 4px;
    margin-top: 8px;
}

.trim-info .duration {
    color: #feca57;
}

/* ============================================
   PREVIEW CONTROLS
   ============================================ */

.marker-record-preview {
    margin-bottom: 20px;
}

.marker-record-preview-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.preview-btn {
    flex: 1;
    height: 56px;
    border: none;
    border-radius: 16px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.preview-btn-play {
    background: linear-gradient(135deg, #a55eea 0%, #8854d0 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(165, 94, 234, 0.4);
}

.preview-btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(165, 94, 234, 0.5);
}

.preview-btn-play.playing {
    background: linear-gradient(135deg, #feca57 0%, #f8b500 100%);
    box-shadow: 0 4px 20px rgba(254, 202, 87, 0.4);
}

.preview-btn-reset {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    flex: 0 0 56px;
}

.preview-btn-reset:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ============================================
   NAME INPUT
   ============================================ */

.marker-record-name {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
    transition: border-color 0.2s ease;
}

.marker-record-name::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.marker-record-name:focus {
    outline: none;
    border-color: var(--color-primary, #8b5cf6);
}

/* ============================================
   ACTION BUTTONS
   ============================================ */

.marker-record-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.marker-record-actions .btn {
    flex: 1;
    height: 56px;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 700;
}

.marker-record-actions .btn-primary {
    background: linear-gradient(135deg, var(--color-success, #22c55e) 0%, #26de81 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
    border: none;
}

.marker-record-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(34, 197, 94, 0.5);
}

.marker-record-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: none;
}

.marker-record-actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ============================================
   SUCCESS OVERLAY
   ============================================ */

.success-overlay {
    position: absolute;
    inset: -2px; /* Erweitert ueber den Border hinaus */
    background: linear-gradient(135deg, #2ed573 0%, #1dd1a1 100%);
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 30; /* Unter dem Close-Button (50), aber ueber allem anderen */
}

.success-overlay[x-cloak] {
    display: none;
}

.success-icon {
    font-size: 72px;
    animation: success-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes success-bounce {
    0% { transform: scale(0) rotate(-20deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.success-text {
    font-size: 24px;
    font-weight: 800;
    color: white;
    text-align: center;
}

.success-subtext {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.85);
}

/* Confetti particles */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confetti-fall 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(200px) rotate(720deg);
        opacity: 0;
    }
}

/* ============================================
   SAVED RECORDINGS LIST
   ============================================ */

.saved-recordings {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.saved-recordings-title {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.saved-recording-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: rgba(255, 255, 255, 0.9);
}

.saved-recording-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.saved-recording-item .icon {
    font-size: 20px;
    color: var(--color-primary, #8b5cf6);
}

.saved-recording-item .name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
}

.saved-recording-item .duration {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.saved-recording-item .delete-btn {
    padding: 6px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    border-radius: 6px;
}

.saved-recording-item:hover .delete-btn {
    opacity: 1;
}

.saved-recording-item .delete-btn:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 400px) {
    .marker-record-panel {
        padding: 48px 16px 20px;
        border-radius: 24px;
        min-width: auto;
        width: calc(100% - 24px);
    }

    .marker-record-close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
    }

    .state-steps {
        gap: 4px;
        margin-bottom: 16px;
    }

    .state-step {
        padding: 6px 10px;
        font-size: 12px;
    }

    .state-step span:not(.step-icon) {
        display: none;
    }

    .marker-record-panel-title {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .marker-record-panel-subtitle {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .marker-status {
        padding: 14px;
        margin-bottom: 16px;
    }

    .marker-record-container {
        width: 130px;
        height: 130px;
        margin-bottom: 12px;
    }

    .marker-record-btn-large {
        width: 100px;
        height: 100px;
    }

    .marker-record-btn-large .inner {
        width: 38px;
        height: 38px;
    }

    .marker-record-state {
        margin-top: 12px;
        margin-bottom: 12px;
    }

    .marker-record-actions {
        gap: 8px;
    }

    .marker-record-actions .btn {
        height: 48px;
        font-size: 15px;
    }

    .success-overlay {
        border-radius: 24px;
    }

    .success-icon {
        font-size: 56px;
    }

    .success-text {
        font-size: 20px;
    }
}
