:root {
    --purple-main: #9564b3;
    --purple-hover: #a85ad9;
    --purple-dark: rgb(102, 2, 111);
}

html, body {
    animation: fadeIn 1.5s ease-in-out forwards;
    height: 100%;
    margin: 0;
    padding: 0;
    background-image: url('/ASSETS/background.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

body {
    padding: 2em;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-direction: column;
    overflow-x: hidden;
}

/* --- Layout Components --- */
.header, .footer {
    text-align: center;
    opacity: 0;
    position: relative; 
    z-index: 10;
}

.header { animation: fadeIn 2s ease-in-out forwards 0.75s; }
.footer { animation: fadeIn 2s ease-in-out forwards 2.25s; }

.header-bismillah { 
    width: 130px; 
    height: auto; 
    position: relative; 
    z-index: 10; 
}

.footer-logo { 
    width: 60px; 
    height: auto; 
    position: relative; 
    z-index: 10; 
}

.header h1 {
    font-family: 'Cinzel', serif;
    font-size: 3.5em;
    color: var(--purple-dark);
    margin-top: 0.3em;
    margin-bottom: 0;
    z-index: 10;
}

.header h2 {
    font-family: 'Cinzel', serif;
    font-size: 1em;
    color: rgb(102, 2, 111);
    margin-block-start: 0;
    margin-block-end: 0;
    position: relative;
    z-index: 10;
}

.header h3 {
    font-family: 'Cinzel', serif;
    font-size: 0.8em;
    color: rgb(102, 2, 111);
    margin-block-start: 0;
    margin-block-end: 0;
    position: relative;
    z-index: 10;
}

.header-flowers { 
    position: fixed; 
    width: 15vh; 
    top: 0; 
    left: 0; 
    margin: 10px; 
    z-index: -1; 
    opacity: 0.8; 
}

.footer-flowers { 
    position: fixed; 
    width: 15vh; 
    bottom: 0; 
    right: 0; 
    margin: 10px; 
    z-index: -1; 
    opacity: 0.8; 
}

/* --- Form Core --- */
form {
    width: 95%;
    max-width: 600px; /* Slightly wider to fit side-by-side counters */
    margin-top: 2em;
    margin-bottom: 5em;
    opacity: 0;
    animation: fadeIn 2s ease-in-out forwards 1.5s;
    position: relative; 
    z-index: 10;
}

input:not([type="checkbox"]):not([type="radio"]), select {
    width: 100%;
    padding: 0.8em;
    margin: 0.5em 0;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.name-inputs { display: flex; justify-content: space-between; gap: 10px; }
.name-inputs input { width: 48%; }

/* --- Attendance Radios --- */
.attendance-options {
    margin: 1em auto;
    color: var(--purple-dark);
    font-family: 'Cinzel', serif;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: fit-content;
}

.attendance-options label { margin-bottom: 0.5em; cursor: pointer; display: flex; align-items: center; }

.attendance-options input[type="radio"], 
.event-count-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--purple-main);
    border: 2px solid #ccc;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.attendance-options input[type="radio"]:checked::before,
.event-count-row input[type="checkbox"]:checked::before {
    content: "✓";
    position: absolute;
    top: -2px;
    left: 2px;
    font-size: 16px;
    color: white;
}

/* --- THE ROW ALIGNMENT FIX --- */
#counterSection {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.8s ease-out, opacity 0.5s ease-out;
    display: block; /* Do not use display: none */
}
#counterSection p {
    color: var(--purple-dark);
    font-family: 'Cinzel', serif;
    font-size: 1em;
    text-align: center;
    width: 100%;
    margin-bottom: 1.5em; /* Adds space before the first event row starts */
    margin-top: 0.5em;
}

#counterSection.show {
    max-height: 2000px; /* High enough for 3 events */
    opacity: 1;
    margin-top: 30px;
}

.event-count-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between; /* Pushes text left, counters right */
    align-items: center;
    width: 100%;
    margin-bottom: 2em;
    padding-bottom: 1em;
    border-bottom: 1px solid rgba(149, 100, 179, 0.1);
    align-items: center;
}

.event-info {
    flex: 1;
    display: flex;
    align-items: center;
    text-align: left;
}

.checkbox-container {
    font-family: 'Cinzel', serif;
    font-size: 1em;
    color: var(--purple-dark);
    display: flex;
    align-items: center;
}

.label-text small {
    display: block;
    white-space: nowrap;
    font-size: 0.7em;
    opacity: 0.8;
}

/* --- Counter Styling --- */
.event-counters {
    display: flex;
    flex-direction: row;
    gap: 15px;
    width: 100%;
    justify-content: center;
    overflow: visible;
}

.counter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 65PX;
    min-width: 65px;
    gap: 2px; /* Small gap between all elements in the column */
    overflow: visible;
}

.badge-label {
    background-color: var(--purple-main);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.55em;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 6px;
    font-family: Arial, sans-serif;
    text-align: center;
    white-space: nowrap;
}

.counter-group button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--purple-main);
    background-color: transparent;
    color: var(--purple-main);
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: all 0.2s ease;
    line-height: 1;
}

.counter-group button:hover {
    background-color: var(--purple-main);
    color: white;
}

/* Specific styling for the number display in the middle */
.counter-group span[id$="_display"] {
    font-family: 'Cinzel', serif;
    font-size: 1.3em;
    color: var(--purple-dark);
    margin: 2px 0;
    font-weight: bold;
}

/* --- Submit Button --- */
#submit-btn {
    background-color: var(--purple-dark);
    color: white;
    width: 100%;
    padding: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    font-family: 'Cinzel', serif;
    margin-top: 1em;
}

#submit-btn:hover { background-color: var(--purple-main); }

/* --- Mobile Fixes --- */
@media screen and (max-width: 480px) {
    .event-count-row {
        flex-direction: column; /* Stack if screen is tiny */
        align-items: flex-start;
        gap: 10px;
    }

    .event-counters {
        width: 100%;
        justify-content: center;
    }

    .header h1 { font-size: 2.5em; }
    
    .badge-label { font-size: 0.55em; padding: 2px 6px; }
}

@media screen and (min-width: 768px) {
    .header-flowers, .footer-flowers { width: 40vh; }
    .footer-logo { width: 100px; }
    .header-bismillah { width: 500px; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Spinner for Loading */
#submit-btn.loading { position: relative; color: transparent; pointer-events: none; }
#submit-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 1.2em; height: 1.2em;
    margin: -0.6em 0 0 -0.6em;
    border: 2px solid white;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }