/*
   Copyright (C) 2010-2025 Université de Lausanne, RISET
   < http://www.unil.ch/riset/ >

   This file is part of Lumières.Lausanne.
   Lumières.Lausanne is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   Lumières.Lausanne is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

   This copyright notice MUST APPEAR in all copies of the file.
*/

/* Common Viewer Controls CSS */

/*
 * Unified button styles
 * Make the transcription top-bar buttons (which use jQuery UI classes like
 * `.ui-button`) visually match the viewer icon buttons `.control-btn`.
 * This keeps markup changes minimal and centralizes the appearance here.
 */
.unified-text-btn,
.ui-button,
.ui-button.ui-widget,
.ui-button.ui-state-default {
    /* Match tb_but_text style from main toolbar */
    display: inline-block;
    font-size: 84.651%;
    line-height: 17px;
    padding: 4px 8px;
    margin: 4px 3px 0;
    background-color: #DEDEDE;
    border: 1px solid #98958E;
    border-radius: 2px;
    color: #6C6C6C;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    height: auto;
    min-height: auto;
}

.unified-text-btn:hover,
.ui-button:hover,
.ui-button.ui-state-default:hover {
    color: #222;
    background-color: #F9F8F4;
    border-color: #776C4E;
}

.unified-text-btn:active,
.ui-button:active {
    background: #dee2e6;
}

.ui-button .ui-button-text { /* maintain existing inner span usage */
    display: inline-block;
}

.ui-button[aria-disabled="true"],
.ui-button.ui-state-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.viewer-control-bar {
    /* Match toolbar appearance */
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #DFDFDF;
    border: 1px solid #8C8C8C;
    border-radius: 2px;
    padding: 6px 8px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1000;
    height: 28px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.viewer-control-bar {
    justify-content: space-between;
}

.control-btn {
    /* Match tb_but style from main toolbar */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 25px;
    margin: 0;
    background-color: #DEDEDE;
    border: 1px solid #98958E;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.control-btn:hover {
    background-color: #F9F8F4;
    border-color: #776C4E;
}

.control-btn:active {
    background: #dee2e6;
    transform: translateY(1px);
}

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

.control-btn:disabled:hover {
    background-color: #DEDEDE;
    border-color: #98958E;
}

.page-indicator {
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    margin: 0 8px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.marker-indicator {
    margin-left: 8px;
    padding: 1px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    border-radius: 3px;
    background: transparent;
    white-space: nowrap;
}

.marker-indicator.blink {
    animation: markerBlink 900ms ease-in-out;
}

@keyframes markerBlink {
    0%   { background: #ffe58f; }
    70%  { background: #ffe58f; }
    100% { background: transparent; }
}

.page-input {
    width: 35px;
    height: 22px;
    padding: 2px 4px;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    text-align: center;
    border: 1px solid #98958E;
    border-radius: 2px;
    background-color: #fff;
    transition: border-color 0.2s ease;
}

.page-input:hover {
    border-color: #776C4E;
}

.page-input:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 1px;
    border-color: #0d6efd;
}

.page-input::-webkit-inner-spin-button,
.page-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
.page-input[type="number"] {
    -moz-appearance: textfield;
}

/* Control Icons using CSS sprites from OpenSeadragon */
.control-icon {
    width: 20px;
    height: 20px;
    display: block;
    background-repeat: no-repeat;
    background-size: contain;
}

.prev-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' stroke='%23444' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 12 10 7 15 12'/></svg>");
}
.control-btn:hover .prev-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' stroke='%230d6efd' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 12 10 7 15 12'/></svg>");
}
.control-btn:active .prev-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' stroke='%230a58ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 12 10 7 15 12'/></svg>");
}

.next-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' stroke='%23444' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 8 10 13 15 8'/></svg>");
}
.control-btn:hover .next-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' stroke='%230d6efd' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 8 10 13 15 8'/></svg>");
}
.control-btn:active .next-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' stroke='%230a58ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 8 10 13 15 8'/></svg>");
}

.zoom-in-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%23444' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'/><line x1='11' y1='8' x2='11' y2='14'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
}
.control-btn:hover .zoom-in-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%230d6efd' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'/><line x1='11' y1='8' x2='11' y2='14'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
}
.control-btn:active .zoom-in-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%230a58ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'/><line x1='11' y1='8' x2='11' y2='14'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
}

