﻿body {
  /*padding: 50px;*/
  /*font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;*/
}

a {
  color: #00B7FF;
}

body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    height: 100vh;
    background: #1e1e1e;
    color: #fff;
    overflow: hidden;
    user-select: none;
}

#sidebar {
    width: 290px;
    background: #252526;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease-in-out;
    position: relative;
}

    #sidebar.collapsed {
        width: 110px;
    }

/* top menu with button */
sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid #333;
    min-height: 32px;
}

/* for phone like devices */
@media (max-width: 768px) {
    html, body {
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
        position: relative;
    }

    #sidebar {
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
        touch-action: manipulation; 
    }

    #folder-list {
        height: calc(100dvh - 60px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px !important;
        box-sizing: border-box;
    }

    #gallery {
        height: calc(110dvh - 60px) !important; /* was 100vh before */
        overflow-y: auto !important; /* only allow scroll for photos only */
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
}

/* precaution for button hiding unintentionally */
#sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 12px 0;
}

#sidebar.collapsed .toggle-menu-btn {
    width: 100%;
    text-align: center;
    font-size: 20px;
}

.toggle-menu-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
}

    .toggle-menu-btn:hover {
        background: #333334;
        color: #fff;
    }

#folder-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 5px;
}

#gallery {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* blocks sidescrolling */
    padding: 25px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    align-content: start;
    max-width: 100%; /* prevents grid to be wider than remaining screenspace */
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}

#sidebar.collapsed ~ #gallery,
#sidebar.collapsed + #gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.folder-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: none;
    border: none;
    color: #aaa;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    overflow: hidden;
    min-width: 0; /* seems optional but whatever */
}

.folder-btn span {
    margin-left: 10px;
    display: block !important;
    width: calc(100% - 30px);
    text-align: left;
    transition: opacity 0.15s;
}

.folder-btn span,
.folder-btn span * {
    display: block !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    width: 100%;
    margin: 0;
    padding: 0;
}

#sidebar.collapsed .folder-btn span {
    display: inline-block;
    max-width: 50px; /* bound space - exceeding words showed as three dots */
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

#sidebar.collapsed .folder-btn {
    justify-content: flex-start;
    padding: 10px 12px;
}

.folder-btn:hover {
    background: #333334;
    color: #fff;
}

.folder-btn.active {
    background: #0078d4;
    color: #fff;
    font-weight: 600;
}

photo-card {
    background: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 190px;
    border: 1px solid #3c3c3c;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}

img, .photo-card, #lightbox {
    -webkit-touch-callout: none !important;
    user-select: none !important;
}

#pwa-preview-img {
    -webkit-touch-callout: default !important; /* Įjungia standartinį „Save Image“ meniu iOS */
    -webkit-user-select: auto !important;
    user-select: auto !important;
    touch-action: auto !important;
}

img {
    -webkit-user-drag: none !important; /* Užkerta kelią vilkimui „Safari“ / „iOS“ */
    user-drag: none !important; /* Užkerta kelią vilkimui „Chrome“ / „Android“ */
}

.photo-card:hover {
    transform: scale(1.02);
    border-color: #555;
}

.img-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #121212;
    overflow: hidden;
    padding: 5px;
}

.photo-card img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

    .photo-card img.loaded {
        opacity: 1;
    }

.photo-name {
    font-size: 11px;
    padding: 8px;
    text-align: center;
    color: #aaa;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

/* loading Shimmer Effect */
.photo-card.loading .img-wrapper {
    background: linear-gradient(90deg, #121212 25%, #252526 50%, #121212 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite linear;
}

@keyframes loading-shimmer {
    0 {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* lightbox modal */
#lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 10, 0.96);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    touch-action: none !important;
}

#lightbox-img {
    max-width: 92vw;
    max-height: 84vh;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    /* 🌟 PRIDĖTA: Švelni 0.2s animacija, kad nuotrauka išryškėtų sklandžiai, o ne grubiai */
    transition: filter 0.2s ease-in-out, opacity 0.2s ease-in-out;
    opacity: 1;
    filter: blur(0px) brightness(100%);
}

    /* blur of previously loaded image */
    #lightbox-img.loading-next {
        opacity: 0.4;
        filter: blur(20px) brightness(70%); /* blur for previous image */
    }

/* thumbnail as placeholder */
.lightbox-bg-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 92vw;
    max-height: 84vh;
    object-fit: contain;
    z-index: -1;
    filter: blur(0px) brightness(90%); /* clear new image */
    opacity: 0;
    transition: opacity 0.15s ease;
}

#lightbox-title {
    margin-top: 15px;
    color: #fff;
    font-size: 13px;
    background: rgba(0,0,0,0.7);
    padding: 6px 18px;
    border-radius: 20px;
    border: 1px solid #444;
    z-index: 10; /* clear text over images layer */
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    background: none;
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    opacity: 0.6;
}

    .close-btn:hover {
        opacity: 1;
        color: #ff4d4d;
    }

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.04);
    border: none;
    color: white;
    font-size: 24px;
    padding: 18px 22px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    z-index: 10000;
}

    .nav-btn:hover {
        background: rgba(255,255,255,0.15);
    }

#prev-btn {
    left: 20px;
}

#next-btn {
    right: 20px;
}

/*new*/
.custom-context-menu {
    position: fixed; /* Lieka prikabintas ekrano koordinatese */
    z-index: 999999 !important; /* Griežtai iškeliame į patį priekį virš lightbox */
    background-color: #ffffff !important; /* Užtikriname nepermatomą baltą foną */
    border: 1px solid #dddddd;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 6px 0;
    width: 220px;
}

    .custom-context-menu a, .custom-context-menu button {
        display: block;
        width: 100%;
        padding: 10px 14px;
        text-align: left;
        color: #333333 !important;
        text-decoration: none;
        font-family: 'Segoe UI', sans-serif;
        font-size: 14px;
        background: none;
        border: none;
        cursor: pointer;
        box-sizing: border-box;
    }

        .custom-context-menu a:hover, .custom-context-menu button:hover {
            background-color: #f5f5f5;
            color: #000000;
        }

/* naršyklės meniu pasirinkimo stilius */
#show-native-menu {
    color: #777777;
    font-style: italic;
}

#gallery, #lightbox, #lightbox-img, .photo-card, .img-wrapper, #lightbox-title {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.gallery-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    width: 100%;
    min-height: 200px;
    color: #FFF;
    font-size: 1.1rem;
    font-family: sans-serif;
}

.gallery-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    width: 100%;
    min-height: 200px;
    color: #888;
    font-size: 1.1rem;
    font-family: sans-serif;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}