/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Custom Properties */
:root {
    --z-controls: 1000;
    --space-lg: 16px;
    --space-md: 12px;
    --transition-normal: 0.3s ease;
    --glass-bg: rgba(15, 20, 25, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
}

html {
    direction: rtl;
}

body {
    font-family: 'Amiri', 'Times New Roman', serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Main Slider Container */
.slider-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 100px;
    position: relative;
}

.slider-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image Container */
.image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    background: #fff;
    cursor: grab;
}

.image-container:active {
    cursor: grabbing;
}

.quran-page {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    /* object-fit: contain; */
    object-position: center;
    transition: transform 0.3s ease;
    transform-origin: center center;
    border-radius: 8px;
    display: block;
}

.quran-page.zoomed {
    cursor: move;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.loading-spinner.show {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Navigation Arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #1e3c72;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.nav-arrow:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.nav-prev {
    right: -25px;
}

.nav-next {
    left: -25px;
}

/* ======================================
   FLOATING TOGGLE BUTTON
   ====================================== */
.floating-toggle {
    position: fixed;
    bottom: 12px;
    right: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #fff;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3), 
                0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    will-change: transform;
    position: fixed;
    overflow: hidden;
}

/* Click ripple effect */
.floating-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    pointer-events: none;
    z-index: 1;
}

.floating-toggle:active::before {
    width: 120px;
    height: 120px;
}

/* SVG icon */
.floating-toggle svg {
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease;
}

.floating-toggle:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4), 
                0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
    border-radius: 25px;
}

.floating-toggle:hover svg {
    transform: scale(1.1);
}

.floating-toggle:active {
    transform: scale(0.9) translateY(0);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    transition: all 0.15s ease;
}

.floating-toggle:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
    border-radius: 22px;
}

/* Floating button animation when controls are shown */
.floating-toggle.active {
    transform: rotate(45deg) scale(1.05);
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    box-shadow: 0 8px 32px rgba(255, 107, 107, 0.4), 
                0 4px 16px rgba(0, 0, 0, 0.2);
    border-radius: 15px;
}

.floating-toggle.active:hover {
    transform: rotate(45deg) scale(1.15) translateY(-2px);
    background: linear-gradient(135deg, #ee5a24 0%, #ff6b6b 100%);
    box-shadow: 0 12px 40px rgba(255, 107, 107, 0.5), 
                0 8px 24px rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.floating-toggle.active:active {
    transform: rotate(45deg) scale(0.95);
}

/* Pulse animation on first load */
@keyframes pulse {
    0% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3), 
                    0 4px 16px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.6), 
                    0 4px 16px rgba(0, 0, 0, 0.2),
                    0 0 0 10px rgba(102, 126, 234, 0.1);
    }
    100% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3), 
                    0 4px 16px rgba(0, 0, 0, 0.2);
    }
}

.floating-toggle:not(.active) {
    animation: pulse 2s ease-in-out infinite;
}

/* ======================================
   ENHANCED CONTROLS - MOBILE NAVIGATION BAR
   ====================================== */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
    z-index: var(--z-controls);
    padding: var(--space-lg) 70px var(--space-lg) var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    will-change: transform;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    pointer-events: none;
}

.controls.show {
    transform: translateY(0);
    pointer-events: auto;
}

/* Controls Group */
.controls-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-md);
    align-items: center;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.control-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 0 8px;
}

.section-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    text-align: center;
    margin-bottom: 6px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    flex-wrap: wrap;
}

