/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@300;400;600;700&family=Exo+2:ital,wght@0,300;0,600;0,800;1,400&display=swap');

:root {
    --gold-primary: #C5A059;
    /* Muted Metallic Gold */
    --gold-glow: #E5C57F;
    --red-core: #700505;
    /* Deep Royal Maroon */
    --red-glow: #8B0000;
    --bg-void: #FDFBF7;
    /* Warm Ivory/Cream Paper */
    --glass-panel: rgba(255, 255, 255, 0.9);
    /* Opaque Porcelain */
    --text-main: #2D1B1B;
    /* Very Dark Warm Brown/Grey */
    --text-muted: #6B5B5B;
    --border-active: rgba(197, 160, 89, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Chakra Petch', sans-serif;
    background-color: var(--bg-void);
    min-height: 100vh;
    color: var(--text-main);
    overflow-x: hidden;
    position: relative;
}

/* Canvas Backdrop */
canvas#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* Vignette - Inverted for light mode (white edges?) or just subtle gradient */
.scene-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 30%, rgba(200, 200, 200, 0.1) 100%);
    z-index: 0;
    pointer-events: none;
}

.container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 2px;
    margin: 5vh auto;
}

/* Rotating Living Border */
.card-border-wrap {
    position: relative;
    background: #fff;
    border-radius: 20px;
    padding: 2px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    /* Softer shadow */
}

.card-border-wrap::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent, transparent, transparent, var(--gold-primary));
    animation: rotate-border 4s linear infinite;
}

.card-border-wrap::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent, transparent, transparent, var(--red-core));
    animation: rotate-border 4s linear infinite;
    animation-delay: -2s;
}

@keyframes rotate-border {
    100% {
        transform: rotate(360deg);
    }
}

.glass-card {
    position: relative;
    background: var(--glass-panel);
    border-radius: 18px;
    padding: 3rem 2rem;
    text-align: center;
    z-index: 2;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Inner mesh texture */
.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(#999 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.05;
    z-index: -1;
    border-radius: 18px;
}

.logo-container {
    position: relative;
    width: 130px;
    height: 130px;
    margin: 0 auto 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(184, 134, 11, 0.1) 0%, transparent 70%);
    /* Subtle gold glow */
    animation: pulse-glow 3s infinite alternate;
}

@keyframes pulse-glow {
    from {
        transform: scale(0.8);
        opacity: 0.5;
    }

    to {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.logo {
    width: 110px;
    height: auto;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.15));
}

