/* ============================================
   AUTH MODAL - Login & Registration
   ============================================ */

/* --- Overlay --- */
.auth-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-overlay.active {
    display: flex;
}

/* --- Modal Box --- */
.auth-modal {
    background: var(--color-light);
    width: 100%;
    max-width: 380px;
    max-height: 90vh;
    border-radius: 4px;
    overflow-y: auto;
    position: relative;
    animation: authModalIn 0.3s ease;
}

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

/* --- Close Button --- */
.auth-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--color-gray);
    cursor: pointer;
    z-index: 2;
    line-height: 1;
    transition: color var(--transition);
}

.auth-modal-close:hover {
    color: var(--color-dark);
}

/* --- Modal Content --- */
.auth-modal-body {
    padding: 30px 25px;
}

.auth-modal-body .auth-intro,
.auth-modal-body .auth-account-links {
    padding-right: 20px;
}

.auth-modal-body .auth-intro {
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.6;
    margin-bottom: 22px;
}

.auth-modal-body .auth-intro strong {
    color: var(--color-dark);
    font-weight: 700;
}

/* --- Form Fields --- */
.auth-field {
    margin-bottom: 14px;
}

.auth-field label {
    display: block;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-dark);
    margin-bottom: 5px;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--color-text);
    box-sizing: border-box;
    transition: border-color var(--transition);
}

.auth-field input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* --- Password wrapper with toggle --- */
.auth-password-wrap {
    position: relative;
}

.auth-password-wrap input {
    padding-right: 40px;
}

.auth-password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-gray);
    font-size: 16px;
    padding: 4px;
    transition: color var(--transition);
}

.auth-password-toggle:hover {
    color: var(--color-dark);
}

/* --- Radio Group (Single / Group account) --- */
.auth-radio-group {
    display: flex;
    gap: 25px;
    margin-bottom: 18px;
}

.auth-radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
}

.auth-radio-group input[type="radio"] {
    accent-color: var(--color-dark);
    cursor: pointer;
}

/* --- Name Row (first + last) --- */
.auth-name-row {
    display: flex;
    gap: 12px;
}

.auth-name-row .auth-field {
    flex: 1;
}

/* --- Group Members Block --- */
.auth-group-members {
    margin-top: 4px;
    margin-bottom: 14px;
}

.auth-group-members-title {
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-dark);
    margin-bottom: 8px;
}

.auth-group-members-title span {
    font-weight: 400;
    font-style: italic;
    color: var(--color-gray);
    font-size: 12px;
}

.auth-group-members .auth-field {
    margin-bottom: 0;
}

/* --- Member Row (dynamic) --- */
.auth-member-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 8px;
}

.auth-member-row .auth-name-row {
    flex: 1;
    margin-bottom: 0;
}

.auth-member-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    padding-top: 2px;
    flex-shrink: 0;
}

.auth-member-add,
.auth-member-remove {
    width: 26px;
    height: 26px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-dark);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.auth-member-add:hover {
    background: var(--color-dark);
    color: var(--color-white);
}

.auth-member-remove {
    border-color: #d32f2f;
    color: #d32f2f;
}

.auth-member-remove:hover {
    background: #d32f2f;
    color: var(--color-white);
}

/* --- Account Type Links --- */
.auth-account-links {
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--color-text);
    margin-bottom: 18px;
    line-height: 1.6;
}

.auth-account-links a {
    color: var(--color-dark);
    text-decoration: underline;
    font-weight: 600;
}

.auth-account-links a:hover {
    color: var(--color-primary);
}

/* --- Buttons --- */
.auth-btn {
    display: block;
    width: 100%;
    padding: 14px;
    font-family: var(--font-accent);
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background var(--transition);
    text-align: center;
}

.auth-btn-login {
    background: var(--color-primary);
    color: var(--color-white);
    margin-bottom: 10px;
}

.auth-btn-login:hover {
    background: var(--color-primary-dark);
}

.auth-btn-create {
    background: var(--color-dark);
    color: var(--color-white);
}

.auth-btn-create:hover {
    background: #333;
}

.auth-btn-back {
    background: none;
    border: none;
    color: var(--color-gray);
    font-family: var(--font-main);
    font-size: 13px;
    cursor: pointer;
    margin-top: 14px;
    display: block;
    width: 100%;
    text-align: center;
    transition: color var(--transition);
    text-decoration: underline;
}

.auth-btn-back:hover {
    color: var(--color-dark);
}

/* --- Form Panel Toggle --- */
.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
}

/* --- Compact mode (Group account) --- */
.auth-modal.compact .auth-modal-body {
    padding: 20px 22px;
}

.auth-modal.compact .auth-account-links {
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.auth-modal.compact .auth-radio-group {
    margin-bottom: 12px;
}

.auth-modal.compact .auth-field {
    margin-bottom: 8px;
}

.auth-modal.compact .auth-field label {
    font-size: 12px;
    margin-bottom: 3px;
}

.auth-modal.compact .auth-field input[type="text"],
.auth-modal.compact .auth-field input[type="email"],
.auth-modal.compact .auth-field input[type="password"] {
    padding: 7px 10px;
    font-size: 13px;
}

.auth-modal.compact .auth-group-members {
    margin-top: 2px;
    margin-bottom: 10px;
}

.auth-modal.compact .auth-group-members-title {
    font-size: 12px;
    margin-bottom: 6px;
}

.auth-modal.compact .auth-group-members .auth-name-row {
    margin-bottom: 5px;
}

.auth-modal.compact .auth-group-members .auth-field input {
    padding: 6px 8px;
    font-size: 12px;
}

.auth-modal.compact .auth-btn {
    padding: 11px;
    font-size: 14px;
}

.auth-modal.compact .auth-btn-back {
    margin-top: 10px;
}

/* --- Field Error Messages --- */
.auth-field-error {
    display: block;
    font-family: var(--font-main);
    font-size: 11px;
    color: #d32f2f;
    margin-top: 4px;
    line-height: 1.3;
}

.auth-input-error {
    border-color: #d32f2f !important;
}

/* --- General Error (top of form) --- */
.auth-general-error {
    background: #fdecea;
    color: #d32f2f;
    font-family: var(--font-main);
    font-size: 13px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-left: 3px solid #d32f2f;
    line-height: 1.4;
}

/* --- Success Message --- */
.auth-success-message {
    text-align: center;
    padding: 30px 10px;
}

.auth-success-message p {
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .auth-modal {
        max-width: 100%;
    }

    .auth-modal-body {
        padding: 25px 18px;
    }

    .auth-name-row {
        flex-direction: column;
        gap: 0;
    }
}