.control-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    margin: 2px;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.control-btn:hover::before {
    width: 100%;
    height: 100%;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.control-btn svg {
    z-index: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Zoom Controls Specific */
.zoom-display {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    min-width: 65px;
    text-align: center;
    flex-shrink: 0;
}

.zoom-level {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Page Controls Specific */
.page-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.page-input {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 12px 14px;
    color: #fff;
    font-size: 0.85rem;
    width: 75px;
    height: 46px;
    text-align: center;
    direction: ltr;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin: 2px;
    font-weight: 600;
}

.page-input:focus {
    outline: none;
    border-color: rgba(66, 153, 225, 0.6);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
    transform: scale(1.02);
}

.page-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-weight: 500;
}

.go-to-page {
    width: 40px !important;
    height: 40px !important;
}

.page-info-display {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    flex-shrink: 0;
    min-width: 75px;
    justify-content: center;
    margin: 2px;
}

.current-page-display {
    color: rgba(66, 153, 225, 0.9);
    font-weight: 700;
    min-width: 25px;
    text-align: center;
}

.page-separator {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 2px;
}

.total-pages-display {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* Quick Actions Specific */
.action-btn {
    width: 44px !important;
    height: 44px !important;
}

.action-btn:hover {
    background: rgba(66, 153, 225, 0.2);
    border-color: rgba(66, 153, 225, 0.4);
    transform: translateY(-2px) scale(1.05);
}

/* Zoom Controls Specific */
.zoom-display {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    min-width: 68px;
    text-align: center;
    flex-shrink: 0;
    margin: 2px;
}

.zoom-level {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Special button states */
.zoom-in:hover, .zoom-out:hover, .reset-zoom:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
}

.go-to-page:hover {
    background: rgba(249, 115, 22, 0.2);
    border-color: rgba(249, 115, 22, 0.4);
}

/* Touch Instructions */
.touch-instructions {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 90%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
    margin-bottom: 80px;
}

.touch-instructions.show {
    opacity: 1;
}

.touch-instructions p {
    margin: 0;
}

.touch-instructions p:first-child {
    margin-bottom: 5px;
}

/* Responsive Design */

/* Tablet Styles */
@media (max-width: 1024px) {
    .floating-toggle {
        width: 46px;
        height: 46px;
        bottom: 10px;
        right: 10px;
    }
    
    .controls {
        padding: 10px 60px 16px 12px;
        min-height: 75px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .section-label {
        font-size: 0.65rem;
    }
    
    .action-btn {
        width: 38px !important;
        height: 38px !important;
    }
    
    .go-to-page {
        width: 36px !important;
        height: 36px !important;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .floating-toggle {
        width: 42px;
        height: 42px;
        bottom: 12px;
        right: 12px;
        z-index: 9999;
        display: flex !important;
        position: fixed !important;
    }
    
    .nav-arrow {
        width: 40px;
        height: 40px;
        opacity: 0.8;
    }
    
    .nav-prev {
        right: -20px;
    }
    
    .nav-next {
        left: -20px;
    }
    
    .controls {
        padding: 8px 50px 14px 10px;
        min-height: 70px;
    }
    
    .control-section {
        gap: 3px;
    }
    
    .section-label {
        font-size: 0.6rem;
    }
    
    .control-group {
        gap: 4px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    .action-btn,
    .go-to-page {
        width: 34px !important;
        height: 34px !important;
    }
    
    .page-input {
        width: 65px;
        height: 40px;
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .zoom-level {
        font-size: 0.75rem;
    }
    
    .page-info-display {
        padding: 6px 8px;
        font-size: 0.7rem;
        min-width: 60px;
    }
    
    .zoom-display {
        padding: 6px 8px;
        min-width: 55px;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .floating-toggle {
        width: 40px;
        height: 40px;
        bottom: 10px;
        right: 10px;
        z-index: 9999;
        display: flex !important;
        position: fixed !important;
        border-radius: 16px;
    }
    
    .nav-arrow {
        width: 36px;
        height: 36px;
    }
    
    .nav-prev {
        right: -18px;
    }
    
    .nav-next {
        left: -18px;
    }
    
    .controls {
        padding: 6px 45px 12px 8px;
        min-height: 65px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
    }
    
    .action-btn,
    .go-to-page {
        width: 30px !important;
        height: 30px !important;
    }
    
    .page-input {
        width: 60px;
        height: 36px;
        padding: 6px 8px;
        font-size: 0.75rem;
    }
    
    .zoom-level {
        font-size: 0.65rem;
        min-width: 45px;
    }
    
    .page-info-display {
        font-size: 0.65rem;
        min-width: 55px;
        padding: 4px 6px;
    }
    
    .zoom-display {
        min-width: 45px;
        padding: 4px 6px;
    }
    
    .section-label {
        font-size: 0.55rem;
    }
    
    .touch-instructions {
        bottom: 85px;
        font-size: 0.75rem;
        padding: 10px 12px;
        max-width: 95%;
        margin-bottom: 65px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
   
    
    .controls {
        padding: 4px 8px 8px 8px;
        min-height: 55px;
    }
    
    .control-btn {
        width: 30px;
        height: 30px;
    }
    
    .section-label {
        font-size: 0.55rem;
    }
    
    .touch-instructions {
        display: none;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .quran-page {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* body {
        background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
    } */
    
    .header {
        background: rgba(15, 20, 25, 0.95);
    }
    
    .controls {
        background: rgba(15, 20, 25, 0.95);
    }
}
