/* ============================================
   JOIN US DIALOG — Betapsyche
   Black & white theme, smooth animations
   ============================================ */

/* ----- Overlay ----- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

.dialog-overlay.is-active {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 1;
    visibility: visible;
}

/* ----- Dialog Container ----- */
.dialog-container {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 24px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 24px 68px rgba(0, 0, 0, 0.16),
        0 8px 28px rgba(0, 0, 0, 0.08);
    transform: translateY(30px) scale(0.96);
    opacity: 0;
    transition: all 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.dialog-overlay.is-active .dialog-container {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Custom scrollbar */
.dialog-container::-webkit-scrollbar {
    width: 6px;
}

.dialog-container::-webkit-scrollbar-track {
    background: transparent;
}

.dialog-container::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.dialog-container::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* ----- Dialog Header ----- */
.dialog-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 32px 36px 0;
    background: #fff;
    border-radius: 24px 24px 0 0;
}

.dialog-header-text {
    flex: 1;
}

.dialog-header-text h2 {
    font-family: var(--font-family-one);
    font-weight: var(--font-weight-one-bold);
    font-size: 2.8rem;
    line-height: 1.2;
    margin: 0 0 6px;
    color: #151618;
    letter-spacing: -0.02em;
}

.dialog-header-text p {
    font-family: var(--font-family-three);
    font-size: 1.5rem;
    font-weight: var(--font-weight-three-regular);
    line-height: 1.5;
    margin: 0;
    color: #6b6b6b;
}

/* ----- Close Button ----- */
.dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 16px;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    border-radius: 50%;
    background: #f2f2f2;
    transition: all 0.2s ease;
}

.dialog-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

.dialog-close svg {
    width: 14px;
    height: 14px;
    fill: #151618;
}

/* ----- Dialog Body (Form) ----- */
.dialog-body {
    padding: 28px 36px 36px;
}

