/* ==========================================
   Record Song – Frontend Styles
   ========================================== */

/* ── CSS Variables ── */
:root {
    --rs-primary: #4F46E5;
    --rs-primary-hover: #4338CA;
    --rs-surface: #ffffff;
    --rs-text: #1e1e1e;
    --rs-text-secondary: #6B7280;
    --rs-border: #E5E7EB;
    --rs-radius: 16px;
    --rs-radius-sm: 10px;
    --rs-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --rs-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.18);
    --rs-red: #EF4444;
    --rs-green: #10B981;
    --rs-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Floating Drawer Container ── */
.rs-drawer {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.rs-drawer--bottom-right {
    bottom: 24px;
    right: 24px;
}

.rs-drawer--bottom-left {
    bottom: 24px;
    left: 24px;
}

/* ── Trigger Button ── */
.rs-drawer-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--rs-transition);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
    position: relative;
    overflow: hidden;
    line-height: 1.4;
}

.rs-drawer-trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 50%);
    border-radius: inherit;
}

.rs-drawer-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
}

.rs-drawer-trigger:active {
    transform: translateY(0);
}

/* Animated pulse on trigger */
.rs-animated .rs-drawer-trigger::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid currentColor;
    opacity: 0;
    animation: rs-pulse 2s ease-in-out infinite;
}

@keyframes rs-pulse {

    0%,
    100% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: 0.15;
        transform: scale(1.06);
    }
}

/* ── Drawer Panel ── */
.rs-drawer-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    width: 340px;
    background: var(--rs-surface);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow-lg);
    border: 1px solid var(--rs-border);
    overflow: hidden;
    display: none;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.rs-drawer--bottom-right .rs-drawer-panel {
    right: 0;
}

.rs-drawer--bottom-left .rs-drawer-panel {
    left: 0;
}

.rs-drawer-panel.rs-panel--open {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ── Drawer Header ── */
.rs-drawer-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--rs-border);
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
}

.rs-drawer-header h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: var(--rs-text);
}

.rs-drawer-header p {
    margin: 0;
    font-size: 13px;
    color: var(--rs-text-secondary);
    line-height: 1.4;
}

/* ── Drawer Body ── */
.rs-drawer-body {
    padding: 24px;
}

/* ── States ── */
.rs-state {
    text-align: center;
}

/* ── Idle: Record Button ── */
.rs-record-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: #fff;
    cursor: pointer;
    transition: var(--rs-transition);
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.35);
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.rs-record-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 30px rgba(79, 70, 229, 0.5);
}

.rs-record-btn:active {
    transform: scale(0.98);
}

/* ── Recording State ── */
.rs-waveform-container {
    background: #f8f8fc;
    border-radius: var(--rs-radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}

.rs-waveform-canvas {
    width: 100%;
    height: 60px;
    display: block;
}

.rs-timer {
    font-size: 28px;
    font-weight: 700;
    color: var(--rs-red);
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

/* Recording dot animation */
.rs-state--recording .rs-timer::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--rs-red);
    border-radius: 50%;
    margin-right: 10px;
    animation: rs-blink 1s ease-in-out infinite;
    vertical-align: middle;
}

@keyframes rs-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

.rs-recording-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.rs-stop-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: 50px;
    background: var(--rs-red);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rs-transition);
}

.rs-stop-btn:hover {
    background: #DC2626;
    transform: translateY(-1px);
}

/* ── Preview State ── */
.rs-audio-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #f8f8fc;
    border-radius: var(--rs-radius-sm);
    margin-bottom: 16px;
}

.rs-play-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--rs-primary);
    color: #fff;
    cursor: pointer;
    transition: var(--rs-transition);
    flex-shrink: 0;
}

.rs-play-btn:hover {
    background: var(--rs-primary-hover);
    transform: scale(1.08);
}

.rs-progress-bar {
    flex: 1;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
}

.rs-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--rs-primary), #7C3AED);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.rs-duration {
    font-size: 12px;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--rs-text-secondary);
    flex-shrink: 0;
}

.rs-preview-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.rs-rerecord-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 2px solid var(--rs-border);
    border-radius: 50px;
    background: transparent;
    color: var(--rs-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rs-transition);
}

.rs-rerecord-btn:hover {
    border-color: var(--rs-primary);
    color: var(--rs-primary);
    background: #f8f7ff;
}

.rs-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--rs-green), #059669);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rs-transition);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.rs-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

/* ── Submitting State ── */
.rs-state--submitting {
    padding: 20px 0;
}

.rs-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #E5E7EB;
    border-top-color: var(--rs-primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: rs-spin 0.8s linear infinite;
}

@keyframes rs-spin {
    to {
        transform: rotate(360deg);
    }
}

.rs-state--submitting p {
    font-size: 14px;
    color: var(--rs-text-secondary);
    margin: 0;
}

/* ── Success State ── */
.rs-success-icon {
    margin-bottom: 12px;
    animation: rs-success-pop 0.4s ease-out;
}

@keyframes rs-success-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    60% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.rs-state--success h4 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--rs-text);
}

.rs-state--success p {
    font-size: 14px;
    color: var(--rs-text-secondary);
    margin: 0 0 16px;
}

.rs-new-recording-btn {
    padding: 8px 20px;
    border: 2px solid var(--rs-primary);
    border-radius: 50px;
    background: transparent;
    color: var(--rs-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rs-transition);
}

.rs-new-recording-btn:hover {
    background: var(--rs-primary);
    color: #fff;
}

/* ── Inline Recorder (Shortcode) ── */
.rs-shortcode-recorder {
    display: inline-block;
    position: relative;
}

.rs-inline-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rs-transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rs-inline-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.rs-inline-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    background: var(--rs-surface);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow-lg);
    border: 1px solid var(--rs-border);
    overflow: hidden;
    z-index: 99999;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .rs-drawer {
        bottom: 12px !important;
        right: 12px !important;
        left: 12px !important;
    }

    .rs-drawer-panel {
        width: calc(100vw - 24px);
        right: 0 !important;
        left: auto !important;
    }

    .rs-drawer--bottom-left .rs-drawer-panel {
        left: 0 !important;
        right: auto !important;
    }

    .rs-drawer-trigger-text {
        display: none;
    }

    .rs-drawer-trigger {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        padding: 0 !important;
        justify-content: center;
    }
}