/* --- Global Reset & Styles --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#main-viewer {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

#image-wrapper {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: 1;
}

#image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    will-change: transform, opacity;
}

/* --- HUD --- */
.hud-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.hud-left,
.hud-right {
    position: absolute;
    top: 20px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.hud-left {
    left: 20px;
}

.hud-right {
    right: 20px;
}

.hud-center {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

body.is-fullscreen .hud-left,
body.is-fullscreen .hud-right,
body.is-fullscreen .hud-center {
    display: none !important;
}

body.is-fullscreen.info-on .hud-left {
    display: flex !important;
}

body.is-fullscreen.info-on #about-btn {
    display: none;
}

.hud-bar button {
    background: rgba(80, 80, 80, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.hud-bar button:hover {
    background: rgba(255, 255, 255, 0.6);
    color: #000;
}

#help-btn,
#about-btn {
    font-family: 'Segoe UI', sans-serif;
    font-weight: 900;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #ccc !important;
    text-shadow: none !important;
}

#help-btn:hover,
#about-btn:hover {
    background: #f0f0f0 !important;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.music-active {
    background-color: rgba(40, 167, 69, 0.8) !important;
    color: white !important;
    border-color: #28a745 !important;
    box-shadow: 0 0 10px #28a745;
    animation: pulse-green 2s infinite;
}

/* Note Button Active State */
.notes-active {
    background-color: rgba(40, 167, 69, 0.8) !important;
    color: white !important;
    border-color: #28a745 !important;
    box-shadow: 0 0 10px #28a745;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.nav-arrow {
    pointer-events: auto;
    background: transparent !important;
    border: none !important;
    font-size: 4em !important;
    opacity: 0.4;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    width: auto !important;
    height: auto !important;
    padding: 20px;
    border-radius: 10px !important;
    transition: all 0.2s ease;
}

.nav-arrow:hover {
    opacity: 1 !important;
    transform: scale(1.1);
    background-color: rgba(255, 255, 255, 0.8) !important;
    color: #000 !important;
    text-shadow: none;
}

/* --- Info Overlay --- */
.info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 10%, transparent);
    padding: 60px 30px 20px;
    z-index: 90;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: auto;
}

.info-overlay.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.info-overlay h3 {
    margin: 0 0 5px;
    font-size: 1.6em;
    text-shadow: 1px 1px 2px black;
}

#info-overlay #photo-exif {
    display: none !important;
}

#photo-counter {
    position: absolute;
    bottom: 20px;
    right: 25px;
    z-index: 95;
    color: #fff;
    font-family: 'Segoe UI', sans-serif;
    font-size: 1.4em;
    font-weight: 800;
    pointer-events: none;
    text-shadow: 2px 2px 4px #000;
    transition: opacity 0.3s;
}

#photo-counter.hidden {
    opacity: 0;
}

/* Play/Pause Feedback Overlay */
#play-pause-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15vw;
    color: white;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: opacity 0.5s ease-out;
}

/* Note Indicator */
.note-indicator {
    position: fixed;
    top: 90px;
    right: 30px;
    background: rgba(80, 80, 80, 0.7);
    color: #fff;
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 1.4em;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 2100;
    pointer-events: none;
    transition: opacity 0.3s;
    text-shadow: 1px 1px 2px black;
}

.note-indicator.hidden {
    opacity: 0;
}

/* Mouse Hide */
body.hide-cursor,
body.hide-cursor * {
    cursor: none !important;
}

/* --- Side Panel --- */
.side-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: 500px !important;
    max-width: 100vw;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #333;
    animation: slideInRight 0.3s ease-out;
}

.side-panel.is-fullscreen {
    width: 100% !important;
}

.side-panel.is-fullscreen .masonry {
    column-count: auto;
    column-width: 250px;
}

.fullscreen-only-title {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    max-width: 40%;
    text-overflow: ellipsis;
}

.side-panel.is-fullscreen .fullscreen-only-title {
    display: block;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.side-panel .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    background: rgba(20, 20, 20, 0.95);
    width: 100%;
    min-height: 60px;
    position: relative;
    /* For absolute centering */
}

.header-title {
    color: white;
    font-size: 1.3em;
    font-weight: bold;
    white-space: nowrap;
    margin-right: 15px;
    transition: all 0.3s ease;
}

.header-controls {
    display: flex;
    align-items: center;
    flex-grow: 1;
    justify-content: flex-end;
    gap: 10px;
}

.panel-dropdown {
    background: #2a2a2a;
    color: #eee;
    border: 1px solid #444;
    padding: 8px 15px;
    border-radius: 20px;
    /* Modern Pill Shape */
    font-size: 0.95em;
    max-width: 200px;
    cursor: pointer;
    outline: none;
    appearance: none;
    /* Remove default arrow */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
    padding-right: 35px;
    transition: all 0.2s;
}

.panel-dropdown:hover {
    background-color: #333;
    border-color: #666;
}

.panel-dropdown:disabled {
    color: #777;
    border-color: #333;
}

