/**
 * Secure Book Reader - Styles
 */

/* Hide header, footer, page title when reader is active */
body.sbr-reader-active #header,
body.sbr-reader-active #footer,
body.sbr-reader-active .default-text-page-wrap > h2,
body.sbr-reader-active .entry-title,
body.sbr-reader-active .page-title {
    display: none !important;
}

/* Remove extra padding/margin when header is hidden */
body.sbr-reader-active .page-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

body.sbr-reader-active #gwrap {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.sbr-reader {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
    font-family: "Maven Pro", sans-serif;
    background-color: #efeee5;
    min-height: 100vh;
}

/* Override theme background for reader page */
body.sbr-reader-active .row.default-text-page-block {
    background-color: #efeee5 !important;
}

/* Main reader container */
.sbr-reader-container {
    background: rgba(128, 128, 128, 0.4);
    border-radius: 8px;
    padding: 20px;
    min-height: 80vh;
}

/* Control panel */
.sbr-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #efeee5;
    border-radius: 0;
    margin-bottom: 20px;
    box-shadow: none;
}

.sbr-page-info {
    font-family: "Maven Pro", sans-serif;
    font-size: 18px;
    font-weight: 500;
    line-height: 145%;
    letter-spacing: 0.05em;
    color: #152054;
}

.sbr-page-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.sbr-page-input {
    width: 70px;
    padding-bottom: 10px;
    font-family: "Maven Pro", sans-serif;
    font-size: 18px;
    line-height: 145%;
    letter-spacing: 0.05em;
    color: #152054;
    border: none;
    background-color: transparent;
    border-bottom: 1px solid rgba(21, 32, 84, 0.5);
    text-align: center;
    border-radius: 0;
}

.sbr-page-input::placeholder {
    color: rgba(21, 32, 84, 0.5);
}

.sbr-btn {
    font-family: "Maven Pro", sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 14px;
    line-height: 16px;
    text-transform: uppercase;
    color: #152054;
    padding: 9px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: transparent;
    border: none;
    cursor: pointer;
}

.sbr-btn::before {
    transition: all ease-in 0.4s;
    content: "";
    position: absolute;
    width: calc(100% - 6px);
    height: 100%;
    border: 1px solid #152054;
}

.sbr-btn::after {
    transition: all ease-out 0.2s;
    content: "";
    position: absolute;
    width: 100%;
    height: calc(100% - 6px);
    border: 1px solid #152054;
}

.sbr-btn:hover:not(:disabled) {
    cursor: pointer;
}

.sbr-btn:hover:not(:disabled)::before {
    transition: all ease-out 0.2s;
    width: 100%;
    height: 100%;
}

.sbr-btn:hover:not(:disabled)::after {
    transition: all ease-in 0.4s;
    width: calc(100% - 6px);
    height: calc(100% + 6px);
}

.sbr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sbr-btn-small {
    padding: 8px 16px;
    font-size: 12px;
}

/* Zoom controls */
.sbr-zoom-controls {
    display: flex;
    gap: 5px;
}

.sbr-zoom-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #152054;
    background: transparent;
    color: #152054;
    border-radius: 0;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.sbr-zoom-btn:hover {
    background: #152054;
    color: #fff;
}

/* Page container */
.sbr-page-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 60vh;
    padding: 20px;
    position: relative;
    overflow: auto;
}

.sbr-page-image {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: #fff;
}

/* Full-page loader overlay */
.sbr-loader-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    transition: opacity 0.3s ease;
}

/* Hide overlay when loaded */
.sbr-reader:not(.sbr-reader-loading) .sbr-loader-overlay {
    display: none;
}

/* Hide content while loading, fade in when ready */
.sbr-reader .sbr-search-panel,
.sbr-reader .sbr-controls,
.sbr-reader .sbr-page-container {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.sbr-reader.sbr-reader-loading .sbr-search-panel,
.sbr-reader.sbr-reader-loading .sbr-controls,
.sbr-reader.sbr-reader-loading .sbr-page-container {
    opacity: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Canvas page rendering */
.sbr-page-canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    background: #fff;
    transition: transform 0.3s ease;
    /* Prevent interactions */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events: auto;
}

/* Disable context menu on canvas */
.sbr-page-canvas {
    -webkit-touch-callout: none;
}

/* Prevent text selection on container */
.sbr-page-container canvas {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Loading spinner */
.sbr-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    display: block;
}

.sbr-spinner div {
    position: absolute;
    top: 33px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #152054;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.sbr-spinner div:nth-child(1) {
    left: 8px;
    animation: sbr-ellipsis1 0.6s infinite;
}

.sbr-spinner div:nth-child(2) {
    left: 8px;
    animation: sbr-ellipsis2 0.6s infinite;
}

.sbr-spinner div:nth-child(3) {
    left: 32px;
    animation: sbr-ellipsis2 0.6s infinite;
}

.sbr-spinner div:nth-child(4) {
    left: 56px;
    animation: sbr-ellipsis3 0.6s infinite;
}

@keyframes sbr-ellipsis1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes sbr-ellipsis3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

@keyframes sbr-ellipsis2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

/* Search panel */
.sbr-search-panel {
    background: #efeee5;
    padding: 15px;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
}

.sbr-search-title {
    font-family: "Maven Pro", sans-serif;
    font-size: 18px;
    font-weight: 500;
    line-height: 145%;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    color: #152054;
}

.sbr-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
}

