:root {
    --bg-color: #FFFFF0; /* Ivory */
    --card-bg: #B2DFDB; /* Mint */
    --card-inner: #E0F2F1; /* Lighter Mint */
    --btn-bg: #F1FAF9; /* Very Light Mint/Ivory */
    --text-color: #455A64; /* Dark Grey-Green */
    --accent-coral: #FFAB91; /* Coral/Peach */
    --error-red: #EF5350; /* Coral Red */
    --max-pin-length: 6; /* Variabel untuk PIN */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

body {
    background-color: var(--bg-color);
    position: relative;
}

#root {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 94vh;
    flex-direction: column;
    width: 100%;
}

/* Container Utama */
.container {
    position: relative;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header Judul (Hanya di halaman login) */
.main-title {
    font-size: 1.8rem;
    color: #FFAB91;
    margin-bottom: 20px;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    font-family: 'Nunito', sans-serif;
}

/* Card Style Umum */
.card {
    background: var(--card-bg);
    padding: 20px;
    padding-bottom: 80px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(128, 175, 171, 0.3);
    width: 90%;
    max-width: 500px;
    min-height: 350px;
    display: none;
    flex-direction: column;
    transition: all 0.5s ease;
    overflow: hidden;
    position: relative;
}

/* --- HALAMAN 1: LOGIN (PIN) --- */
#login-page {
    display: flex; 
    flex-direction: row;
    width: 90%;
    max-width: 500px;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(128, 175, 171, 0.3);
}

/* Bagian Foto Kiri */
.profile-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.profile-img {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Bagian Keypad Kanan */
.input-section {
    flex: 1;
    background: var(--card-inner);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.status-display {
    background: white;
    padding: 8px 20px;
    border-radius: 20px;
    color: var(--accent-coral);
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 15px;
    min-width: 100px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s;
}

.status-display.error {
    color: var(--error-red);
    animation: shake 0.3s;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.key {
    background: rgba(255, 255, 255, 0.6);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--accent-coral);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.key:hover {
    background: white;
}

.key:active {
    transform: scale(0.95);
}

/* --- HALAMAN 2: SUCCESS (BIRTHDAY) --- */
#success-page {
    /* display: none; */ /* Default sembunyi */
    flex-direction: column;
    width: 100%;
    text-align: center;
    height: 100%;
    overflow-y: auto;
}

.header-text {
    color: #4DB6AC;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: left;
    padding-left: 10px;
    font-family: 'Nunito', sans-serif;
}

.content-frame {
    position: relative;
    width: 100%;
    height: 320px;
    border-radius: 15px;
    overflow: hidden;
    background: black;
    margin-bottom: 20px;
}

.content-frame img, .content-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
}

.overlay-text {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    color: white;
    text-align: left;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.overlay-text h2 {
    font-size: 1.4rem;
    font-family: 'Nunito', sans-serif;
}

.overlay-text p {
    font-size: 0.8rem;
    margin-top: 5px;
    line-height: 1.2;
}

/* Music Note */
#music-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-top: 15px; /* Add space between card and music note */
}

.music-note .fas {
    margin-right: 5px;
}

/* Tombol Navigasi Bawah */
.nav-buttons {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-around;
}

.nav-btn {
    background: var(--btn-bg);
    border: none;
    padding: 8px 15px;
    border-radius: 12px;
    color: var(--accent-coral);
    font-weight: bold;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.nav-btn:hover {
    transform: translateY(-2px);
}

/* Footer Signature */
.footer {
    margin-top: 30px;
    width: 90%;
    text-align: end;
    color: #888;
    font-size: 0.9rem;
}

.signature {
    font-family: 'Great Vibes', sans-serif;
    font-size: 20px;
    color: var(--text-color);
    margin-top: 5px;
}

/* Animasi */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.8s ease forwards;
}

@keyframes bounceInDown {
    0%, 60%, 75%, 90%, 100% {
        transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    }
    0% {
        opacity: 0;
        transform: translate3d(0, -3000px, 0);
    }
    60% {
        opacity: 1;
        transform: translate3d(0, 25px, 0);
    }
    75% {
        transform: translate3d(0, -10px, 0);
    }
    90% {
        transform: translate3d(0, 5px, 0);
    }
    100% {
        transform: none;
    }
}

.bounceInDown {
    animation-name: bounceInDown;
    animation-duration: 1s;
    animation-fill-mode: both;
}

/* Responsif untuk HP */
@media (max-width: 480px) {
    .main-title {
        font-size: 1.5rem; /* Perkecil font di HP */
        line-height: 1.2; /* Atur jarak baris jika teksnya wrap */
        text-align: center; /* Pastikan tetap di tengah */
    }
    #login-page {
        flex-direction: column;
    }
    .card {
        padding: 15px;
        padding-bottom: 70px;
    }
    .input-section {
        width: 100%;
        margin-top: 15px;
    }
    .nav-buttons {
        bottom: 15px;
        left: 15px;
        right: 15px;
    }
    .nav-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    /* .gallery-img {
        height: 80px;
    } */
    .month {
        font-size: 0.6rem;
    }
}

/* --- HALAMAN 3: PROFILE --- */
#profile-page, #lovely-page, #read-me-page {
    display: none; /* Sembunyikan default */
    flex-direction: column;
    width: 100%;
    /* padding: 15px; */
    align-items: center;
    height: 100%;
    overflow-y: auto;
}

#lovely-page, #readme-envelope-view {
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    align-items: center; /* Align items to the top */
    background: var(--card-inner); /* Inner card color */
    padding: 15px;
    border-radius: 15px;
}

