/* --- Global Styles & Background --- */
body { 
    font-family: 'Segoe UI', sans-serif; 
    /* Toned down: Dark Midnight Green to Deep Charcoal */
    background: radial-gradient(circle at center, #1a2a22 0%, #0d0d0d 100%);
    background-attachment: fixed;
    color: white; 
    padding: 20px; 
    min-height: 100vh;
    margin: 0;
}

/* --- The Main Glassmorphism Container --- */
.container { 
    max-width: 900px; 
    margin: 40px auto; 
    /* The "Red" is now only inside the glass tint */
    background: rgba(196, 30, 58, 0.05) !important; 
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 30px; 
    border-radius: 20px; 
    /* A soft red glow on the border instead of solid red */
    border: 1px solid rgba(196, 30, 58, 0.3); 
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    position: relative;
}

/* --- Section Styling --- */
.section {
    background: rgba(0, 0, 0, 0.2);
    padding: 25px 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    position: relative;
    border: 1px solid rgba(255, 215, 0, 0.15); 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.section h3 {
    margin-top: 0;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

/* --- Help Toggle & Instruction Card --- */
#helpToggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 18px;
    
    /* Perfect Centering */
    display: flex;
    align-items: center;
    justify-content: center;
    
    transition: all 0.3s ease;
    padding: 0; /* Remove default button padding */
    line-height: 0; /* Prevents text-line offset */
}

#helpToggle:hover {
    background: #ffd700;
    color: #1a472a;
    transform: scale(1.1) rotate(10deg);
    border-color: #ffd700;
}

#instructionCard {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.95em;
    line-height: 1.6;
    color: #e0e0e0;
}

#instructionCard h3 {
    color: #ffd700;
    border: none;
    margin-bottom: 5px;
}

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

/* --- Inputs & Textarea --- */
textarea, input { 
    width: 100%; 
    padding: 10px; 
    border-radius: 8px; 
    border: 1px solid rgba(255, 255, 255, 0.2); 
    background: rgba(0, 0, 0, 0.3); 
    color: #f0f0f0;
    font-family: inherit; 
    box-sizing: border-box; 
    margin-bottom: 10px; 
    transition: all 0.3s ease;
}

textarea:focus, input:focus {
    outline: none;
    border-color: #ffd700; 
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

input.invalid {
    border: 2px solid #ff4d4d !important;
    background-color: #4d1a1a !important;
    box-shadow: 0 0 12px rgba(255, 77, 77, 0.6);
}

textarea { height: 80px; }

/* --- Buttons --- */
button { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; transition: all 0.2s ease; }
button:disabled { opacity:0.5; cursor:not-allowed; }
button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.1); }

