/**
 * Persistent Bottom Control Bar Styles
 * Always-visible recitation controls
 */

/* =========================================
   BOTTOM BAR CONTAINER
   ========================================= */

.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    font-family: var(--ui-font, 'Readex Pro', sans-serif);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease;
}

/* Dark mode */
body.dark-mode .bottom-bar {
    background: rgba(37, 42, 40, 0.95);
    border-top-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* Hidden state for when modal is open etc */
.bottom-bar.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* Body padding when bottom bar is visible */
body.has-bottom-bar {
    padding-bottom: 80px;
}

body.has-bottom-bar .app-footer {
    /*padding-bottom: 100px;*/
}

/* =========================================
   CONTROL BUTTONS
   ========================================= */

.bottom-bar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 52px;
    height: 48px;
    padding: 0 16px;
    border: none;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.bottom-bar-btn:focus-visible {
    outline: 2px solid var(--primary-color, #3a9d74);
    outline-offset: 2px;
}

.bottom-bar-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.bottom-bar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* Navigation buttons (Prev/Next) */
.bottom-bar-btn.btn-nav-bottom {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-color, #333);
    min-width: 48px;
    padding: 0 14px;
}

.bottom-bar-btn.btn-nav-bottom:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
}

body.dark-mode .bottom-bar-btn.btn-nav-bottom {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color-dark, #e8f0ec);
}

body.dark-mode .bottom-bar-btn.btn-nav-bottom:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

/* Primary action button (Record) - Green theme idle, Red recording */
.bottom-bar-btn.btn-primary-bottom {
    background: linear-gradient(135deg, hsl(var(--primary-hue, 150), 50%, 45%), hsl(var(--primary-hue, 150), 55%, 35%));
    color: white;
    min-width: 110px;
    box-shadow: 0 4px 12px hsla(var(--primary-hue, 150), 50%, 40%, 0.35);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-bar-btn.btn-primary-bottom:hover:not(:disabled) {
    box-shadow: 0 6px 20px hsla(var(--primary-hue, 150), 50%, 45%, 0.5);
    transform: translateY(-1px);
    background: linear-gradient(135deg, hsl(var(--primary-hue, 150), 55%, 50%), hsl(var(--primary-hue, 150), 50%, 40%));
}

/* Stop state - change to warning/gold color */
.bottom-bar-btn.btn-primary-bottom.is-active {
    background: linear-gradient(135deg, var(--secondary-color, #d4af37), hsl(45, 65%, 45%));
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.35);
}

.bottom-bar-btn.btn-primary-bottom.is-active:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.45);
}

/* Bottom Bar Record Button - Icon Transformation */
.bottom-bar-btn.btn-primary-bottom {
    min-width: 56px;
    padding: 0 16px;
}

.bottom-bar-btn.btn-primary-bottom .btn-label {
    display: none;
}

/* Loading spinner - hidden by default */
.bottom-bar-btn.btn-primary-bottom .loading-spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bottom-bar-spinner 0.8s linear infinite;
    position: absolute;
    inset: 0;
    margin: auto;
}

/* Loading State - show spinner, hide mic icon */
.bottom-bar-btn.btn-primary-bottom.is-loading {
    background: linear-gradient(135deg, hsl(var(--primary-hue, 150), 55%, 45%), hsl(var(--primary-hue, 150), 60%, 35%)) !important;
    cursor: wait;
}

.bottom-bar-btn.btn-primary-bottom.is-loading i.fa-microphone {
    display: none !important;
}

.bottom-bar-btn.btn-primary-bottom.is-loading .loading-spinner {
    display: block;
}

.bottom-bar-btn.btn-primary-bottom.is-loading .record-dot {
    display: none;
}

@keyframes bottom-bar-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Recording dot - hidden by default */
.bottom-bar-btn.btn-primary-bottom .record-dot {
    display: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Recording State - hide mic, show pulsing dot */
.bottom-bar-btn.btn-primary-bottom.is-recording {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    animation: bottom-bar-glow 1.5s ease-in-out infinite;
}

.bottom-bar-btn.btn-primary-bottom.is-recording i {
    display: none;
}

.bottom-bar-btn.btn-primary-bottom.is-recording .record-dot {
    display: block;
    animation: bottom-bar-dot-pulse 1s ease-in-out infinite;
}

@keyframes bottom-bar-glow {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
    }
    50% {
        box-shadow: 0 4px 30px rgba(239, 68, 68, 0.75), 0 0 50px rgba(239, 68, 68, 0.3);
    }
}

