@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap'); /* For a retro terminal feel */

:root {
    --bg-color: #0d0d0d;
    --primary-color: #00ff00; /* Neon green */
    --accent-color: #00ffff; /* Neon cyan */
    --text-color: #c0c0c0;
    --border-color: #333;
    --glow-strength: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
    --incognito-color: #9400d3; /* Dark violet */
    --incognito-glow: 0 0 10px var(--incognito-color), 0 0 20px var(--incognito-color);
}

body {
    font-family: 'VT323', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto; /* Allow vertical scrolling for the whole page */
}

.browser-wrapper {
    width: 90%;
    max-width: 900px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

.tab-bar {
    display: flex;
    background-color: #0a0a0a;
    border: 2px solid var(--primary-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    box-shadow: var(--glow-strength);
    height: 40px;
    box-sizing: border-box;
}

.tabs-container {
    display: flex;
    flex-grow: 1;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
}

.tabs-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, Opera */
}

.tab {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    background-color: #1a1a1a;
    border-right: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.tab:hover {
    background-color: #2a2a2a;
}

.tab.active {
    background-color: var(--bg-color);
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    box-shadow: inset 0 -2px 5px var(--primary-color);
    z-index: 1;
}

.tab.incognito {
    background-color: #1e1a2a; /* Darker, purplish background */
    border-right-color: #4b0082;
}

.tab.incognito.active {
    background-color: var(--bg-color);
    color: var(--incognito-color);
    border-bottom-color: var(--incognito-color);
    box-shadow: inset 0 -2px 5px var(--incognito-color);
}

.tab .close-tab-button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2em;
    margin-left: 10px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s ease;
}

.tab .close-tab-button:hover {
    color: #ff0000;
}

.new-tab-button {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    padding: 0 15px;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 1.5em;
    line-height: 1;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    transition: background-color 0.3s ease;
}

.new-tab-button:hover {
    background-color: var(--primary-color);
    box-shadow: none;
}

.browser-container {
    background-color: #1a1a1a;
    border: 2px solid var(--primary-color);
    border-top: none; /* Connects to tab bar */
    box-shadow: var(--glow-strength);
    width: 100%; /* Occupy full width of wrapper */
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    flex-grow: 1; /* Allows container to take available space */
}

.browser-bar {
    display: flex;
    padding: 10px;
    background-color: #0a0a0a;
    border-bottom: 1px solid var(--primary-color);
    align-items: center;
    gap: 10px;
}

#url-input {
    flex-grow: 1;
    background-color: #050505;
    border: 1px solid var(--accent-color);
    color: var(--primary-color);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: 'VT323', monospace;
    font-size: 1em;
    outline: none;
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    transition: box-shadow 0.3s ease;
    margin: 0; /* Remove potential default margins */
}

#url-input:focus {
    box-shadow: 0 0 8px var(--accent-color), 0 0 15px rgba(0, 255, 255, 0.7);
}

.action-button {
    background-color: var(--primary-color);
    color: var(--bg-color);
    border: none;
    padding: 8px 15px;
    margin-left: 0; /* Changed from 10px */
    border-radius: 4px;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 1em;
    text-transform: uppercase;
    box-shadow: var(--glow-strength);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

.action-button:hover {
    background-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
}

.action-button.icon-button {
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-button.icon-button svg {
    width: 24px;
    height: 24px;
}

.upload-button, .history-button {
    display: inline-block;
    background-color: #555; /* Neutral button color */
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 1em;
    text-transform: uppercase;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.upload-button:hover, .history-button:hover {
    background-color: #777;
    border-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
}

.menu-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    background-color: #1a1a1a;
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 100;
    min-width: 180px;
    overflow: hidden;
}

.dropdown-menu a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-family: 'VT323', monospace;
    font-size: 1em;
    transition: background-color 0.2s, color 0.2s;
}

.dropdown-menu a:hover {
    background-color: #333;
    color: var(--primary-color);
}

.browser-screen {
    position: relative;
    width: 100%;
    min-height: 400px;
    background-color: #050505;
    overflow: hidden;
    border-radius: 0 0 8px 8px;
    box-sizing: border-box;
}

.browser-content {
    padding: 20px;
    word-wrap: break-word;
    color: var(--text-color);
    font-size: 0.95em;
    line-height: 1.6;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    transition: filter 0.1s ease-out; /* For glitch effects */
}

/* Style for simulated content */
.browser-content h1, .browser-content h2, .browser-content h3 {
    color: var(--primary-color);
    text-shadow: var(--glow-strength);
    margin-top: 1em;
    margin-bottom: 0.5em;
}
.browser-content p {
    margin-bottom: 1em;
}
.browser-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px 0;
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}
.browser-content a {
    color: var(--accent-color);
    text-decoration: none;
}
.browser-content a:hover {
    text-decoration: underline;
    text-shadow: 0 0 5px var(--accent-color);
}

