/* Basic styles for PokeSnap-Dex */
body {
    font-family: Arial, sans-serif;
    background-color: #fafafa;
    margin: 0;
    padding: 0;
    text-align: center;
    transition: background-color 0.3s;
}

.dark-mode body {
    background-color: #222;
}

#app-container {
    max-width: 668px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
}

.header-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #990000;
    border-radius: 20px 20px 0 0;
    transition: background-color 0.3s;
    width: 100%;
}

.dark-mode .header-container {
    background-color: #000;
}

header {
    color: white;
    padding: 20px;
    border-radius: 20px 20px 0 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.6);
}

.header-divider {
    height: 6px;
    background: linear-gradient(to bottom, #a0a0a0 0%, #606060 100%);
}

.footer-divider {
    height: 6px;
    background: linear-gradient(to bottom, #a0a0a0 0%, #606060 100%);
    position: fixed;
    bottom: 20px;
    z-index: 1000;
    width: calc(100vw - 40px);
    max-width: 668px;
    margin: 0 auto;
}

.footer {
    border-radius: 0 0 20px 20px;
    height: 20px;
    transition: background-color 0.3s;
    position: fixed;
    bottom: 0;
    z-index: 1000;
    width: calc(100vw - 40px);
    max-width: 668px;
    margin: 0 auto;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -20px;
    right: -20px;
    bottom: 0;
    background: white;
    z-index: -1;
}

.footer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #990000;
    border-radius: 0 0 20px 20px;
    z-index: 1;
}

.dark-mode .footer {
    background-color: #000;
}

.dark-mode .footer::before {
    background: white;
}

.dark-mode .footer::after {
    background: #000;
}

.header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 10px;
    gap: 20px;
}

.header-controls > * {
    margin: 0;
}

#captured-count {
    background-color: #990000;
    color: white;
    border: 2px solid #990000;
    padding: 8px 16px;
    font-weight: bold;
    font-size: 1.2em;
    cursor: pointer;
    margin: 0;
    width: 180px;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.2s;
    border-top: 2px solid #FF3333;
    border-left: 2px solid #FF3333;
    border-bottom: 2px solid #990000;
    border-right: 2px solid #990000;
    outline: 0.25px solid white;
}

#captured-count:hover {
    background-color: #AA0000;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#captured-count:active {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: translateY(2px);
}

.dark-mode #captured-count {
    background-color: #333;
    border-color: #555;
    color: white;
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
    border-top: 2px solid #666;
    border-left: 2px solid #666;
    border-bottom: 2px solid #000;
    border-right: 2px solid #000;
    outline: 0.25px solid white;
}

.dark-mode #captured-count:hover {
    background-color: white;
    color: #333;
    box-shadow: 0 6px 12px rgba(255, 255, 255, 0.2);
}

.dark-mode #captured-count:active {
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

#search-input {
    padding: 8px;
    margin: 0;
    width: 180px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}

.dark-mode #search-input {
    background-color: #555;
    color: white;
    border-color: #777;
}

.dark-mode header {
    background-color: #000;
}

#theme-toggle {
    background-color: white;
    color: #990000;
    border: 2px solid #990000;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 5px;
    margin: 0;
    width: 180px;
    transition: all 0.3s;
    border-top: 2px solid #FF3333;
    border-left: 2px solid #FF3333;
    border-bottom: 2px solid #990000;
    border-right: 2px solid #990000;
    outline: 0.25px solid white;
}

#theme-toggle:hover {
    background-color: #AA0000;
    color: white;
}

.dark-mode #theme-toggle {
    background-color: #555;
    color: white;
    border: 2px solid #555;
    border-top: 2px solid #666;
    border-left: 2px solid #666;
    border-bottom: 2px solid #000;
    border-right: 2px solid #000;
    outline: 0.25px solid white;
}

.dark-mode #theme-toggle:hover {
    background-color: white;
    color: #333;
}

#power-indicator {
    position: absolute;
    right: 20px;
    top: 30px;
    width: 12px;
    height: 12px;
    background-color: #48BB78;
    border-radius: 50%;
    box-shadow: 0 0 5px #48BB78, 0 0 10px #48BB78, 0 0 15px #48BB78, 0 0 20px #48BB78;
    margin: 0;
}

#prev-variant, #next-variant, #close-gallery {
    background-color: #007BFF;
    color: white;
    border: 2px solid #007BFF;
    padding: 5px 10px;
    font-size: 0.8em;
    width: 70px;
    cursor: pointer;
    border-radius: 5px;
}

.dark-mode #prev-variant, .dark-mode #next-variant, .dark-mode #close-gallery {
    background-color: #555;
    color: white;
    border: 2px solid #555;
}

