@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

:root {
    --primary: #1a39c4;
    /* lighter blue */
    --primary-hover: #6F86F8;
    /* hover - even lighter */
    --primary-light: rgba(79, 110, 245, 0.12);
    /* subtle light */
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.07);
    --radius: 8px;
    --gradient-primary: linear-gradient(135deg, rgba(79, 110, 245, 1) 0%, rgba(111, 134, 248, 0.9) 40%, rgba(131, 150, 252, 0.75) 100%);
    --gradient-header-dark: linear-gradient(135deg, rgb(0, 28, 110) 0%, rgba(27, 48, 110, 0.95) 45%, rgba(41, 68, 140, 0.9) 100%);
    /* alias for inline styles and theme toggles */
    --primary-color: var(--primary);
    /* text color specifically for the Pengaturan/settings button (light mode default) */
    --settings-text: #000000;
}

.dark-mode {
    --primary: #3b5ef0;
    /* slightly darker for dark mode contrast */
    --primary-hover: #2e4fd0;
    --primary-light: rgba(59, 94, 240, 0.15);
    --gradient-header-dark: linear-gradient(135deg, rgba(1, 30, 133, 0.457) 0%, rgba(15, 28, 70, 0.95) 45%, rgba(28, 50, 105, 0.9) 100%);
    /* ensure inline aliases map to dark-mode colors */
    --primary-color: var(--primary);
    --settings-text: #ffffff;
    --text: #e0e0e0;
    --text-muted: #9e9e9e;
    --bg: #121212;
    --bg-secondary: #1e1e1e;
    --surface: #1e1e1e;
    --surface-hover: #2c2c2c;
    --border: #2c2c2c;
}

* {
    box-sizing: border-box;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    animation: fadeIn 0.5s ease-out;
    position: relative;
    overflow-x: hidden;
}

/* More visible floating blue circles background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(79, 110, 245, 0.12) 0%, rgba(111, 134, 248, 0.06) 40%, transparent 60%),
        radial-gradient(circle at 80% 20%, rgba(111, 134, 248, 0.15) 0%, rgba(131, 150, 252, 0.08) 40%, transparent 60%),
        radial-gradient(circle at 40% 40%, rgba(59, 94, 240, 0.10) 0%, rgba(79, 110, 245, 0.05) 40%, transparent 60%);
    animation: floatCircles 20s ease-in-out infinite;
}

@keyframes floatCircles {

    0%,
    100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.4;
    }

    50% {
        transform: translateY(-10px) rotate(45deg);
        opacity: 0.3;
    }
}

/* Individual floating circles */
.floating-circles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.floating-circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 110, 245, 0.25) 0%, rgba(111, 134, 248, 0.15) 30%, rgba(131, 150, 252, 0.08) 60%, transparent 100%);
    box-shadow: 0 0 30px rgba(79, 110, 245, 0.2), inset 0 0 20px rgba(111, 134, 248, 0.1);
    animation: float 15s infinite ease-in-out;
}

.floating-circle:nth-child(1) {
    width: 80px;
    height: 80px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
    animation-duration: 20s;
}

.floating-circle:nth-child(2) {
    width: 120px;
    height: 120px;
    top: 60%;
    left: 80%;
    animation-delay: -5s;
    animation-duration: 25s;
}

.floating-circle:nth-child(3) {
    width: 60px;
    height: 60px;
    top: 80%;
    left: 20%;
    animation-delay: -10s;
    animation-duration: 18s;
}

.floating-circle:nth-child(4) {
    width: 100px;
    height: 100px;
    top: 30%;
    left: 70%;
    animation-delay: -15s;
    animation-duration: 22s;
}

.floating-circle:nth-child(5) {
    width: 40px;
    height: 40px;
    top: 50%;
    left: 5%;
    animation-delay: -8s;
    animation-duration: 16s;
}

.floating-circle:nth-child(6) {
    width: 90px;
    height: 90px;
    top: 15%;
    left: 60%;
    animation-delay: -12s;
    animation-duration: 24s;
}

.floating-circle:nth-child(7) {
    width: 70px;
    height: 70px;
    top: 70%;
    left: 50%;
    animation-delay: -6s;
    animation-duration: 19s;
}

.floating-circle:nth-child(8) {
    width: 110px;
    height: 110px;
    top: 40%;
    left: 15%;
    animation-delay: -18s;
    animation-duration: 26s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px) translateX(0px) scale(1);
        opacity: 0.8;
    }

    25% {
        transform: translateY(-30px) translateX(20px) scale(1.2);
        opacity: 1;
    }

    50% {
        transform: translateY(-60px) translateX(-10px) scale(0.9);
        opacity: 0.6;
    }

    75% {
        transform: translateY(-20px) translateX(30px) scale(1.1);
        opacity: 0.9;
    }
}