.controls-panel {
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap on smaller screens */
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
    align-items: center;
}

.language-settings-content {
    padding: 20px 0;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.lang-label {
    color: var(--primary-color);
    font-size: 1em;
    font-family: 'VT323', monospace;
    text-shadow: var(--glow-strength);
}

#lang-select {
    /* Inherits action-button styles, but adjust as needed */
    padding: 8px 12px;
    margin-left: 0; /* Remove extra margin from action-button */
    text-transform: none; /* Don't uppercase language names */
    background-color: #050505;
    color: var(--primary-color);
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    outline: none;
    cursor: pointer;
}

#lang-select:hover {
    background-color: #1a1a1a;
    box-shadow: 0 0 8px var(--primary-color);
}

/* Hacked State Styles */
.browser-screen.hacked {
    border-color: #ff0000; /* Red for hack */
    box-shadow: 0 0 15px #ff0000, 0 0 30px #ff0000, 0 0 45px #ff0000;
}

.browser-content.hacked {
    animation: glitch 0.5s infinite alternate;
    filter: hue-rotate(90deg) saturate(1.5) contrast(1.2);
}

.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.browser-screen.hacked .glitch-overlay {
    opacity: 1;
    animation: scanline 0.1s infinite alternate, noise 0.1s steps(2) infinite;
    background-image: 
        linear-gradient(rgba(0, 255, 0, 0.05) 50%, transparent 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.03) 50%, transparent 50%);
    background-size: 100% 4px, 4px 100%;
}

@keyframes glitch {
    0% {
        transform: translate(0);
        text-shadow: 
            2px 0 0 rgba(255, 0, 0, 0.7),
            -2px 0 0 rgba(0, 255, 255, 0.7);
    }
    20% {
        transform: translate(-5px, 5px);
        text-shadow: 
            -2px 0 0 rgba(255, 0, 0, 0.7),
            2px 0 0 rgba(0, 255, 255, 0.7);
    }
    40% {
        transform: translate(5px, -5px);
        text-shadow: 
            2px 0 0 rgba(0, 255, 255, 0.7),
            -2px 0 0 rgba(255, 0, 0, 0.7);
    }
    60% {
        transform: translate(-5px, -5px);
        text-shadow: 
            -2px 0 0 rgba(0, 255, 255, 0.7),
            2px 0 0 rgba(255, 0, 0, 0.7);
    }
    80% {
        transform: translate(5px, 5px);
        text-shadow: 
            2px 0 0 rgba(255, 0, 0, 0.7),
            -2px 0 0 rgba(0, 255, 255, 0.7);
    }
    100% {
        transform: translate(0);
        text-shadow: 
            -2px 0 0 rgba(255, 0, 0, 0.7),
            2px 0 0 rgba(0, 255, 255, 0.7);
    }
}

@keyframes scanline {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(100%);
    }
}

@keyframes noise {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 100% 100%;
    }
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 100; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.8); /* Black w/ opacity */
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1a1a1a;
    margin: auto;
    padding: 30px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: var(--glow-strength);
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

.modal-content h2 {
    color: var(--primary-color);
    text-shadow: var(--glow-strength);
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

.modal-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.modal-tab-button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-color);
    padding: 10px 15px;
    font-family: 'VT323', monospace;
    font-size: 1.1em;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, box-shadow 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; /* Overlap the container's border */
    text-transform: uppercase;
}

