/**
 * City Representative Overlay & Application Form Styles
 * Meraki Cycling Club
 */

:root {
    --rep-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Modal Overlay Backdrop */
.rep-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.rep-modal-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Modal Card */
.rep-modal-card {
    position: relative;
    background: #ffffff;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.94) translateY(12px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--rep-font-family);
    color: #1e293b;
}

.rep-modal-backdrop.is-visible .rep-modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* City Accent Header Strip */
.rep-card-header-bar {
    height: 8px;
    width: 100%;
    background: var(--city-gradient, #03402e);
    flex-shrink: 0;
}

/* Modal Close Button */
.rep-modal-close-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
}

.rep-modal-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: scale(1.08);
}

.rep-modal-close-btn:focus-visible {
    outline: 2px solid var(--city-primary, #03402e);
    outline-offset: 2px;
}

/* Modal Scrollable Content */
.rep-modal-body {
    padding: 2rem 2.25rem 2.25rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

/* City Badge & Header */
.rep-city-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--city-badge-bg, #fee2e2);
    color: var(--city-badge-text, #991b1b);
    border: 1px solid var(--city-badge-border, #fecaca);
    margin-bottom: 1rem;
}

.rep-modal-title {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.25;
    color: #0f172a;
    margin-bottom: 0.75rem;
    padding-right: 2rem;
    letter-spacing: -0.02em;
}

.rep-modal-intro {
    font-size: 0.98rem;
    line-height: 1.65;
    color: #475569;
    margin-bottom: 1.5rem;
}

.rep-modal-intro strong {
    color: #0f172a;
}

/* Form Layout */
.rep-form {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.rep-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.rep-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.rep-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rep-label .rep-optional {
    font-weight: 400;
    font-size: 0.78rem;
    color: #94a3b8;
}

.rep-required-mark {
    color: #ef4444;
    margin-left: 2px;
}

/* Inputs & Select */
.rep-input,
.rep-select,
.rep-textarea {
    width: 100%;
    padding: 0.75rem 0.95rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: #0f172a;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.rep-input:hover,
.rep-select:hover,
.rep-textarea:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}

.rep-input:focus,
.rep-select:focus,
.rep-textarea:focus {
    outline: none;
    border-color: var(--city-primary, #03402e);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--city-glow, rgba(3, 64, 46, 0.15));
}

.rep-input::placeholder,
.rep-textarea::placeholder {
    color: #94a3b8;
}

.rep-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.rep-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* Day Toggle Buttons */
.rep-days-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.2rem;
}

.rep-day-toggle {
    position: relative;
    cursor: pointer;
    user-select: none;
    flex: 1 1 calc(14.28% - 0.5rem);
    min-width: 42px;
}

.rep-day-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.rep-day-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.2rem;
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.rep-day-toggle:hover .rep-day-pill {
    border-color: #cbd5e1;
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-1px);
}

.rep-day-toggle input[type="checkbox"]:focus-visible + .rep-day-pill {
    outline: 2px solid var(--city-primary, #03402e);
    outline-offset: 2px;
}

.rep-day-toggle input[type="checkbox"]:checked + .rep-day-pill {
    background: var(--city-primary, #03402e);
    color: #ffffff;
    border-color: var(--city-primary, #03402e);
    box-shadow: 0 4px 10px var(--city-glow, rgba(3, 64, 46, 0.25));
    transform: translateY(-1px) scale(1.02);
}

/* Error message under inputs */
.rep-field-error {
    font-size: 0.78rem;
    color: #dc2626;
    margin-top: 0.2rem;
    display: none;
    font-weight: 500;
}

.rep-field-error.is-visible {
    display: block;
}

.rep-input.is-invalid,
.rep-select.is-invalid {
    border-color: #ef4444;
    background: #fff5f5;
}

/* Form Alert Box (Network / Server Error) */
.rep-alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    display: none;
    line-height: 1.5;
}

.rep-alert.is-error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Submit CTA Button */
.rep-submit-btn {
    width: 100%;
    padding: 0.95rem 1.5rem;
    font-size: 1.02rem;
    font-weight: 700;
    font-family: inherit;
    color: #ffffff;
    background: var(--city-gradient, #03402e);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--city-glow, rgba(3, 64, 46, 0.25));
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.rep-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--city-glow, rgba(3, 64, 46, 0.35));
    filter: brightness(1.05);
}

.rep-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.rep-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading Spinner */
.rep-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: repSpin 0.75s linear infinite;
}

@keyframes repSpin {
    to { transform: rotate(360deg); }
}

/* Dismiss Link at the bottom */
.rep-dismiss-link-wrap {
    text-align: center;
    margin-top: 0.35rem;
}

.rep-dismiss-link {
    font-size: 0.88rem;
    color: #64748b;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
    padding: 0.25rem 0.5rem;
}

.rep-dismiss-link:hover {
    color: #0f172a;
}

/* Success State View */
.rep-success-view {
    display: none;
    text-align: center;
    padding: 1.5rem 0.5rem;
    animation: repFadeIn 0.4s ease;
}

.rep-success-view.is-visible {
    display: block;
}

.rep-success-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: repBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.rep-success-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.rep-success-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #475569;
    max-width: 480px;
    margin: 0 auto 2rem;
}

.rep-success-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 2rem;
    background: var(--city-gradient, #03402e);
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--city-glow, rgba(3, 64, 46, 0.2));
    transition: all 0.2s ease;
}

.rep-success-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--city-glow, rgba(3, 64, 46, 0.3));
}

@keyframes repBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

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

/* Floating Reopen Pill (Shown when modal is dismissed) */
.rep-floating-pill {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-radius: 9999px;
    padding: 0.65rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-family: var(--rep-font-family);
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    animation: repFadeIn 0.3s ease;
}

.rep-floating-pill:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 28px -5px rgba(0, 0, 0, 0.2);
    border-color: var(--city-primary, #03402e);
}

.rep-floating-pill-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--city-primary, #03402e);
    box-shadow: 0 0 0 3px var(--city-badge-bg, rgba(3, 64, 46, 0.2));
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .rep-modal-backdrop {
        padding: 0.75rem;
        align-items: flex-end;
    }

    .rep-modal-card {
        max-height: 92vh;
        border-radius: 20px 20px 12px 12px;
    }

    .rep-modal-body {
        padding: 1.5rem 1.25rem 1.75rem;
    }

    .rep-modal-title {
        font-size: 1.4rem;
    }

    .rep-form-row {
        grid-template-columns: 1fr;
        gap: 1.15rem;
    }

    .rep-day-toggle {
        flex: 1 1 calc(25% - 0.5rem);
    }

    .rep-day-pill {
        padding: 0.55rem 0.2rem;
        font-size: 0.85rem;
    }

    .rep-floating-pill {
        bottom: 16px;
        right: 16px;
        font-size: 0.82rem;
        padding: 0.55rem 0.95rem;
    }
}