/* Dark mode adjustments for circles */
.dark-mode .floating-circle {
    background: radial-gradient(circle, rgba(59, 94, 240, 0.30) 0%, rgba(47, 79, 208, 0.18) 30%, rgba(79, 110, 245, 0.10) 60%, transparent 100%);
    box-shadow: 0 0 40px rgba(59, 94, 240, 0.25), inset 0 0 25px rgba(47, 79, 208, 0.15);
}

.dark-mode body::before {
    background-image:
        radial-gradient(circle at 20% 80%, rgba(59, 94, 240, 0.15) 0%, rgba(47, 79, 208, 0.08) 40%, transparent 70%),
        radial-gradient(circle at 80% 20%, rgba(47, 79, 208, 0.18) 0%, rgba(79, 110, 245, 0.10) 40%, transparent 70%),
        radial-gradient(circle at 40% 40%, rgba(79, 110, 245, 0.12) 0%, rgba(59, 94, 240, 0.06) 40%, transparent 70%);
}

header {
    background: rgba(255, 255, 255, 0.8);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease, border 0.3s ease;
}

.dark-mode header {
    background: rgba(18, 18, 18, 0.8);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.logo {
    font-family: Montserrat;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: inline-block;
}

.search-container {
    display: flex;
    flex: 1;
    max-width: 500px;
    gap: 0.75rem;
}

#searchBar,
#sortOptions {
    font-family: Montserrat;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease-in-out;
}

#searchBar:focus,
#sortOptions:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

#searchBar::placeholder {
    color: var(--text-muted);
}

#sortOptions {
    cursor: pointer;
    min-width: 130px;
}

.control-buttons button {
    font-family: Montserrat;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s ease-in-out;
    width: 44px;
    height: 44px;
}

.control-buttons button:hover {
    background: var(--surface-hover);
    color: var(--primary);
}

/* Header settings button (theme-aware) */
#settings {
    background: transparent;
    color: var(--settings-text);
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#settings:hover {
    filter: brightness(1.05);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    animation: fadeInUp 0.5s ease-out forwards;
}

#container,
#featuredZones {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

/* Ensure the loading placeholder uses Montserrat */
#container {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color: white !important;
}

.zone-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.zone-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg), 0 0 20px var(--primary-light);
}

.zone-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: var(--bg-secondary);
    transition: transform 0.3s ease;
}

.zone-item:hover img {
    transform: scale(1.03);
}

.zone-item button {
    font-family: Montserrat;
    background: transparent;
    color: var(--text);
    border: 0;
    padding: 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    text-align: center;
    transition: color 0.3s ease;
    margin-top: auto;
}

.zone-item:hover button {
    color: var(--primary);
}

#zoneViewer {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
}

.zone-header {
    background: var(--gradient-header-dark);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
}

#zoneName {
    font-size: 1.25rem;
    font-weight: 700;
}

#zoneAuthor {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

#zoneAuthor:hover {
    color: white;
}

.zone-controls button {
    font-family: Montserrat;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease;
}

.zone-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

#zoneFrame {
    flex-grow: 1;
    border: none;
    width: 100%;
    height: 100%;
}

#popupOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.popup {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    border: 1px solid var(--border);
    animation: fadeInUp 0.3s ease forwards;
}

.popup-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#popupTitle {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

#popupClose {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

#popupClose:hover {
    color: var(--text);
}

#popupBody {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 70vh;
}

/* Styled form controls inside popups */
#popupBody label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 700;
}

#popupBody input[type="text"],
#popupBody input[type="url"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 0.95rem;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#popupBody input[type="text"]:focus,
#popupBody input[type="url"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

#popupBody input::placeholder {
    color: var(--text-muted);
}

/* smaller helper spacing for popup fields */
.popup-field-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.popup-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.settings-button {
    font-family: Montserrat;
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--gradient-primary);
    color: white;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
}

.settings-button:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.1);
}

.settings-button:active {
    transform: translateY(-1px);
    filter: brightness(0.9);
}

#dark-mode-toggle::before {
    content: '\1F319';
    font-size: 1.2em;
}

#tab-cloak-button::before {
    content: '\1F3AD';
    font-size: 1.2em;
}

footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem 1rem;
    margin-top: 3rem;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary);
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .search-container {
        width: 100%;
    }

    #container,
    #featuredZones {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}