.dark-mode .entry {
    background-color: #000;
    color: #ccc;
}

.dark-mode #dex-container {
    background-color: #2C3539;
}

#dex-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(192px, 1fr));
    gap: 6px;
    padding: 20px;
    height: calc(100vh - 100px);
    overflow-y: auto;
    background-color: #001a3d;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

#dex-container.flex-layout {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 20px;
    max-height: none;
    overflow-y: visible;
}

.entry {
    width: 192px;
    height: 192px;
    border-radius: 10%;
    background-color: #000;
    margin: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    color: #fff;
    font-weight: 300;
    text-align: center;
    line-height: 1.2;
    font-size: calc(0.139 * 192px);
    word-break: break-word;
}

@media (max-width: 1200px) {
    .entry {
        width: 160px;
        height: 160px;
        margin: 5px;
        font-size: calc(0.139 * 160px);
    }
    #dex-container {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 960px) {
    .entry {
        width: 128px;
        height: 128px;
        margin: 4px;
        font-size: calc(0.139 * 128px);
    }
    #dex-container {
        grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    }
}

@media (max-width: 720px) {
    .entry {
        width: 96px;
        height: 96px;
        margin: 3px;
        font-size: calc(0.139 * 96px);
    }
    #dex-container {
        grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    }
}

@media (max-width: 480px) {
    .entry {
        width: 64px;
        height: 64px;
        margin: 2px;
        font-size: calc(0.139 * 64px);
    }
    #dex-container {
        grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    }
}

.entry img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10%;
}

.entry.empty {
    background-color: #ccc;
    color: #666;
    font-weight: bold;
}

#gallery {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#gallery.hidden {
    display: none;
}

#gallery-image {
    height: 50%;
    width: 50%;
    object-fit: contain;
}

#gallery-name {
    color: white;
    font-size: 1.5em;
    margin: 10px 0;
    text-align: center;
}

.gallery-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.gallery-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive adjustments for gallery */
@media (min-width: 768px) {
    #gallery-image {
        max-height: 60vh;
        margin-top: 20px;
    }
}

button {
    margin: 10px;
    padding: 10px 20px;
    background-color: #000;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

#toggle-show-all {
    background-color: #004085;
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, box-shadow 0.2s;
    border-top: 2px solid #3366CC;
    border-left: 2px solid #3366CC;
    border-bottom: 2px solid #002244;
    border-right: 2px solid #002244;
}

#toggle-show-all:hover {
    background-color: #002752;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#toggle-show-all:active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transform: translateY(1px);
}

.dark-mode #toggle-show-all {
    background-color: #000;
    border-top: 2px solid #333;
    border-left: 2px solid #333;
    border-bottom: 2px solid #000;
    border-right: 2px solid #000;
}

.dark-mode #toggle-show-all:hover {
    background-color: #333;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    max-height: 70%;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

#captured-list {
    list-style-type: none;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
}

#captured-list.show-all {
    max-height: none;
    overflow-y: visible;
}

#captured-list li {
    padding: 8px;
    border-bottom: 1px solid #ddd;
}

#captured-list li:hover {
    background-color: #f0f0f0;
}

.dark-mode .modal-content {
    background-color: #333;
    color: white;
}

.dark-mode #captured-list li:hover {
    background-color: #555;
}

@media (max-width: 768px) {
    header {
        padding: 20px;
    }
    .header-controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }
    .header-controls > * {
        width: auto;
        font-size: 2.5vw;
    }
    #captured-count {
        padding: 2px 4px;
        font-size: 2.5vw;
        flex: 1;
        white-space: nowrap;
        margin-right: 0;
        order: 1;
    }
    #search-input {
        padding: 2px 4px;
        flex-basis: 100%;
        font-size: 2.5vw;
        margin-right: 0;
        order: 3;
    }
    #theme-toggle {
        padding: 1px 1px;
        font-size: 2.5vw;
        flex: 1;
        order: 2;
    }
    .gallery-buttons {
        gap: 5px;
    }
    .gallery-buttons button {
        padding: 5px 10px;
        font-size: 0.8em;
        width: 70px;
    }
    .gallery-buttons button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
    #captured-count {
        padding: 6.4px 12.8px;
        font-size: 0.96em;
    }
    #search-input {
        padding: 6.4px;
        font-size: 0.8em;
    }
    #theme-toggle {
        padding: 8px 12px;
        font-size: 0.8em;
    }
}

@media (orientation: landscape) and (max-width: 768px) {
    #gallery-image {
        height: 40vh;
    }
    #gallery-controls {
        gap: 5px;
    }
    #gallery-controls button {
        width: 60px;
        padding: 5px 8px;
        font-size: 0.7em;
    }
}