@keyframes bottom-bar-dot-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
    }
    50% {
        transform: scale(1.25);
        box-shadow: 0 0 18px rgba(255, 255, 255, 1);
    }
}

/* Reset button */
.bottom-bar-btn.btn-reset-bottom {
    background: rgba(0, 0, 0, 0.05);
    color: var(--muted-text, #666);
    min-width: 48px;
    padding: 0;
}

.bottom-bar-btn.btn-reset-bottom:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color, #333);
}

body.dark-mode .bottom-bar-btn.btn-reset-bottom {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted-text-dark, #a0b0a8);
}

body.dark-mode .bottom-bar-btn.btn-reset-bottom:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color-dark, #e8f0ec);
}

/* Surah Mode toggle button */
.bottom-bar-btn.btn-surah-mode {
    background: rgba(0, 0, 0, 0.05);
    color: var(--muted-text, #666);
    min-width: 48px;
    padding: 0;
    position: relative;
}

.bottom-bar-btn.btn-surah-mode:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color, #333);
}

/* Surah Mode active state */
.bottom-bar-btn.btn-surah-mode.is-active {
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    color: white;
    box-shadow: 0 2px 8px rgba(58, 157, 116, 0.4);
}

.bottom-bar-btn.btn-surah-mode.is-active:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(58, 157, 116, 0.5);
}

/* Surah Mode indicator badge */
.bottom-bar-btn.btn-surah-mode.is-active::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--secondary-color, #d4af37);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--secondary-color, #d4af37);
}

body.dark-mode .bottom-bar-btn.btn-surah-mode {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted-text-dark, #a0b0a8);
}

body.dark-mode .bottom-bar-btn.btn-surah-mode:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color-dark, #e8f0ec);
}

body.dark-mode .bottom-bar-btn.btn-surah-mode.is-active {
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    color: white;
}

/* Mushaf Page Mode toggle button */
.bottom-bar-btn.btn-mushaf-mode {
    background: rgba(0, 0, 0, 0.05);
    color: var(--muted-text, #666);
    min-width: 48px;
    padding: 0;
    position: relative;
}

.bottom-bar-btn.btn-mushaf-mode:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color, #333);
}

/* Mushaf Mode active state - uses a different accent color */
.bottom-bar-btn.btn-mushaf-mode.is-active {
    background: linear-gradient(135deg, hsl(200, 60%, 45%), hsl(200, 65%, 35%));
    color: white;
    box-shadow: 0 2px 8px hsla(200, 60%, 45%, 0.4);
}

.bottom-bar-btn.btn-mushaf-mode.is-active:hover:not(:disabled) {
    box-shadow: 0 4px 12px hsla(200, 60%, 45%, 0.5);
}

/* Mushaf Mode indicator badge */
.bottom-bar-btn.btn-mushaf-mode.is-active::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--secondary-color, #d4af37);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--secondary-color, #d4af37);
}

body.dark-mode .bottom-bar-btn.btn-mushaf-mode {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted-text-dark, #a0b0a8);
}

body.dark-mode .bottom-bar-btn.btn-mushaf-mode:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color-dark, #e8f0ec);
}

body.dark-mode .bottom-bar-btn.btn-mushaf-mode.is-active {
    background: linear-gradient(135deg, hsl(200, 60%, 45%), hsl(200, 65%, 35%));
    color: white;
}

/* =========================================
   BUTTON ICONS
   ========================================= */

.bottom-bar-btn i {
    font-size: 1rem;
    line-height: 1;
}

.bottom-bar-btn.btn-primary-bottom i {
    font-size: 1.1rem;
}

/* Button text labels */
.bottom-bar-btn .btn-label {
    font-size: 0.85rem;
    font-weight: 600;
}

/* =========================================
   DIVIDER
   ========================================= */

.bottom-bar-divider {
    width: 1px;
    height: 28px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 4px;
}

body.dark-mode .bottom-bar-divider {
    background: rgba(255, 255, 255, 0.1);
}

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

