/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    font-family: 'Comfortaa', cursive;
    font-weight: 400;
    font-style: normal;
    font-stretch: normal;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
    text-size-adjust: 100%;
    background: #1a0d2e; /* Match index.html background */
}

/* Spline Viewer Background */
spline-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: auto;
}

/* Main Container */
#container {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2;
    opacity: 0;
    animation: fadeIn 0.5s ease-in-out forwards;
    pointer-events: none;
}

/* Aktifkan pointer events untuk elemen yang perlu interaksi */
.text-input,
input,
button {
    pointer-events: auto;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Text Input Section */
.text-input {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(16, 8, 35, 0.9);
    backdrop-filter: blur(15px);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid #ff69b4;
    position: relative;
    overflow: hidden;
}

.text-input h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: #ff69b4;
    text-shadow: 0 0 10px #ff69b4, 0 0 20px #9400d3, 0 0 30px #4169e1;
    margin-bottom: 10px;
    animation: neonSlideIn 1s ease-out forwards, neonFlicker 6s ease-in-out infinite;
    opacity: 0;
    transform: translateX(-100%);
}

@keyframes neonSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes neonFlicker {
    0%, 100% {
        text-shadow: 0 0 10px #ff69b4, 0 0 20px #9400d3, 0 0 30px #4169e1;
    }
    10%, 30% {
        text-shadow: 0 0 20px #ff69b4, 0 0 40px #9400d3, 0 0 50px #4169e1;
    }
    20% {
        text-shadow: 0 0 5px #ff69b4, 0 0 10px #9400d3, 0 0 15px #4169e1;
    }
}

/* Username and Password Inputs Styling */
input[type="text"],
input[type="password"] {
    width: 100%;
    max-width: 400px;
    padding: 15px;
    margin-top: 20px;
    font-family: 'Comfortaa', cursive;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.7;
    background: rgba(16, 8, 35, 0.9);
    color: #87ceeb;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    resize: none;
    overflow-y: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
    height: 50px;
}

/* CSS untuk mengatasi gaya autofill browser */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px rgba(16, 8, 35, 0.9) inset !important;
    -webkit-text-fill-color: #87ceeb !important;
    caret-color: #87ceeb !important;
    transition: background-color 5000s ease-in-out 0s;
}

input[type="text"]:hover,
input[type="text"]:focus,
input[type="password"]:hover,
input[type="password"]:focus {
    border-color: #9400d3;
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.4);
}

/* Password Input Grid Styling (4 boxes) */
.key-input-grid {
    display: grid;
    grid-template-columns: repeat(5, 50px) auto;
    gap: 10px;
    max-width: 600px;
    margin-top: 20px;
    justify-content: center;
}

.password-input {
    width: 50px;
    height: 50px;
    padding: 10px;
    font-family: 'Comfortaa', cursive;
    font-size: 18px;
    text-align: center;
    background: rgba(16, 8, 35, 0.9);
    color: #87ceeb;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s, box-shadow 0.3s;
    text-transform: uppercase;
}

.password-input:hover,
.password-input:focus {
    border-color: #9400d3;
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.4);
}

/* Button Styling */
button {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.3rem;
    padding: 15px 30px;
    margin: 20px;
    background: rgba(16, 8, 35, 0.9);
    color: #ff69b4;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: color 0.3s, background 0.3s, box-shadow 0.3s;
}

button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 105, 180, 0.3) 10%, transparent 70%);
    animation: neonPulse 1.5s ease-out infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

button:hover::before {
    opacity: 1;
}

button:hover {
    color: #87ceeb;
    background: rgba(148, 0, 211, 0.9);
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.4);
}

/* Modal Styling */
.modal {
    display: none; /* Default hidden */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent background overlay */
    display: flex; /* Use flexbox to center content */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
}

.modal-content {
    background: rgba(16, 8, 35, 0.9);
    backdrop-filter: blur(15px);
    padding: 30px;
    border: 2px solid #ff69b4; /* Default border color */
    border-radius: 15px;
    width: 80%; /* Adjusted width for better responsiveness */
    max-width: 450px; /* Max width */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #87ceeb; /* Default text color */
    font-family: 'Comfortaa', cursive;
    text-align: center;
    animation: modalFadeIn 0.3s ease-out; /* Simple animation */
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

#modalMessage {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

#modalOkayBtn {
    /* Inherits button styles, but can be customized */
    font-size: 1rem;
    padding: 10px 25px;
    margin-top: 0; /* Adjust margin */
}


/* Responsive Design */
@media (max-width: 900px) {
    #container {
        width: 90%;
        margin: 20px auto;
    }

    input[type="text"],
    input[type="password"] {
        max-width: 100%;
    }

    .key-input-grid {
        grid-template-columns: repeat(5, 40px) auto;
        gap: 8px;
    }

    .password-input {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #container {
        padding: 15px;
    }

    .text-input {
        padding: 15px;
        margin-bottom: 30px;
    }

    input[type="text"],
    input[type="password"] {
        max-width: 100%;
        font-size: 14px;
        padding: 12px;
    }

    .key-input-grid {
        grid-template-columns: repeat(5, 30px) auto;
        gap: 6px;
    }

    .password-input {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    button {
        max-width: 100%;
    }
    
    .modal-content {
        padding: 20px;
    }

    #modalMessage {
        font-size: 1rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-clear-button,
input[type="password"]::-webkit-inner-spin-button {
    display: none;
    -webkit-appearance: none;
}

.toggle-visibility {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.key-input-grid .toggle-password-btn {
    width: 50px;
    height: 50px;
    margin-left: 15px; /* Jarak dari password box terakhir */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    font-family: 'Comfortaa', cursive;
    text-align: center;
    line-height: 1;
    letter-spacing: 0.5px;
    padding: 0;
    
    background: rgba(16, 8, 35, 0.95);
    color: #87ceeb;
    border: 2px solid #a92e6c;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.key-input-grid .toggle-password-btn:hover,
.key-input-grid .toggle-password-btn:focus {
    border-color: #d94f8b; /* versi terang dari #a92e6c */
    box-shadow: 0 0 15px rgba(169, 46, 108, 0.5);
}

.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    z-index: 10001;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