.profile-card-img {
    width: 280px; /* Lebar gambar */
    height: auto;
    border-radius: 10px;
    border: 3px solid white;
}

.readme-card-img {
    width: 200px; /* Lebar gambar */
    height: auto;
    border-radius: 10px;
    border: 3px solid white;
}

.profile-text {
    flex: 1;
    color: var(--text-color);
    text-align: center;
    margin-top: 15px;
}

.profile-text h3 {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-coral);
    margin-bottom: 8px;
}

.profile-text p {
    font-size: 0.85rem;
    line-height: 1.4;
}

/* --- LOVELY PAGE --- */
.gallery-wrapper {
    display: flex;
    flex-direction: column; /* Stack gallery and arrows vertically */
    align-items: center;   /* Center them horizontally */
    width: 100%;
}

.gallery-container {
    width: 100%;
    overflow-x: auto; /* Use auto for scrolling */
    scroll-behavior: smooth;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.gallery-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Webkit browsers */
}

.arrow-controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
}

.gallery {
    display: flex;
    gap: 10px;
    padding: 10px;
}

.gallery-item {
    position: relative;
    flex-shrink: 0;
}

.gallery-img {
    height: 150px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.gallery-img.selected {
    transform: scale(1.1);
    border: 3px solid var(--accent-coral);
}

.month {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 2px 5px;
    border-radius: 5px;
    font-size: 0.7rem;
}

.arrow {
    background: rgba(224, 242, 241, 0.7); /* Lighter Mint, semi-transparent */
    border: none;
    border-radius: 50%;
    width: 40px; /* Slightly larger for easier clicking */
    height: 40px;
    font-size: 1.8rem;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.arrow:hover {
    background: rgba(224, 242, 241, 1); /* Opaque on hover */
}

.arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.full-image-container {
    position: relative;
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack image and caption vertically */
    max-width: 90vw;
    max-height: 95vh; /* Ensure the whole card fits the viewport */
    background: var(--card-inner); /* A clean background for the card */
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    overflow: hidden; /* Important for rounded corners and containing children */
    animation: fadeIn 0.3s ease;
}

.caption-text {
    font-size: 0.9rem;
    color: var(--text-color); /* Consistent text color */
    padding: 10px 15px;
    text-align: center;
    background: white; /* A clean background for the caption */
    flex-shrink: 0; /* Prevents the caption from being squished */
    overflow-y: auto; /* Allow caption to scroll if too long */
    /* border-bottom-left-radius and border-bottom-right-radius might be needed if container has border-radius */
}

#full-image {
    display: block;
    width: 100%; /* Fill the container's width */
    object-fit: contain; /* Maintain aspect ratio */
    flex-grow: 1; /* Allow image to expand to fill available vertical space */
    min-height: 0; /* Essential for flex items containing images to prevent overflow */
    border-radius: 0; /* Remove specific image border-radius, let container handle it */
    border: none; /* Remove border from image, it's on the container */
    padding: 10px 10px 0; /* Add padding here to give space around image, not whole container */
}

.collect-btn-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

/* --- IMAGE OVERLAY --- */
#image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none; /* Default hidden */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(5px);
}

#close-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: white;
    border: 2px solid var(--accent-coral);
    color: var(--accent-coral);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.8rem;
    line-height: 31px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1001;
}

/* --- READ ME PAGE --- */
.envelope-img {
    width: 250px;
    animation: fadeIn 1s;
}

/* --- POSTCARD OVERLAY --- */
#postcard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none; /* Default hidden */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.postcard-container {
    position: relative;
}

.postcard {
    position: relative;
    width: 90%;
    max-width: 380px;
    max-height: 80vh; /* Set a maximum height for scrollability */
    overflow-y: auto; /* Enable vertical scrolling */
    background: #F1FAF9;
    border: 1px solid #80CBC4;
    border-radius: 15px;
    padding: 25px;
    padding-bottom: 50px; /* Increase padding to prevent content from being hidden by scrollbar */
    box-shadow: 5px 5px 15px rgba(0,0,0,0.2);
    font-family: 'Nunito', sans-serif;
    color: var(--text-color);
    animation: fadeIn 0.5s;
    background-image: repeating-linear-gradient(
        #F1FAF9 0px,
        #F1FAF9 20px,
        #E0F2F1 20px,
        #E0F2F1 21px
    );
}

#close-postcard-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: white;
    border: 2px solid var(--accent-coral);
    color: var(--accent-coral);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.5rem;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.postcard-header h4 {
    font-weight: normal;
    font-size: 0.9rem;
    text-align: right;
    margin-bottom: 20px;
    border-bottom: 1px dashed #80CBC4;
    padding-bottom: 5px;
}

.postcard-body p {
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 15px;
}

.postcard-footer {
    text-align: right;
    margin-top: 20px;
}

.postcard-footer h5 {
    font-weight: normal;
    font-size: 1rem;
}

.postcard-footer p {
    font-family: 'Great Vibes', cursive;
    font-size: 18px;
    color: var(--accent-coral);
    font-weight: normal;
    margin-top: 5px;
}

.inspiration-footnote {
    width: 100%;
    padding-left: 5px;
    padding-bottom: 2px;
    padding-top: 2rem;
    font-size: 0.7rem;
    font-style: italic;
    color: #9e9e9e;
    pointer-events: none;
    opacity: 0.6; 
}

/* Responsif untuk HP Sangat Kecil */
@media (max-width: 360px) {
    .nav-buttons {
        left: 10px;
        right: 10px;
        gap: 4px;
    }
    .nav-btn {
        padding: 8px 8px;
        font-size: 0.7rem;
        gap: 3px;
    }
}