.zoom-out-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%23444' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
}
.control-btn:hover .zoom-out-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%230d6efd' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
}
.control-btn:active .zoom-out-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%230a58ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
}

.rotate-icon {
    background-image: url('/static/js/lib/openseadragon/images/rotateright_rest.png');
}
.control-btn:hover .rotate-icon {
    background-image: url('/static/js/lib/openseadragon/images/rotateright_hover.png');
}
.control-btn:active .rotate-icon {
    background-image: url('/static/js/lib/openseadragon/images/rotateright_pressed.png');
}

.fullscreen-icon {
    background-image: url('/static/js/lib/openseadragon/images/fullpage_rest.png');
}
.control-btn:hover .fullscreen-icon {
    background-image: url('/static/js/lib/openseadragon/images/fullpage_hover.png');
}
.control-btn:active .fullscreen-icon {
    background-image: url('/static/js/lib/openseadragon/images/fullpage_pressed.png');
}

.reset-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%23444' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><path d='M4 11a8 8 0 1 1 8 8'/><polyline points='10 9 14 9 14 13'/></svg>");
}
.control-btn:hover .reset-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%230d6efd' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><path d='M4 11a8 8 0 1 1 8 8'/><polyline points='10 9 14 9 14 13'/></svg>");
}
.control-btn:active .reset-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' stroke='%230a58ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'><path d='M4 11a8 8 0 1 1 8 8'/><polyline points='10 9 14 9 14 13'/></svg>");
}

/* Custom icons for contrast and brightness (using Unicode symbols) */
.contrast-icon::before {
    content: "◐";
    font-size: 18px;
    line-height: 1;
    color: #495057;
    font-style: normal;
}

.brightness-icon::before {
    content: "☀";
    font-size: 18px;
    line-height: 1;
    color: #495057;
    font-style: normal;
}

/* Dropdown popup styles */
.control-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-popup {
    position: absolute;
    top: 100%;
    left: 0;
    width: 120px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 8px;
    margin-top: 2px;
    display: none;
    z-index: 1001;
}

.dropdown-popup.show {
    display: block;
}

.dropdown-popup input[type="range"] {
    width: 100%;
    height: 16px;
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .viewer-control-bar {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .control-group {
        gap: 2px;
    }
    
    .control-btn {
        width: 28px;
        height: 28px;
    }
    
    .page-indicator {
        font-size: 12px;
        margin: 0 4px;
    }
}

/* Fullscreen mode adjustments */
.openseadragon-container.fullscreen .viewer-control-bar {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(5px);
}

/* Transcription controls: properly sized and aligned */
#transcription-view-controls p {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 0 0 12px 0;
    flex-wrap: nowrap;
}

#transcription-view-controls .ui-button,
#transcription-view-controls .ui-button.ui-widget {
    /* Match tb_but_text style but with better proportions */
    padding: 6px 10px !important;
    margin: 0 !important;
    min-height: 24px !important;
    height: auto !important;
    font-size: 11px !important;
    line-height: 14px !important;
    background-color: #DEDEDE !important;
    border: 1px solid #98958E !important;
    border-radius: 2px !important;
    color: #6C6C6C !important;
    vertical-align: middle !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#transcription-view-controls .ui-button:hover,
#transcription-view-controls .ui-button.ui-widget:hover {
    color: #222 !important;
    background-color: #F9F8F4 !important;
    border-color: #776C4E !important;
}

#transcription-view-controls .ui-button .ui-button-text,
#transcription-view-controls .ui-button .ui-button-text span {
    font-size: 11px !important;
    line-height: 14px !important;
    padding: 0 !important;
    display: inline !important;
}

#transcription-view-controls .ui-button[aria-disabled="true"],
#transcription-view-controls .ui-button.ui-state-disabled {
    opacity: 0.6;
}

@media (max-width: 900px) {
    #transcription-view-controls p {
        flex-wrap: wrap; /* allow wrapping on smaller screens */
        gap: 6px;
    }
    #transcription-view-controls .ui-button {
        font-size: 12px;
        padding: 4px 6px;
    }
}

/* Ensure controls are always visible */
.viewer-control-bar {
    user-select: none;
}

.control-btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.control-btn:focus:not(:focus-visible) {
    outline: none;
}