.sbr-search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
}

.sbr-search-clear {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid #152054;
    color: #152054;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    span {
        margin-top: -2px;
    }
}

.sbr-search-clear:hover {
    background: #152054;
    color: #fff;
}

.sbr-search-close {
    font-family: "Maven Pro", sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 14px;
    line-height: 16px;
    text-transform: uppercase;
    color: #152054;
    padding: 9px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: transparent;
    border: none;
    cursor: pointer;
    @media (max-width: 768px) {
        padding: 8px 16px;
        font-size: 12px;
    }
}

.sbr-search-close::before {
    transition: all ease-in 0.4s;
    content: "";
    position: absolute;
    width: calc(100% - 6px);
    height: 100%;
    border: 1px solid #152054;
}

.sbr-search-close::after {
    transition: all ease-out 0.2s;
    content: "";
    position: absolute;
    width: 100%;
    height: calc(100% - 6px);
    border: 1px solid #152054;
}

.sbr-search-close:hover {
    cursor: pointer;
}

.sbr-search-close:hover::before {
    transition: all ease-out 0.2s;
    width: 100%;
    height: 100%;
}

.sbr-search-close:hover::after {
    transition: all ease-in 0.4s;
    width: calc(100% - 6px);
    height: calc(100% + 6px);
}

.sbr-search-input {
    flex: 1;
    font-family: "Maven Pro", sans-serif;
    font-style: normal;
    font-weight: normal;
    font-size: 18px;
    line-height: 145%;
    letter-spacing: 0.05em;
    color: #152054;
    border: none;
    background-color: transparent;
    border-bottom: 1px solid rgba(21, 32, 84, 0.5);
    padding-bottom: 10px;
    border-radius: 0;
}

.sbr-search-input::placeholder {
    color: rgba(21, 32, 84, 0.5);
}

.sbr-search-results {
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    padding-top: 10px;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    opacity: 1;
}

.sbr-search-results.sbr-search-hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    overflow: hidden;
}

.sbr-search-results ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sbr-search-results li a {
    display: inline-block;
    padding: 5px 12px;
    background: #f0f0f0;
    border: 1px solid #152054;
    border-radius: 4px;
    text-decoration: none;
    color: #152054;
    font-size: 13px;
    transition: background 0.2s;
}

.sbr-search-results li a:hover {
    background: #152054;
    color: #fff;
}

/* Error message */
.sbr-error {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    margin: 20px 0;
}

/* Progress bar */
.sbr-progress-container {
    width: 100%;
    height: 3px;
    background: transparent;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sbr-progress-container.sbr-progress-active {
    opacity: 1;
}

.sbr-progress-bar {
    height: 100%;
    background: #152054;
    width: 0;
    position: relative;
    transition: width 0.3s ease;
}

.sbr-progress-active .sbr-progress-bar {
    animation: sbr-progress-animation 1.5s ease-in-out infinite;
}

@keyframes sbr-progress-animation {
    0% {
        width: 0;
        left: 0;
    }
    50% {
        width: 70%;
        left: 0;
    }
    100% {
        width: 0;
        left: 100%;
    }
}

/* Print protection */
@media print {
    .sbr-reader,
    .sbr-reader-container,
    .sbr-page-container,
    .sbr-page-image,
    .sbr-page-canvas {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
}

/* Screenshot protection - blur when dev tools open */
.sbr-reader.devtools-open .sbr-page-canvas {
    filter: blur(20px);
}

/* Responsive */
@media (max-width: 768px) {
    .container,
    .sbr-reader {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .sbr-controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    /* Navigation buttons in one row */
    #sbr-prev,
    #sbr-next {
        flex: 1;
        min-width: calc(50% - 5px);
        order: 1;
    }
    
    /* Page info and input in separate rows */
    .sbr-page-info {
        width: 100%;
        order: 2;
        font-size: 14px;
        text-align: center;
    }
    
    .sbr-page-input-group {
        width: 100%;
        order: 3;
        justify-content: center;
    }
    
    .sbr-btn {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .sbr-search-form {
        flex-direction: column;
    }
}

/* Prevent selection on image */
.sbr-page-image {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-pointer-events: none;
    pointer-events: none;
}

.sbr-page-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