h1 {
    font-family: 'Exo 2', sans-serif;
    font-weight: 800;
    font-size: 2.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.2rem;
    background: linear-gradient(90deg, var(--text-main), var(--gold-primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

h2 {
    font-family: 'Exo 2', sans-serif;
    font-size: 1.8rem;
    color: var(--gold-primary);
    margin-bottom: 0.5rem;
}

h3 {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

p.subtitle,
p.desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: inline-block;
    padding-bottom: 10px;
}

.input-group,
.form-group {
    margin-bottom: 2rem;
    position: relative;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(197, 160, 89, 0.3);
    padding: 1.2rem;
    color: var(--text-main);
    font-family: 'Exo 2', sans-serif;
    font-weight: 600;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 1px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    background: #fff;
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(184, 134, 11, 0.15);
    transform: scale(1.02);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: #aaa;
    font-weight: 300;
    font-style: italic;
}

button[type="submit"],
.btn-secondary,
.btn-danger {
    width: 100%;
    background: var(--red-core);
    border: none;
    padding: 1.2rem;
    color: #fff;
    font-family: 'Exo 2', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    margin-top: 10px;
}

.btn-secondary {
    background: #fff;
    color: var(--gold-primary);
    border: 2px solid var(--gold-primary);
}

.btn-secondary:hover {
    background: var(--gold-primary);
    color: #fff;
}

.btn-danger {
    background: #800000;
}

.btn-danger:hover {
    background: #b00000;
}

button[type="submit"]::before,
.btn-secondary::before,
.btn-danger::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transition: 0.5s;
}

button[type="submit"]:hover,
.btn-secondary:hover,
.btn-danger:hover {
    box-shadow: 0 5px 15px rgba(214, 0, 0, 0.2);
    transform: translateY(-2px);
}

button[type="submit"]:hover::before,
.btn-secondary:hover::before,
.btn-danger:hover::before {
    left: 100%;
}

.footer {
    margin-top: 3rem;
    font-size: 0.7rem;
    color: #888;
    letter-spacing: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.footer-link {
    color: var(--gold-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
    font-weight: 600;
}

.footer-link:hover {
    color: var(--red-core);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #2e7d32;
    /* darker green for light mode */
    border-radius: 50%;
    box-shadow: 0 0 5px #2e7d32;
}

.error-msg {
    color: #d32f2f;
    background: rgba(255, 235, 238, 0.8);
    padding: 10px;
    border-left: 3px solid var(--red-core);
    margin-top: 15px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Guest List Styles */
.guest-list {
    list-style: none;
    text-align: left;
    margin-top: 20px;
}

.guest-item {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.guest-remove {
    background: transparent;
    border: 1px solid #ccc;
    color: #d32f2f;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    clip-path: none;
}

.guest-remove:hover {
    background: #ffebee;
    color: #b71c1c;
    transform: scale(1.1);
    box-shadow: none;
}

/* Admin Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    color: var(--text-main);
}

th,
td {
    text-align: left;
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

th {
    background: rgba(184, 134, 11, 0.1);
    color: var(--gold-primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.status-checked {
    color: #2e7d32;
    text-shadow: none;
    font-weight: bold;
    border: 1px solid #2e7d32;
    background: #e8f5e9;
    padding: 2px 8px;
    border-radius: 4px;
}

.status-pending {
    color: #757575;
    font-style: italic;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* ======================
   Interactive Flip Ticket 
   ====================== */
.flip-container {
    width: 100%;
    max-width: 500px;
    /* Optimal card size */
    aspect-ratio: 1.6/1;
    /* Enforce Card Ratio */
    height: auto;
    position: relative;
    cursor: pointer;
    z-index: 9999;
    /* Force highest layer */
    pointer-events: auto;
    /* Force clickable */
    margin: 20px auto;
    perspective: 1000px;
    animation: card-entrance 1.5s ease-out forwards;
}

.flipper {
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    position: relative;
    /* Animation moved to parent to avoid Transform Conflict */
}

/* Entrance Animation */
@keyframes card-entrance {
    0% {
        transform: translateY(100vh) rotateX(20deg);
        opacity: 0;
    }

    60% {
        transform: translateY(-20px) rotateX(-5deg);
        opacity: 1;
    }

    100% {
        transform: translateY(0) rotateX(0);
        opacity: 1;
    }
}

.flip-container.flipped .flipper {
    transform: rotateY(180deg);
}

.front,
.back {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--gold-primary);
    /* The Perfect Box Border */
    background: #000;
    /* Prevent transparency gaps */
    -webkit-font-smoothing: antialiased;
}

/* Front: Kad Merah */
.front {
    z-index: 2;
    transform: rotateY(0deg);
}

.front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill the perfect box */
    border-radius: 12px;
}

/* Back: Kad Putih */
.back {
    transform: rotateY(180deg);
    background-image: url('src/kad_putih.png');
    background-size: 100% 100%;
    /* Fill the container */
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    color: #2D1B1B;
}

/* Text Overlays - Adjusted for Landscape */
.name-overlay {
    position: absolute;
    top: 34.5%;
    /* Moved down to sit on the dotted line */
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    font-family: 'Times New Roman', Times, serif;
    /* Certificate Style */
    font-weight: bold;
    font-size: 1rem;
    /* Smaller */
    color: #8B6508;
    /* Darker Gold */
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.details-overlay {
    margin-top: 15px;
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.click-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 15px;
    animation: pulse 2s infinite;
    opacity: 0.8;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

/* Mobile Responsiveness for Flip Ticket */
@media screen and (max-width: 600px) {
    .flip-container {
        max-width: 90%;
        /* Ensure side spacing */
        margin: 10px auto;
    }

    .name-overlay {
        font-size: 0.8rem;
        /* Smaller font on mobile */
        top: 34%;
        /* Slight micro-adjustment for mobile optics */
        width: 90%;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
        font-family: serif;
    }

    canvas,
    .scene-vignette {
        display: none;
    }

    .card-border-wrap {
        padding: 0;
        box-shadow: none;
        background: white;
    }

    .glass-card {
        background: white;
        padding: 0;
        color: black;
        border: none;
    }

    .glass-card::before {
        display: none;
    }

    .btn-secondary,
    .btn-danger,
    .no-print {
        display: none;
    }

    table {
        color: black;
        border: 1px solid #ccc;
    }

    th {
        background: #eee;
        color: black;
    }

    td {
        border-bottom: 1px solid #ccc;
    }

    h1,
    h2,
    h3,
    p {
        color: black !important;
    }
}