/* ----- Form Groups ----- */
.form-group {
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(16px);
    animation: formFieldIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.form-group:nth-child(1) { animation-delay: 0.08s; }
.form-group:nth-child(2) { animation-delay: 0.14s; }
.form-group:nth-child(3) { animation-delay: 0.20s; }
.form-group:nth-child(4) { animation-delay: 0.26s; }
.form-group:nth-child(5) { animation-delay: 0.32s; }

@keyframes formFieldIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group:last-of-type {
    margin-bottom: 28px;
}

/* ----- Labels ----- */
.form-label {
    display: block;
    font-family: var(--font-family-three);
    font-size: 1.5rem;
    font-weight: 600;
    color: #151618;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.form-label .required-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #151618;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* ----- Hint labels ----- */
.form-hint {
    display: block;
    font-family: var(--font-family-three);
    font-size: 1.25rem;
    font-weight: var(--font-weight-three-regular);
    color: #999;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* ----- Inputs & Textarea ----- */
.form-input,
.form-textarea {
    display: block;
    width: 100%;
    font-family: var(--font-family-three);
    font-size: 1.6rem;
    font-weight: var(--font-weight-three-regular);
    line-height: 1.5;
    color: #151618;
    background: #f9f9f9;
    border: 1.5px solid #e5e5e5;
    border-radius: 14px;
    padding: 14px 18px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #bbb;
    font-weight: 400;
}

.form-input:hover,
.form-textarea:hover {
    border-color: #ccc;
    background: #f5f5f5;
}

.form-input:focus,
.form-textarea:focus {
    border-color: #151618;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(21, 22, 24, 0.08);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* ----- Validation States ----- */
.form-group.has-error .form-input,
.form-group.has-error .form-textarea {
    border-color: #e53935;
    background: #fff5f5;
}

.form-group.has-error .form-input:focus,
.form-group.has-error .form-textarea:focus {
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

.form-group.is-valid .form-input,
.form-group.is-valid .form-textarea {
    border-color: #2e7d32;
    background: #f5fff5;
}

.form-group.is-valid .form-input:focus,
.form-group.is-valid .form-textarea:focus {
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.08);
}

/* ----- Error Message ----- */
.form-error {
    display: none;
    font-family: var(--font-family-three);
    font-size: 1.2rem;
    font-weight: 500;
    color: #e53935;
    margin-top: 6px;
    padding-left: 2px;
    line-height: 1.3;
    animation: errorShake 0.3s ease;
}

.form-group.has-error .form-error {
    display: block;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* ----- Valid Checkmark ----- */
.form-valid-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 18px;
    height: 18px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

/* For textarea, anchor icon to top-right */
.form-input-wrap:has(.form-textarea) .form-valid-icon {
    top: 16px;
    transform: translateY(0) scale(0);
}

.form-group.is-valid .form-input-wrap:has(.form-textarea) .form-valid-icon {
    transform: translateY(0) scale(1);
}

.form-input-wrap {
    position: relative;
}

.form-group.is-valid .form-valid-icon {
    transform: translateY(-50%) scale(1);
}

.form-valid-icon svg {
    width: 18px;
    height: 18px;
    fill: #2e7d32;
}

/* ----- Submit Button ----- */
.dialog-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    font-family: var(--font-family-three);
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1;
    padding: 18px 32px;
    color: #fff;
    background: #151618;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    position: relative;
    overflow: hidden;
}

.dialog-submit::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dialog-submit:hover {
    background: #2a2b2e;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.dialog-submit:hover::before {
    opacity: 1;
}

.dialog-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dialog-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ----- Submit Loading State ----- */
.dialog-submit .submit-text {
    transition: opacity 0.2s ease;
}

.dialog-submit.is-loading .submit-text {
    opacity: 0;
}

.dialog-submit .submit-spinner {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    animation: spinRotate 0.7s linear infinite;
}

.dialog-submit.is-loading .submit-spinner {
    opacity: 1;
}

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

/* ----- Submit Arrow Icon ----- */
.submit-arrow {
    display: inline-flex;
    transition: transform 0.2s ease;
}

.dialog-submit:hover .submit-arrow {
    transform: translateX(3px);
}

.submit-arrow svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ============================================
   SUCCESS SCREEN
   ============================================ */

.dialog-success {
    display: none;
    text-align: center;
    padding: 48px 36px 40px;
    animation: successIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dialog-success.is-visible {
    display: block;
}

@keyframes successIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Success icon circle */
.success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: #151618;
    animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

@keyframes successPop {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-icon svg {
    width: 36px;
    height: 36px;
    fill: #fff;
    animation: checkDraw 0.4s ease 0.45s both;
}

@keyframes checkDraw {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.success-title {
    font-family: var(--font-family-one);
    font-weight: var(--font-weight-one-bold);
    font-size: 2.6rem;
    color: #151618;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
    animation: successTextIn 0.5s ease 0.3s both;
}

.success-message {
    font-family: var(--font-family-three);
    font-size: 1.5rem;
    font-weight: var(--font-weight-three-regular);
    color: #6b6b6b;
    line-height: 1.6;
    margin: 0 auto 28px;
    max-width: 380px;
    animation: successTextIn 0.5s ease 0.4s both;
}

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

.success-close-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-family-three);
    font-size: 1.5rem;
    font-weight: 600;
    color: #151618;
    background: #f2f2f2;
    border: none;
    border-radius: 100px;
    padding: 14px 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: successTextIn 0.5s ease 0.5s both;
}

.success-close-btn:hover {
    background: #e5e5e5;
    transform: translateY(-1px);
}

/* ----- Celebration Particles ----- */
.dialog-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 24px;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: particleFall 1.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes particleFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(120px) rotate(720deg) scale(0);
    }
}

/* ----- Server Error ----- */
.dialog-server-error {
    display: none;
    font-family: var(--font-family-three);
    font-size: 1.3rem;
    font-weight: 500;
    color: #e53935;
    text-align: center;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #fff5f5;
    border: 1px solid rgba(229, 57, 53, 0.15);
    border-radius: 12px;
    animation: errorShake 0.3s ease;
}

.dialog-server-error.is-visible {
    display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .dialog-container {
        max-width: 100%;
        border-radius: 20px;
        max-height: 92vh;
    }

    .dialog-header {
        padding: 24px 24px 0;
        border-radius: 20px 20px 0 0;
    }

    .dialog-header-text h2 {
        font-size: 2.3rem;
    }

    .dialog-header-text p {
        font-size: 1.3rem;
    }

    .dialog-body {
        padding: 22px 24px 28px;
    }

    .form-input,
    .form-textarea {
        font-size: 1.6rem;
        padding: 13px 16px;
        border-radius: 12px;
    }

    .dialog-submit {
        font-size: 1.6rem;
        padding: 16px 28px;
    }

    .success-icon {
        width: 64px;
        height: 64px;
    }

    .success-icon svg {
        width: 28px;
        height: 28px;
    }

    .success-title {
        font-size: 2.2rem;
    }

    .dialog-success {
        padding: 36px 24px 32px;
    }
}

@media (max-width: 380px) {
    .dialog-header-text h2 {
        font-size: 2rem;
    }

    .form-label {
        font-size: 1.35rem;
    }

    .form-hint {
        font-size: 1.15rem;
    }
}