.panel-close-btn {
    background: #333 !important;
    color: white !important;
    border: 1px solid #555 !important;
    padding: 8px 15px !important;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    min-width: 40px;
}

.panel-close-btn:hover {
    background: #555 !important;
}

.masonry-scroll-container {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    padding: 20px;
}

.masonry {
    column-count: 2;
    column-gap: 15px;
}

@media (max-width: 600px) {
    .masonry {
        column-count: 1;
    }
}

.photo-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
    break-inside: avoid;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
    cursor: pointer;
    background: #222;
    border: 2px solid transparent;
}

.photo-item:hover {
    transform: scale(1.02);
    border-color: #007bff;
}

.photo-item img {
    display: block;
    width: 100%;
    height: auto;
}

/* --- Modals --- */
.overlay-modal:not(.side-panel) {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.overlay-content {
    background: #f2f2f2;
    /* Light Gray Page for Assistant */
    padding: 40px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    text-align: left;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #333;
}

.overlay-content h2 {
    text-align: center;
    margin-top: 0;
}

.extended-content {
    max-width: 900px;
}

#meta-album-title {
    font-size: 2.5em;
    font-weight: 800;
    margin-bottom: 15px;
    line-height: 1.1;
    text-align: center;
}

#modal-music-box {
    background-color: #f0f0f0;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid #ddd;
    color: #000;
    text-align: center;
}

#detail-exif {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-family: monospace;
    font-size: 0.9em;
    color: #555;
}

.exif-item {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
}

.close-overlay-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
    font-size: 1.1em;
}

.overlay-modal:not(.side-panel) .close-overlay-btn,
.overlay-content>div[style*="margin-top"] {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.action-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1em;
    transition: opacity 0.2s;
}

.action-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

/* --- ASSISTANT MODAL --- */
.assistant-tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px;
    font-size: 1.1em;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
}

.tab-btn.active {
    border-bottom: 3px solid #007bff;
    color: #007bff;
    font-weight: bold;
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

.option-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #eee;
    cursor: pointer;
}

.toggle-row:hover {
    border-color: #ccc;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    background: #ffffff;
    /* White Input Background */
}

/* NEW: Input with Counter */
.input-with-counter {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-counter input {
    flex-grow: 1;
}

.input-with-counter .badge {
    background: #6c757d;
    /* Gray Badge */
    color: white;
    padding: 5px 15px;
    /* Increased Padding */
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}

.assistant-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.link-preview {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.link-preview input {
    flex-grow: 1;
    padding: 10px;
    background: #ffffff;
    /* White Input */
    border: 1px solid #ccc;
    color: #333;
    font-family: monospace;
}

.link-preview button {
    background: #007bff;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.link-preview button:hover {
    background: #0056b3;
}

/* --- Help Columns --- */
.help-columns {
    display: flex;
    gap: 40px;
    justify-content: space-between;
    margin-bottom: 20px;
}

.help-col {
    flex: 1;
}

.clickable-help {
    list-style: none;
    padding: 0;
    text-align: left;
}

.clickable-help li {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.clickable-help li:hover {
    background-color: #f0f8ff;
    color: #007bff;
    font-weight: bold;
}

.clickable-help strong {
    display: inline-block;
    min-width: 120px;
}

/* --- Toast --- */
#toast-container {
    position: fixed;
    bottom: 15%;
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 9999;
    pointer-events: none;
}

.toast-message {
    background: rgba(80, 80, 80, 0.7);
    color: white;
    padding: 20px 40px;
    border-radius: 50px;
    margin-top: 10px;
    opacity: 0;
    font-size: 1.8em;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.toast-message.big {
    font-size: 2.5em;
    padding: 30px 60px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.toast-message.show {
    opacity: 1;
}

/* --- Private Overlay --- */
.private-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #111;
    color: #fff;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.private-box {
    text-align: center;
    background: #222;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    border: 1px solid #444;
}

.private-box h1 {
    margin: 0 0 10px;
    color: #ff4757;
}

/* --- End Screen List --- */
.album-list-container {
    background-color: #f0f0f0;
    padding: 20px;
    border-radius: 8px;
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid #ddd;
}

ul.end-album-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul.end-album-list li {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    font-size: 1.1em;
}

ul.end-album-list li:last-child {
    border-bottom: none;
}

ul.end-album-list li.current {
    font-weight: bold;
    color: #333;
    background-color: rgba(0, 0, 0, 0.05);
    cursor: default;
    border-left: 4px solid #333;
    padding-left: 10px;
}

ul.end-album-list a {
    color: #007bff;
    text-decoration: none;
    display: block;
    width: 100%;
    padding: 2px 5px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

ul.end-album-list a:hover {
    text-decoration: none;
    background-color: #e2e6ea;
    color: #0056b3;
}

ul.end-album-list a.keyboard-selected {
    background-color: #007bff !important;
    color: #fff !important;
    font-weight: bold;
    outline: none;
}