/* ==========================================================================
   competition_registration.css
   Split-Panel Registration Wizard & M-Pesa Payment Modals
   ========================================================================== */

/* ------------------------------------------------------------------
   Backdrop & Animations
   ------------------------------------------------------------------ */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-backdrop.hidden {
    display: none;
    opacity: 0;
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ------------------------------------------------------------------
   Main Modal Container
   ------------------------------------------------------------------ */
.modal-container.registration-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 1000px; /* Slightly wider to accommodate 2x2 grid comfortably */
    height: 85vh;
    max-height: 800px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 10001;
    overflow: hidden;
    animation: slideInUp 0.3s var(--smooth);
    font-family: var(--font-sans);
}

.modal-container.registration-modal.hidden {
    display: none;
}

.registration-modal-content {
    width: 100%;
    height: 100%;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
}

.modal-close-btn:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    transform: rotate(90deg);
}

/* ------------------------------------------------------------------
   Split Layout (Sidebar vs Main Form)
   ------------------------------------------------------------------ */
.reg-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Left Sidebar (Context) */
.reg-sidebar {
    width: 400px; /* Slightly wider */
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Right Panel (Form) */
.reg-main {
    flex: 1;
    background: var(--bg-card);
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Custom Scrollbars for panels */
.reg-sidebar::-webkit-scrollbar, .reg-main::-webkit-scrollbar { width: 6px; }
.reg-sidebar::-webkit-scrollbar-track, .reg-main::-webkit-scrollbar-track { background: transparent; }
.reg-sidebar::-webkit-scrollbar-thumb, .reg-main::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 4px; }

/* ------------------------------------------------------------------
   Sidebar Elements
   ------------------------------------------------------------------ */
.reg-image-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.reg-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reg-image-placeholder {
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: rgba(255,255,255,0.4);
}

.reg-comp-title {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    margin: 0 0 20px 0;
    line-height: var(--line-height-tight);
}

/* 2x2 META GRID FIX */
.reg-meta-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* FORCES 2 COLUMNS */
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
}

.reg-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    min-width: 0; /* Prevents overflow pushing grid */
}

.reg-meta-item i {
    color: var(--primary);
    width: 16px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.meta-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.meta-text span {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: var(--font-bold);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.meta-text strong {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Truncates long text gracefully */
}

/* Rules Section */
.reg-rules-section {
    margin-top: auto;
}

.reg-rules-section h4 {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-bold);
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rules-scroll-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    max-height: 180px;
    overflow-y: auto;
    line-height: var(--line-height-relaxed);
}

/* ------------------------------------------------------------------
   Main Form Elements
   ------------------------------------------------------------------ */
.reg-main-header {
    margin-bottom: 30px;
    padding-right: 40px;
}

.reg-main-header h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.reg-main-header p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin: 0;
}

.reg-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.section-title {
    font-size: 15px;
    font-weight: var(--font-bold);
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg-secondary);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 30px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.full-width { grid-column: 1 / -1; }

.form-label {
    font-size: 13px;
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
}

.input-help {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: -4px;
}

.readonly-field {
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-medium);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: var(--font-medium);
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 14px;
}

.premium-input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.premium-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(53, 168, 240, 0.15);
}

/* Payment Receipt */
.payment-receipt {
    background: rgba(53, 168, 240, 0.05);
    border: 1px solid rgba(53, 168, 240, 0.2);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 6px 0;
}

.total-row {
    border-top: 1px dashed rgba(53, 168, 240, 0.3);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: var(--font-bold);
    color: var(--text-primary);
    font-size: 16px;
}

.total-amount { color: var(--primary-dark); }

/* Custom Checkbox */
.custom-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.custom-checkbox input { display: none; }

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-card);
    position: relative;
    transition: var(--transition-fast);
}

.custom-checkbox input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.custom-checkbox input:checked + .checkmark::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    color: white;
    font-size: 10px;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.check-text { font-size: 13px; color: var(--text-secondary); }
.terms-link { color: var(--primary); font-weight: var(--font-semibold); text-decoration: none; }
.terms-link:hover { text-decoration: underline; }

.validation-error { display: none; color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Buttons */
.form-actions { margin-top: auto; display: flex; justify-content: flex-end; gap: 12px; }

.btn-wizard {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; border-radius: 10px; font-size: 14px; font-weight: var(--font-bold);
    cursor: pointer; transition: var(--transition); border: none; min-width: 120px;
}

.btn-wizard-outline { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-medium); }
.btn-wizard-outline:hover { background: var(--border-dark); }

.btn-wizard-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-wizard-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--glow); }
.btn-wizard-primary:disabled { background: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; transform: none; box-shadow: none; }

/* ------------------------------------------------------------------
   Loading & Confirmation Overlays
   ------------------------------------------------------------------ */
.modal-container.loading-modal, .modal-container.confirmation-modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 10500; display: flex; align-items: center; justify-content: center;
}

.modal-container.loading-modal { width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(4px); }
.modal-container.loading-modal.hidden { display: none; }

.loading-content {
    background: var(--bg-card); padding: 32px 40px; border-radius: var(--border-radius);
    text-align: center; box-shadow: var(--shadow-xl);
}
.loading-spinner { font-size: 40px; color: var(--primary); margin-bottom: 16px; }
.loading-text h3 { margin: 0 0 8px 0; font-size: 18px; color: var(--text-primary); }
.loading-text p { margin: 0; color: var(--text-secondary); font-size: 14px; }

.modal-container.confirmation-modal { width: 100%; max-width: 450px; padding: 20px; }
.modal-container.confirmation-modal.hidden { display: none; }

.confirmation-content {
    background: var(--bg-card); border-radius: var(--border-radius-lg); overflow: hidden;
    width: 100%; box-shadow: var(--shadow-xl); animation: slideInUp 0.3s var(--smooth);
}

.confirmation-header {
    background: var(--gradient-primary); padding: 20px 24px; color: white;
    display: flex; justify-content: space-between; align-items: center;
}
.confirmation-header h3 { margin: 0; font-size: 18px; }
.close-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; opacity: 0.8; transition: var(--transition-fast); }
.close-btn:hover { opacity: 1; transform: scale(1.1); }

.confirmation-body { padding: 30px 24px; text-align: center; color: var(--text-primary); line-height: 1.6; }
.confirmation-actions { padding: 20px 24px; background: var(--bg-primary); border-top: 1px solid var(--border-light); display: flex; gap: 12px; }
.confirmation-actions .btn-wizard { flex: 1; }

/* ------------------------------------------------------------------
   Responsive Adjustments
   ------------------------------------------------------------------ */
@media (max-width: 850px) {
    .reg-layout { flex-direction: column; overflow-y: auto; }
    .reg-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-light); padding: 24px; }
    .reg-main { overflow-y: visible; padding: 24px; }
    .modal-container.registration-modal { height: 90vh; }
    
    /* Flow sidebar nicely for mobile */
    .reg-image-wrapper { max-width: 250px; margin: 0 auto 20px auto; }
    .reg-comp-title { text-align: center; }
}

@media (max-width: 576px) {
    .form-grid { grid-template-columns: 1fr; }
    .reg-meta-list { grid-template-columns: 1fr; } /* Stacks the 2x2 grid back to a column on tiny phones */
    .form-actions { flex-direction: column-reverse; }
    .btn-wizard { width: 100%; }
    .modal-container.registration-modal { height: 100vh; max-height: 100vh; border-radius: 0; }
    .confirmation-actions { flex-direction: column; }
}