/* Responsive container */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* Flipbook container - responsive */
#flipbook {
    width: 100%;
    height: auto;
    min-height: 300px;
    max-width: 100%;
    margin: 0 auto;
    transition: all 0.3s ease;
    position: relative;
}

/* Corner flip effect */
.corner {
    position: absolute;
    width: 50px;
    height: 50px;
    z-index: 100;
    cursor: pointer;
    transition: transform 0.3s ease;
    opacity: 0.3;
}

.corner:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

.corner-top-right {
    top: 0;
    right: 0;
}

.corner-top-left {
    top: 0;
    left: 0;
}

.corner-bottom-right {
    bottom: 0;
    right: 0;
}

.corner-bottom-left {
    bottom: 0;
    left: 0;
}

/* Page curl effect */
.page-curled {
    box-shadow: -5px 0 15px rgba(0,0,0,0.2);
    transform: perspective(1000px) rotateY(-10deg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Individual pages - responsive sizing */
.page {
    width: 100%;
    height: 100%;
    background-color: #fdfdfd;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

/* Page shadow effect during turn */
.turning {
    box-shadow: -20px 0 30px rgba(0,0,0,0.3) !important;
}

/* Canvas responsive */
.page canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* Navigation container */
#flipbook-nav {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    gap: 10px;
    padding: 0 10px;
    flex-wrap: wrap;
}

/* Control panel */
.control-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.control-btn {
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.control-btn:hover {
    background: #e55a2b;
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

/* Page counter */
.page-counter {
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 5px 15px;
    font-size: 14px;
    color: #666;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Search bar */
.search-container {
    position: relative;
    margin: 10px auto;
    max-width: 300px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid #ff6b35;
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.3s;
    outline: none;
}

.search-input:focus {
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.3);
}

.search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-btn:hover {
    background: #e55a2b;
}

/* Navigation buttons - mobile friendly */
.nav-btn {
    flex: 1;
    max-width: 150px;
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    background-color: #ff6b35;
    color: white;
    position: relative;
    overflow: hidden;
}

.nav-btn:hover {
    background-color: #e55a2b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.nav-btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    #flipbook {
        height: 400px;
    }

    .page {
        border-radius: 5px;
    }

    .nav-btn {
        padding: 15px;
        font-size: 14px;
    }

    #flipbook-nav {
        flex-direction: row;
        gap: 8px;
    }

    .corner {
        width: 40px;
        height: 40px;
    }

    .control-panel {
        gap: 10px;
        padding: 0 10px;
    }

    .control-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #flipbook {
        height: 350px;
    }

    .nav-btn {
        padding: 12px;
        font-size: 13px;
    }

    .corner {
        width: 35px;
        height: 35px;
    }
}

/* Portrait orientation */
@media (max-width: 768px) and (orientation: portrait) {
    #flipbook {
        height: 450px;
    }
}

/* Landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
    #flipbook {
        height: 300px;
    }
}

/* Loading indicator */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    font-size: 18px;
    color: #666;
    flex-direction: column;
    gap: 15px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Swipe hint for mobile */
.swipe-hint {
    text-align: center;
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    display: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@media (max-width: 768px) {
    .swipe-hint {
        display: block;
    }
}

/* Page turn animation */
@keyframes pageTurn {
    0% { transform: rotateY(0); }
    50% { box-shadow: -20px 0 30px rgba(0,0,0,0.3); }
    100% { transform: rotateY(-180deg); }
}

/* Highlight search results */
.search-highlight {
    background-color: rgba(255, 255, 0, 0.5);
    border-radius: 3px;
    padding: 2px 0;
}

.current-search-result {
    background-color: rgba(255, 107, 53, 0.7) !important;
    animation: highlight-pulse 1.5s infinite;
}

@keyframes highlight-pulse {
    0% { background-color: rgba(255, 107, 53, 0.7); }
    50% { background-color: rgba(255, 107, 53, 0.9); }
    100% { background-color: rgba(255, 107, 53, 0.7); }
}

/* Sound toggle */
.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: all 0.3s;
}

.sound-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.sound-toggle.muted {
    background: #666;
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 5px;
    display: flex;
    gap: 5px;
    z-index: 100;
}

.zoom-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: #e9e9e9;
}