.modal-tab-button:hover {
    background-color: #2a2a2a;
    color: var(--accent-color);
}

.modal-tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    box-shadow: 0 2px 5px -2px var(--primary-color);
}

.modal .close-button {
    color: var(--accent-color);
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 3em;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal .close-button:hover,
.modal .close-button:focus {
    color: #ff0000;
    text-decoration: none;
    cursor: pointer;
}

.image-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px; /* For scrollbar */
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 5px;
}

.image-item {
    position: relative;
    border: 1px solid var(--accent-color);
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    background-color: #050505;
    display: flex; /* Use flex to align content and uploader */
    flex-direction: column;
}

.image-item.selected {
    border-color: var(--primary-color);
    box-shadow: var(--glow-strength);
    transform: scale(1.05);
}

.image-item img {
    width: 100%;
    height: 100px; /* Fixed height for consistency */
    object-fit: cover;
    display: block;
}

.image-item .actions-overlay {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 5px;
    background: linear-gradient(to bottom left, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 60%); /* Adjusted gradient direction */
}

.image-item .icon-action-button {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 1.2em; /* Adjust for icon size */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    padding: 0;
}

.image-item .delete-image-button {
    color: #ffb8b8;
    border-color: #ffb8b8;
}

.image-item .delete-image-button:hover {
    opacity: 1;
    background-color: #ff0000;
    color: white;
    border-color: white;
}

.image-item .add-to-gallery-button {
    color: #b8e9ff;
    border-color: #b8e9ff;
}

.image-item .add-to-gallery-button:hover {
    opacity: 1;
    background-color: var(--accent-color);
    color: var(--bg-color);
    border-color: white;
}

.image-item .default-image-button {
    color: #a0a0a0;
    border-color: #a0a0a0;
}

.image-item .default-image-button:hover {
    color: #ffff00;
    border-color: #ffff00;
}

.image-item .default-image-button.is-default {
    color: #ffff00; /* Yellow for star */
    border-color: #ffff00;
    opacity: 1;
    text-shadow: 0 0 5px #ffff00;
}

.image-item .image-uploader {
    font-size: 0.75em;
    color: var(--text-color);
    padding: 5px;
    background-color: #1a1a1a;
    border-top: 1px solid var(--border-color);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-list + .action-button { /* Style for ADD NEW IMAGE button below image list */
    margin-left: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

#add-new-image-container {
    width: 100%;
}

#add-new-image-container .action-button {
    margin-left: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
}

#history-list li {
    background-color: #050505;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--accent-color);
    transition: background-color 0.2s ease;
}

#history-list li.incognito-notice {
    justify-content: center;
    color: var(--incognito-color);
    border-color: var(--incognito-color);
    background-color: #1e1a2a;
    font-size: 1.1em;
}

#history-list li:hover {
    background-color: #101010;
}

#history-list li span {
    flex-grow: 1;
    color: var(--text-color);
    font-size: 0.9em;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

#history-list li span:hover {
    color: var(--primary-color);
}

#history-list li .delete-history-button {
    background-color: rgba(255, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background-color 0.2s ease;
}

#history-list li .delete-history-button:hover {
    background-color: #ff0000;
}

#clear-all-history-button {
    margin-left: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    background-color: #cc0000;
    box-shadow: 0 0 5px #cc0000;
}

#clear-all-history-button:hover {
    background-color: #ff0000;
    box-shadow: 0 0 10px #ff0000;
}

/* Modal animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .action-button, .upload-button, .history-button {
        width: 100%;
        margin-left: 0;
        margin-bottom: 10px; /* Add some space between stacked buttons */
    }

    .language-selector {
        width: 100%;
        justify-content: space-between;
    }

    #lang-select {
        flex-grow: 1;
        margin-left: 0;
    }

    .browser-bar {
        flex-wrap: wrap;
    }

    #url-input {
        margin-bottom: 10px;
        width: 100%;
        order: 1; /* Make it appear on top on mobile */
        flex-basis: 100%; /* Full width */
    }

    #go-button {
        flex-grow: 1;
        order: 2;
    }

    #home-button {
        order: 2;
    }

    .menu-container {
        order: 2;
    }
}