@media (max-width: 767px) {
    .bottom-bar {
        padding: 10px 16px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }

    body.has-bottom-bar {
        padding-bottom: 70px;
    }

    .bottom-bar-btn {
        height: 44px;
        min-width: 44px;
        padding: 0 12px;
        font-size: 0.85rem;
    }

    .bottom-bar-btn.btn-primary-bottom {
        min-width: 90px;
    }

    .bottom-bar-btn i {
        font-size: 0.95rem;
    }

    /* Hide text labels on small screens, show only icons */
    .bottom-bar-btn .btn-label {
        display: none;
    }

    .bottom-bar-divider {
        height: 24px;
    }

    /* Hide mic meter on mobile - it doesn't work reliably */
    .mic-meter-wrapper {
        display: none !important;
    }
}

@media (max-width: 360px) {
    .bottom-bar {
        padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        gap: 6px;
    }

    .bottom-bar-btn {
        height: 40px;
        min-width: 40px;
        padding: 0 10px;
    }

    .bottom-bar-btn.btn-primary-bottom {
        min-width: 80px;
    }
}

/* =========================================
   RTL SUPPORT
   ========================================= */

html[dir="rtl"] .bottom-bar,
body.rtl-mode .bottom-bar {
    flex-direction: row-reverse;
}

/* =========================================
   HIDE ORIGINAL CONTROLS WHEN BOTTOM BAR ACTIVE
   (Optional - can be enabled if desired)
   ========================================= */

/*
body.has-bottom-bar .controls-area .recitation-controls {
    display: none;
}
*/

/* =========================================
   HIDE ORIGINAL CONTROLS WHEN BOTTOM BAR ACTIVE
   ========================================= */

body.has-bottom-bar .controls-area .recitation-controls {
    display: none !important;
}

/* Also hide the shortcut hint since it's now on the bottom bar */
body.has-bottom-bar .controls-area .shortcut-hint {
    display: none !important;
}

/* Hide the old Prev/Next navigation buttons from selection card */
body.has-bottom-bar .selection-card .ayah-navigation {
    display: none !important;
}

/* =========================================
   KEYBOARD SHORTCUT HINT
   ========================================= */

.bottom-bar-hint {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.75rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 8px;
}

.bottom-bar:hover .bottom-bar-hint {
    opacity: 1;
}

body.dark-mode .bottom-bar-hint {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

/* =========================================
   RANGE SELECTION MODAL
   ========================================= */

.range-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.range-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.range-modal-content {
    position: relative;
    background: var(--card-bg, #fff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow: auto;
    animation: rangeModalIn 0.25s ease-out;
    z-index: 10000;
}

@keyframes rangeModalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.range-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    color: white;
}

.range-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
}

.range-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.range-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.range-modal-body {
    padding: 20px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.range-label {
    font-weight: 600;
    color: var(--primary-color, #3a9d74);
    width: 50px;
    flex-shrink: 0;
}

.range-selects {
    display: flex;
    gap: 8px;
    flex: 1;
}

.range-select {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border-color, #e0e5e8);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.range-select:focus {
    outline: none;
    border-color: var(--primary-color, #3a9d74);
}

.range-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.range-loop-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    background: hsla(var(--primary-hue, 150), 50%, 95%, 0.5);
    border-radius: 10px;
    margin-top: 16px;
}

.range-loop-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.range-loop-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color, #3a9d74);
}

.range-loop-text {
    font-weight: 600;
    color: var(--primary-dark, #2a7a58);
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-loop-hint {
    font-size: 0.8rem;
    color: var(--muted-text, #666);
    margin-left: 28px;
}

.range-modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #e0e5e8);
    background: hsla(var(--primary-hue, 150), 30%, 97%, 0.5);
}

.range-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.range-btn-cancel {
    background: var(--border-color, #e0e5e8);
    color: var(--muted-text, #666);
}

.range-btn-cancel:hover {
    background: #d0d5d8;
}

.range-btn-start {
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    color: white;
    box-shadow: 0 4px 12px hsla(var(--primary-hue, 150), 50%, 40%, 0.3);
}

.range-btn-start:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px hsla(var(--primary-hue, 150), 50%, 40%, 0.4);
}

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

/* Dark mode adjustments */
body.dark-mode .range-modal-content {
    background: var(--card-bg-dark, #252a28);
}

body.dark-mode .range-loop-row {
    background: hsla(var(--primary-hue, 150), 30%, 20%, 0.5);
}

body.dark-mode .range-modal-footer {
    background: hsla(var(--primary-hue, 150), 20%, 15%, 0.5);
}