.bulk-btn { background:#c41e3a; color:#ffd700; }
.add-btn { background:#c41e3a; color:#ffd700; }
.draw-btn { background:#2e7d32; color:white; font-size: 1.1em; } 
.send-emails-btn { background:#c41e3a; color:#ffd700; }
.clear-matches { background:#b71c1c; color:white; }
button.secondary { background: rgba(255,255,255,0.1); color:white; border: 1px solid rgba(255,255,255,0.2); }
button.danger { background: #b71c1c; color: white; }

/* --- Layout Grids --- */
.p-grid { display:grid; grid-template-columns: 1fr 1fr 1fr; gap:10px; margin-bottom:5px; }
.top-buttons { 
    display:flex; 
    gap:15px; 
    justify-content:space-between; 
    align-items: center;
    margin-bottom:30px; 
    flex-wrap:wrap; 
    background: rgba(0,0,0,0.2); 
    padding: 15px; 
    border-radius: 12px;
}

/* --- Participant Rows --- */
.participant-row {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.participant-row:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
}

.delete-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
    background: none;
    border: none;
    color: #ff4d4d;
    cursor: pointer;
    font-size: 1.2em;
    padding: 5px 10px;
}

.participant-row:hover .delete-btn { opacity: 1; }

/* --- Exclusion Tags --- */
.ex-tag { 
    background: rgba(196, 30, 58, 0.8); 
    font-size: 11px; 
    padding: 4px 10px; 
    border-radius: 20px; 
    display:flex; 
    align-items:center; 
    border: 1px solid rgba(255,255,255,0.2);
}

/* --- Tooltips --- */
/* Tooltip Container */
[data-tooltip] {
    position: relative;
    /* Change 'help' to 'text' for inputs, keep 'help' for buttons */
}

/* Tooltip Text */
[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%; /* Higher up to clear the input box */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
    color: #ffd700; /* Festive gold text */
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10000; /* Ensure it's above EVERYTHING */
    border: 1px solid rgba(255, 215, 0, 0.3);
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* Show on Hover */
[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Cursor logic: Use a standard text cursor for inputs even if they have tooltips */
input[data-tooltip]:hover, textarea[data-tooltip]:hover {
    cursor: text;
}

/* Use help cursor only for buttons/icons */
button[data-tooltip]:hover, span[data-tooltip]:hover {
    cursor: help;
}

/* --- Modals & Progress Bar --- */
/* --- Modal Background --- */
.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    background: rgba(0, 0, 0, 0.85); 
    display: none; /* Controlled by JS */
    align-items: center; 
    justify-content: center; 
    z-index: 10000; 
    backdrop-filter: blur(8px); 
}

/* --- Modal Box --- */
.modal-content { 
    background: #ffffff; /* Solid white for readability */
    color: #333; 
    padding: 30px; 
    border-radius: 20px; 
    width: 90%; 
    max-width: 450px; 
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); 
    border: 4px solid #c41e3a; 
    display: flex;
    flex-direction: column;
}

/* --- Modal Typography --- */
.modal-content h3 { 
    color: #c41e3a; 
    margin-top: 0; 
    font-size: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

/* --- The Options List (Alignment Fix) --- */
.ex-options.scrollable { 
    max-height: 300px; 
    overflow-y: auto; 
    margin: 15px 0;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #eee;
}

/* Fix for the checkbox and label alignment */
.ex-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid #eee;
    color: #333;
}

.ex-row:last-child { border-bottom: none; }

/* Ensure checkboxes don't inherit the global 100% width */
.ex-row input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    cursor: pointer;
}

.ex-row label {
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    flex-grow: 1;
}

/* --- Modal Footer Buttons --- */
.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end; /* Puts buttons on the right */
}

/* Ensure the cancel button is visible and styled */
.modal-footer button.secondary {
    background: #666 !important;
    color: white !important;
}

.modal-footer button:first-child {
    background: #c41e3a;
    color: white;
}

/* Ensure the Select All wrapper matches the alignment of the list rows */
.select-all-wrapper {
    display: flex;
    align-items: center; /* Centers checkbox with text vertically */
    gap: 12px;
    padding: 10px;
    border-bottom: 2px solid #ddd;
    margin-bottom: 5px;
    background: #f0f0f0; /* Slightly darker to distinguish it */
    border-radius: 8px 8px 0 0;
}

/* Force the checkbox inside Select All to stay small */
.select-all-wrapper input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    cursor: pointer;
    flex-shrink: 0; /* Prevents it from squishing */
}

.select-all-wrapper label {
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

#emailProgress {
    height: 100%;
    width: 0%;
    background: repeating-linear-gradient(45deg, #2e7d32, #2e7d32 15px, #1a472a 15px, #1a472a 30px);
    background-size: 42px 42px;
    animation: moveStripes 1s linear infinite;
    color: white;
    font-weight: bold;
    text-align: center;
    line-height: 30px;
    transition: width 0.4s ease;
}

/* Class to stop the candy cane animation when finished */
.progress-finished {
    animation: none !important;
    background: #2e7d32 !important; /* Solid Green */
}


@keyframes moveStripes {
    from { background-position: 0 0; }
    to { background-position: 42px 0; }
}


/* The container that holds everything */
.match-container { 
    position: relative; 
    border-radius: 15px; 
    overflow: hidden; 
    margin-top: 20px; 
    border: 1px solid rgba(255, 215, 0, 0.3);
}

/* The Red "Wrapping Paper" that hides the names */
.gift-overlay { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: #c41e3a; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.3em; 
    font-weight: bold;
    color: white;
    cursor: pointer; 
    z-index: 10; /* Sits on top */
    transition: opacity 0.5s ease;
}

/* The actual list of names */
.match-list { 
    background: #ffffff; /* Solid white so it's readable */
    color: #333; 
    padding: 25px; 
    filter: blur(20px); /* Heavy blur so you can't peek */
    transition: filter 0.5s ease;
    min-height: 100px;
}

/* Fix the header color inside the match results */
.match-list h3 {
    color: #1a1a1a !important; /* Elegant near-black */
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-family: 'Segoe UI', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.match-list div {
    padding: 8px 0;
    border-bottom: 1px solid #f9f9f9;
    color: #444; /* Soft black/dark grey */
    font-size: 1.05em;
}

.match-list b {
    color: #c41e3a; /* Keeps the names slightly festive red */
}


/* Fix the 'Results loaded from file' text color */
#loadStatus, .status-message {
    color: #333333 !important;
    font-weight: 600;
    margin-top: 10px;
}


#copyResultsBtn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffd700; /* Gold text */
    border: 1px solid rgba(255, 215, 0, 0.3);
    transition: all 0.3s ease;
}

#copyResultsBtn:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
}



/* --- THE REVEAL LOGIC --- */

/* When the container gets the 'revealed' class: */
.revealed .gift-overlay { 
    display: none; 
}

.revealed .match-list { 
    filter: blur(0); /* Remove the blur */
}


/* --- Utility --- */
.hidden { display: none !important; }
.scrollable { max-height: 250px; overflow-y: auto; }
